diff --git a/rds/kubernetes/endpoints.go b/rds/kubernetes/endpoints.go index b183a8aa..7c464290 100644 --- a/rds/kubernetes/endpoints.go +++ b/rds/kubernetes/endpoints.go @@ -36,8 +36,8 @@ type epLister struct { kClient *client mu sync.RWMutex // Mutex for names and cache - names []string - cache map[string]*epInfo + keys []resourceKey + cache map[resourceKey]*epInfo l *logger.Logger } @@ -67,16 +67,16 @@ func (lister *epLister) listResources(req *pb.ListResourcesRequest) ([]*pb.Resou lister.mu.RLock() defer lister.mu.RUnlock() - for _, name := range lister.names { - if epName != "" && name != epName { + for _, key := range lister.keys { + if epName != "" && key.name != epName { continue } - if nameFilter != nil && !nameFilter.Match(name, lister.l) { + if nameFilter != nil && !nameFilter.Match(key.name, lister.l) { continue } - epi := lister.cache[name] + epi := lister.cache[key] if nsFilter != nil && !nsFilter.Match(epi.Metadata.Namespace, lister.l) { continue } @@ -141,7 +141,7 @@ func (epi *epInfo) resources(portFilter *filter.RegexFilter, l *logger.Logger) ( return } -func parseEndpointsJSON(resp []byte) (names []string, endpoints map[string]*epInfo, err error) { +func parseEndpointsJSON(resp []byte) (keys []resourceKey, endpoints map[resourceKey]*epInfo, err error) { var itemList struct { Items []*epInfo } @@ -150,11 +150,11 @@ func parseEndpointsJSON(resp []byte) (names []string, endpoints map[string]*epIn return } - names = make([]string, len(itemList.Items)) - endpoints = make(map[string]*epInfo) + keys = make([]resourceKey, len(itemList.Items)) + endpoints = make(map[resourceKey]*epInfo) for i, item := range itemList.Items { - names[i] = item.Metadata.Name - endpoints[item.Metadata.Name] = item + keys[i] = resourceKey{item.Metadata.Namespace, item.Metadata.Name} + endpoints[keys[i]] = item } return @@ -166,16 +166,16 @@ func (lister *epLister) expand() { lister.l.Warningf("epLister.expand(): error while getting endpoints list from API: %v", err) } - names, endpoints, err := parseEndpointsJSON(resp) + keys, endpoints, err := parseEndpointsJSON(resp) if err != nil { lister.l.Warningf("epLister.expand(): error while parsing endpoints API response (%s): %v", string(resp), err) } - lister.l.Infof("epLister.expand(): got %d endpoints", len(names)) + lister.l.Infof("epLister.expand(): got %d endpoints", len(keys)) lister.mu.Lock() defer lister.mu.Unlock() - lister.names = names + lister.keys = keys lister.cache = endpoints } diff --git a/rds/kubernetes/endpoints_test.go b/rds/kubernetes/endpoints_test.go index 2dcf1fee..f8a0d736 100644 --- a/rds/kubernetes/endpoints_test.go +++ b/rds/kubernetes/endpoints_test.go @@ -15,20 +15,24 @@ func TestParseEndpoints(t *testing.T) { if err != nil { t.Fatalf("error reading test data file: %s", epListFile) } - _, epByName, err := parseEndpointsJSON(data) + _, epByKey, err := parseEndpointsJSON(data) if err != nil { t.Fatalf("error reading test data file: %s", epListFile) } - testNames := []string{"cloudprober", "cloudprober-test", "kubernetes"} - for _, testP := range testNames { - if epByName[testP] == nil { - t.Errorf("didn't get endpoints by the name: %s", testP) + testKeys := []resourceKey{ + {"default", "cloudprober"}, + {"default", "cloudprober-test"}, + {"system", "kubernetes"}, + } + for _, key := range testKeys { + if epByKey[key] == nil { + t.Errorf("didn't get endpoints for %+v", key) } } - for _, name := range testNames[:1] { - epi := epByName[name] + for _, key := range testKeys[:1] { + epi := epByKey[key] if epi.Metadata.Labels["app"] != "cloudprober" { t.Errorf("cloudprober endpoints app label: got=%s, want=cloudprober", epi.Metadata.Labels["app"]) } diff --git a/rds/kubernetes/kubernetes.go b/rds/kubernetes/kubernetes.go index c61c227e..95c142fe 100644 --- a/rds/kubernetes/kubernetes.go +++ b/rds/kubernetes/kubernetes.go @@ -98,6 +98,10 @@ type kMetadata struct { Labels map[string]string } +type resourceKey struct { + namespace, name string +} + // ListResources returns the list of resources from the cache. func (p *Provider) ListResources(req *pb.ListResourcesRequest) (*pb.ListResourcesResponse, error) { tok := strings.SplitN(req.GetResourcePath(), "/", 2) diff --git a/rds/kubernetes/pods.go b/rds/kubernetes/pods.go index 90ed00f3..aea045e2 100644 --- a/rds/kubernetes/pods.go +++ b/rds/kubernetes/pods.go @@ -34,8 +34,8 @@ type podsLister struct { kClient *client mu sync.RWMutex // Mutex for names and cache - names []string - cache map[string]*podInfo + keys []resourceKey + cache map[resourceKey]*podInfo l *logger.Logger } @@ -59,12 +59,12 @@ func (pl *podsLister) listResources(req *pb.ListResourcesRequest) ([]*pb.Resourc pl.mu.RLock() defer pl.mu.RUnlock() - for _, name := range pl.names { - if nameFilter != nil && !nameFilter.Match(name, pl.l) { + for _, key := range pl.keys { + if nameFilter != nil && !nameFilter.Match(key.name, pl.l) { continue } - pod := pl.cache[name] + pod := pl.cache[key] if nsFilter != nil && !nsFilter.Match(pod.Metadata.Namespace, pl.l) { continue } @@ -73,7 +73,7 @@ func (pl *podsLister) listResources(req *pb.ListResourcesRequest) ([]*pb.Resourc } resources = append(resources, &pb.Resource{ - Name: proto.String(name), + Name: proto.String(key.name), Ip: proto.String(pod.Status.PodIP), Labels: pod.Metadata.Labels, }) @@ -91,7 +91,7 @@ type podInfo struct { } } -func parsePodsJSON(resp []byte) (names []string, pods map[string]*podInfo, err error) { +func parsePodsJSON(resp []byte) (keys []resourceKey, pods map[resourceKey]*podInfo, err error) { var itemList struct { Items []*podInfo } @@ -100,14 +100,14 @@ func parsePodsJSON(resp []byte) (names []string, pods map[string]*podInfo, err e return } - names = make([]string, len(itemList.Items)) - pods = make(map[string]*podInfo) + keys = make([]resourceKey, len(itemList.Items)) + pods = make(map[resourceKey]*podInfo) for i, item := range itemList.Items { if item.Status.Phase != "Running" { continue } - names[i] = item.Metadata.Name - pods[item.Metadata.Name] = item + keys[i] = resourceKey{item.Metadata.Namespace, item.Metadata.Name} + pods[keys[i]] = item } return @@ -119,16 +119,16 @@ func (pl *podsLister) expand() { pl.l.Warningf("podsLister.expand(): error while getting pods list from API: %v", err) } - names, pods, err := parsePodsJSON(resp) + keys, pods, err := parsePodsJSON(resp) if err != nil { pl.l.Warningf("podsLister.expand(): error while parsing pods API response (%s): %v", string(resp), err) } - pl.l.Infof("podsLister.expand(): got %d pods", len(names)) + pl.l.Infof("podsLister.expand(): got %d pods", len(keys)) pl.mu.Lock() defer pl.mu.Unlock() - pl.names = names + pl.keys = keys pl.cache = pods } diff --git a/rds/kubernetes/pods_test.go b/rds/kubernetes/pods_test.go index d8dc0cec..1f1bb019 100644 --- a/rds/kubernetes/pods_test.go +++ b/rds/kubernetes/pods_test.go @@ -24,18 +24,25 @@ import ( ) func testPodInfo(name, ns, ip string, labels map[string]string) *podInfo { + labels["namespace"] = ns pi := &podInfo{Metadata: kMetadata{Name: name, Namespace: ns, Labels: labels}} pi.Status.PodIP = ip return pi } func TestListResources(t *testing.T) { - pl := &podsLister{} - pl.names = []string{"podA", "podB", "podC"} - pl.cache = map[string]*podInfo{ - "podA": testPodInfo("podA", "nsAB", "10.1.1.1", map[string]string{"app": "appA"}), - "podB": testPodInfo("podB", "nsAB", "10.1.1.2", map[string]string{"app": "appB"}), - "podC": testPodInfo("podC", "nsC", "10.1.1.3", map[string]string{"app": "appC", "func": "web"}), + pl := &podsLister{ + cache: make(map[resourceKey]*podInfo), + } + for _, pi := range []*podInfo{ + testPodInfo("podA", "nsAB", "10.1.1.1", map[string]string{"app": "appA"}), + testPodInfo("podB", "nsAB", "10.1.1.2", map[string]string{"app": "appB"}), + testPodInfo("podC", "nsC", "10.1.1.3", map[string]string{"app": "appC", "func": "web"}), + testPodInfo("podC", "devC", "10.2.1.3", map[string]string{"app": "appC", "func": "web"}), + } { + key := resourceKey{pi.Metadata.Namespace, pi.Metadata.Name} + pl.keys = append(pl.keys, key) + pl.cache[key] = pi } tests := []struct { @@ -43,7 +50,7 @@ func TestListResources(t *testing.T) { nameFilter string filters map[string]string labelsFilter map[string]string - wantPods []string + wantPods []resourceKey wantErr bool }{ { @@ -54,17 +61,22 @@ func TestListResources(t *testing.T) { { desc: "only name filter for podB and podC", filters: map[string]string{"name": "pod(B|C)"}, - wantPods: []string{"podB", "podC"}, + wantPods: []resourceKey{{"nsAB", "podB"}, {"nsC", "podC"}, {"devC", "podC"}}, + }, + { + desc: "name filter for podB and podC, and namespace filter", + filters: map[string]string{"name": "pod(B|C)", "namespace": "ns.*"}, + wantPods: []resourceKey{{"nsAB", "podB"}, {"nsC", "podC"}}, }, { desc: "name and namespace filter for podB", filters: map[string]string{"name": "pod(B|C)", "namespace": "nsAB"}, - wantPods: []string{"podB"}, + wantPods: []resourceKey{{"nsAB", "podB"}}, }, { desc: "only namespace filter for podA and podB", filters: map[string]string{"namespace": "nsAB"}, - wantPods: []string{"podA", "podB"}, + wantPods: []resourceKey{{"nsAB", "podA"}, {"nsAB", "podB"}}, }, } @@ -83,13 +95,13 @@ func TestListResources(t *testing.T) { return } - var gotNames []string + var gotPods []resourceKey for _, res := range results { - gotNames = append(gotNames, res.GetName()) + gotPods = append(gotPods, resourceKey{res.GetLabels()["namespace"], res.GetName()}) } - if !reflect.DeepEqual(gotNames, test.wantPods) { - t.Errorf("pods.listResources: got=%v, expected=%v", gotNames, test.wantPods) + if !reflect.DeepEqual(gotPods, test.wantPods) { + t.Errorf("pods.listResources: got=%v, expected=%v", gotPods, test.wantPods) } }) } @@ -102,28 +114,31 @@ func TestParseResourceList(t *testing.T) { if err != nil { t.Fatalf("error reading test data file: %s", podsListFile) } - _, podsByName, err := parsePodsJSON(data) + _, podsByKey, err := parsePodsJSON(data) if err != nil { t.Fatalf("Error while parsing pods JSON data: %v", err) } - cpPod := "cloudprober-54778d95f5-7hqtd" - if podsByName[cpPod] == nil { - t.Errorf("didn't get pod by the name: %s", cpPod) + for _, ns := range []string{"prod", "dev"} { + cpPodKey := resourceKey{ns, "cloudprober-54778d95f5-7hqtd"} + if podsByKey[cpPodKey] == nil { + t.Errorf("didn't get pod by the key: %+v", cpPodKey) + continue + } + + if podsByKey[cpPodKey].Metadata.Labels["app"] != "cloudprober" { + t.Errorf("cloudprober pod app label: got=%s, want=cloudprober", podsByKey[cpPodKey].Metadata.Labels["app"]) + } + + cpPodIP := "10.28.0.3" + if podsByKey[cpPodKey].Status.PodIP != cpPodIP { + t.Errorf("cloudprober pod ip: got=%s, want=%s", podsByKey[cpPodKey].Status.PodIP, cpPodIP) + } } - // Verify that we got the pending pod. - if podsByName["test"] != nil { + // Verify that we didn't the pending pod. + if podsByKey[resourceKey{"default", "test"}] != nil { t.Error("got a non-running pod in the list: test") } - - if podsByName[cpPod].Metadata.Labels["app"] != "cloudprober" { - t.Errorf("cloudprober pod app label: got=%s, want=cloudprober", podsByName[cpPod].Metadata.Labels["app"]) - } - - cpPodIP := "10.28.0.3" - if podsByName[cpPod].Status.PodIP != cpPodIP { - t.Errorf("cloudprober pod ip: got=%s, want=%s", podsByName[cpPod].Status.PodIP, cpPodIP) - } } diff --git a/rds/kubernetes/services.go b/rds/kubernetes/services.go index 58c15a3f..156188a7 100644 --- a/rds/kubernetes/services.go +++ b/rds/kubernetes/services.go @@ -36,8 +36,8 @@ type servicesLister struct { kClient *client mu sync.RWMutex // Mutex for names and cache - names []string - cache map[string]*serviceInfo + keys []resourceKey + cache map[resourceKey]*serviceInfo l *logger.Logger } @@ -67,16 +67,16 @@ func (lister *servicesLister) listResources(req *pb.ListResourcesRequest) ([]*pb lister.mu.RLock() defer lister.mu.RUnlock() - for _, name := range lister.names { - if svcName != "" && name != svcName { + for _, key := range lister.keys { + if svcName != "" && key.name != svcName { continue } - if nameFilter != nil && !nameFilter.Match(name, lister.l) { + if nameFilter != nil && !nameFilter.Match(key.name, lister.l) { continue } - svc := lister.cache[name] + svc := lister.cache[key] if nsFilter != nil && !nsFilter.Match(svc.Metadata.Namespace, lister.l) { continue } @@ -170,7 +170,7 @@ func (si *serviceInfo) resources(portFilter *filter.RegexFilter, reqIPType pb.IP return } -func parseServicesJSON(resp []byte) (names []string, services map[string]*serviceInfo, err error) { +func parseServicesJSON(resp []byte) (keys []resourceKey, services map[resourceKey]*serviceInfo, err error) { var itemList struct { Items []*serviceInfo } @@ -179,11 +179,11 @@ func parseServicesJSON(resp []byte) (names []string, services map[string]*servic return } - names = make([]string, len(itemList.Items)) - services = make(map[string]*serviceInfo) + keys = make([]resourceKey, len(itemList.Items)) + services = make(map[resourceKey]*serviceInfo) for i, item := range itemList.Items { - names[i] = item.Metadata.Name - services[item.Metadata.Name] = item + keys[i] = resourceKey{item.Metadata.Namespace, item.Metadata.Name} + services[keys[i]] = item } return @@ -195,16 +195,16 @@ func (lister *servicesLister) expand() { lister.l.Warningf("servicesLister.expand(): error while getting services list from API: %v", err) } - names, services, err := parseServicesJSON(resp) + keys, services, err := parseServicesJSON(resp) if err != nil { lister.l.Warningf("servicesLister.expand(): error while parsing services API response (%s): %v", string(resp), err) } - lister.l.Infof("servicesLister.expand(): got %d services", len(names)) + lister.l.Infof("servicesLister.expand(): got %d services", len(keys)) lister.mu.Lock() defer lister.mu.Unlock() - lister.names = names + lister.keys = keys lister.cache = services } diff --git a/rds/kubernetes/services_test.go b/rds/kubernetes/services_test.go index 3f36aec9..b4f2a438 100644 --- a/rds/kubernetes/services_test.go +++ b/rds/kubernetes/services_test.go @@ -49,13 +49,19 @@ func testServiceInfo(name, ns, ip, publicIP, hostname string, labels map[string] } func TestListSvcResources(t *testing.T) { - sl := &servicesLister{} - sl.names = []string{"serviceA", "serviceB", "serviceC", "serviceD"} - sl.cache = map[string]*serviceInfo{ - "serviceA": testServiceInfo("serviceA", "nsAB", "10.1.1.1", "", "", map[string]string{"app": "appA"}, []int{9313, 9314}), - "serviceB": testServiceInfo("serviceB", "nsAB", "10.1.1.2", "192.16.16.199", "", map[string]string{"app": "appB"}, []int{443}), - "serviceC": testServiceInfo("serviceC", "nsC", "10.1.1.3", "192.16.16.200", "serviceC.test.com", map[string]string{"app": "appC", "func": "web"}, []int{3141}), - "serviceD": testServiceInfo("serviceD", "nsD", "10.1.1.4", "", "serviceD.test.com", map[string]string{"app": "appD", "func": "web"}, []int{3141}), + sl := &servicesLister{ + cache: make(map[resourceKey]*serviceInfo), + } + for _, svc := range []*serviceInfo{ + testServiceInfo("serviceA", "nsAB", "10.1.1.1", "", "", map[string]string{"app": "appA"}, []int{9313, 9314}), + testServiceInfo("serviceB", "nsAB", "10.1.1.2", "192.16.16.199", "", map[string]string{"app": "appB"}, []int{443}), + testServiceInfo("serviceC", "nsC", "10.1.1.3", "192.16.16.200", "serviceC.test.com", map[string]string{"app": "appC", "func": "web"}, []int{3141}), + testServiceInfo("serviceD", "nsD", "10.1.1.4", "", "serviceD.test.com", map[string]string{"app": "appD", "func": "web"}, []int{3141}), + testServiceInfo("serviceD", "devD", "10.2.1.4", "", "", map[string]string{"app": "appD", "func": "web"}, []int{3141}), + } { + rkey := resourceKey{svc.Metadata.Namespace, svc.Metadata.Name} + sl.keys = append(sl.keys, rkey) + sl.cache[rkey] = svc } tests := []struct { @@ -83,7 +89,7 @@ func TestListSvcResources(t *testing.T) { }, { desc: "only port filter for ports 9314 and 3141", - filters: map[string]string{"port": "314"}, + filters: map[string]string{"port": "314", "namespace": "ns.*"}, wantServices: []string{"serviceA", "serviceC", "serviceD"}, wantIPs: []string{"10.1.1.1", "10.1.1.3", "10.1.1.4"}, wantPorts: []int32{9314, 3141, 3141}, @@ -108,6 +114,13 @@ func TestListSvcResources(t *testing.T) { wantPublicIPs: []string{"192.16.16.199", "192.16.16.200", "serviceD.test.com"}, wantPorts: []int32{443, 3141, 3141}, }, + { + desc: "only dev namespace", + filters: map[string]string{"namespace": "dev.*"}, + wantServices: []string{"serviceD"}, + wantIPs: []string{"10.2.1.4"}, + wantPorts: []int32{3141}, + }, } for _, test := range tests { @@ -168,63 +181,69 @@ func TestParseSvcResourceList(t *testing.T) { if err != nil { t.Fatalf("error reading test data file: %s", servicesListFile) } - _, servicesByName, err := parseServicesJSON(data) + _, services, err := parseServicesJSON(data) if err != nil { t.Fatalf("Error while parsing services JSON data: %v", err) } - services := map[string]struct { - ip string - publicIP string - ports []int - labels map[string]string + expectedSvcs := map[string]struct { + namespace string + ip string + publicIP string + ports []int + labels map[string]string }{ "cloudprober": { - ip: "10.31.252.209", - ports: []int{9313}, - labels: map[string]string{"app": "cloudprober"}, + namespace: "default", + ip: "10.31.252.209", + ports: []int{9313}, + labels: map[string]string{"app": "cloudprober"}, }, "cloudprober-rds": { - ip: "10.96.15.88", - publicIP: "192.88.99.199", - ports: []int{9314, 9313}, - labels: map[string]string{"app": "cloudprober"}, + namespace: "default", + ip: "10.96.15.88", + publicIP: "192.88.99.199", + ports: []int{9314, 9313}, + labels: map[string]string{"app": "cloudprober"}, }, "cloudprober-test": { - ip: "10.31.246.77", - ports: []int{9313}, - labels: map[string]string{"app": "cloudprober"}, + namespace: "default", + ip: "10.31.246.77", + ports: []int{9313}, + labels: map[string]string{"app": "cloudprober"}, }, "kubernetes": { - ip: "10.31.240.1", - ports: []int{443}, - labels: map[string]string{"component": "apiserver", "provider": "kubernetes"}, + namespace: "system", + ip: "10.31.240.1", + ports: []int{443}, + labels: map[string]string{"component": "apiserver", "provider": "kubernetes"}, }, } - for name, svc := range services { - if servicesByName[name] == nil { + for name, svc := range expectedSvcs { + rkey := resourceKey{svc.namespace, name} + if services[rkey] == nil { t.Errorf("didn't get service by the name: %s", name) } - gotLabels := servicesByName[name].Metadata.Labels + gotLabels := services[rkey].Metadata.Labels if !reflect.DeepEqual(gotLabels, svc.labels) { t.Errorf("%s service labels: got=%v, want=%v", name, gotLabels, svc.labels) } - if servicesByName[name].Spec.ClusterIP != svc.ip { - t.Errorf("%s service ip: got=%s, want=%s", name, servicesByName[name].Spec.ClusterIP, svc.ip) + if services[rkey].Spec.ClusterIP != svc.ip { + t.Errorf("%s service ip: got=%s, want=%s", name, services[rkey].Spec.ClusterIP, svc.ip) } if svc.publicIP != "" { - if servicesByName[name].Status.LoadBalancer.Ingress[0].IP != svc.publicIP { - t.Errorf("%s service load balancer ip: got=%s, want=%s", name, servicesByName[name].Status.LoadBalancer.Ingress[0].IP, svc.publicIP) + if services[rkey].Status.LoadBalancer.Ingress[0].IP != svc.publicIP { + t.Errorf("%s service load balancer ip: got=%s, want=%s", name, services[rkey].Status.LoadBalancer.Ingress[0].IP, svc.publicIP) } } var gotPorts []int - for _, port := range servicesByName[name].Spec.Ports { + for _, port := range services[rkey].Spec.Ports { gotPorts = append(gotPorts, port.Port) } if !reflect.DeepEqual(gotPorts, svc.ports) { diff --git a/rds/kubernetes/testdata/endpoints.json b/rds/kubernetes/testdata/endpoints.json index 7356b4e5..dda706e5 100644 --- a/rds/kubernetes/testdata/endpoints.json +++ b/rds/kubernetes/testdata/endpoints.json @@ -125,7 +125,7 @@ { "metadata": { "name": "kubernetes", - "namespace": "default", + "namespace": "system", "selfLink": "/api/v1/namespaces/default/endpoints/kubernetes", "uid": "ae471cff-9b4f-11e8-a95e-42010a8a0ff8", "resourceVersion": "32", diff --git a/rds/kubernetes/testdata/pods.json b/rds/kubernetes/testdata/pods.json index d15c3757..d6bd370f 100644 --- a/rds/kubernetes/testdata/pods.json +++ b/rds/kubernetes/testdata/pods.json @@ -10,8 +10,174 @@ "metadata": { "name": "cloudprober-54778d95f5-7hqtd", "generateName": "cloudprober-54778d95f5-", - "namespace": "default", - "selfLink": "/api/v1/namespaces/default/pods/cloudprober-54778d95f5-7hqtd", + "namespace": "prod", + "selfLink": "/api/v1/namespaces/prod/pods/cloudprober-54778d95f5-7hqtd", + "uid": "27b40427-be52-11e9-b3cb-42010a8a0172", + "resourceVersion": "60211894", + "creationTimestamp": "2019-08-14T05:12:47Z", + "labels": { + "app": "cloudprober", + "pod-template-hash": "1033485191" + }, + "annotations": { + "kubernetes.io/limit-ranger": "LimitRanger plugin set: cpu request for container cloudprober" + }, + "ownerReferences": [ + { + "apiVersion": "apps/v1", + "kind": "ReplicaSet", + "name": "cloudprober-54778d95f5", + "uid": "4d8dea4f-d753-11e8-ade0-42010a8a00bc", + "controller": true, + "blockOwnerDeletion": true + } + ] + }, + "spec": { + "volumes": [ + { + "name": "cloudprober-config", + "configMap": { + "name": "cloudprober-config", + "defaultMode": 420 + } + }, + { + "name": "default-token-fpbjc", + "secret": { + "secretName": "default-token-fpbjc", + "defaultMode": 420 + } + } + ], + "containers": [ + { + "name": "cloudprober", + "image": "cloudprober/cloudprober", + "args": [ + "--config_file", + "/cfg/cloudprober.cfg", + "--logtostderr" + ], + "ports": [ + { + "name": "http", + "containerPort": 9313, + "protocol": "TCP" + } + ], + "env": [ + { + "name": "CLOUDPROBER_PORT", + "value": "9313" + } + ], + "resources": { + "requests": { + "cpu": "100m" + } + }, + "volumeMounts": [ + { + "name": "cloudprober-config", + "mountPath": "/cfg" + }, + { + "name": "default-token-fpbjc", + "readOnly": true, + "mountPath": "/var/run/secrets/kubernetes.io/serviceaccount" + } + ], + "terminationMessagePath": "/dev/termination-log", + "terminationMessagePolicy": "File", + "imagePullPolicy": "Always" + } + ], + "restartPolicy": "Always", + "terminationGracePeriodSeconds": 30, + "dnsPolicy": "ClusterFirst", + "serviceAccountName": "default", + "serviceAccount": "default", + "nodeName": "gke-cluster-1-default-pool-abd8ad35-ccr7", + "securityContext": { + + }, + "schedulerName": "default-scheduler", + "tolerations": [ + { + "key": "node.kubernetes.io/not-ready", + "operator": "Exists", + "effect": "NoExecute", + "tolerationSeconds": 300 + }, + { + "key": "node.kubernetes.io/unreachable", + "operator": "Exists", + "effect": "NoExecute", + "tolerationSeconds": 300 + } + ], + "priority": 0, + "enableServiceLinks": true + }, + "status": { + "phase": "Running", + "conditions": [ + { + "type": "Initialized", + "status": "True", + "lastProbeTime": null, + "lastTransitionTime": "2019-08-14T05:12:47Z" + }, + { + "type": "Ready", + "status": "True", + "lastProbeTime": null, + "lastTransitionTime": "2019-08-14T05:13:08Z" + }, + { + "type": "ContainersReady", + "status": "True", + "lastProbeTime": null, + "lastTransitionTime": null + }, + { + "type": "PodScheduled", + "status": "True", + "lastProbeTime": null, + "lastTransitionTime": "2019-08-14T05:12:47Z" + } + ], + "hostIP": "10.138.0.5", + "podIP": "10.28.0.3", + "startTime": "2019-08-14T05:12:47Z", + "containerStatuses": [ + { + "name": "cloudprober", + "state": { + "running": { + "startedAt": "2019-08-14T05:13:06Z" + } + }, + "lastState": { + + }, + "ready": true, + "restartCount": 0, + "image": "cloudprober/cloudprober:latest", + "imageID": "docker-pullable://cloudprober/cloudprober@sha256:e6efb4057a41e8bb187508b68256df402d0c67b60ad6dfdfbce26a128d501efc", + "containerID": "docker://1dc2faec2892d334821fac4a1c460272114353154c239d2dd225d408fe100d62" + } + ], + "qosClass": "Burstable" + } + }, + { + "metadata": { + "name": "cloudprober-54778d95f5-7hqtd", + "generateName": "cloudprober-54778d95f5-", + "namespace": "dev", + "selfLink": "/api/v1/namespaces/dev/pods/cloudprober-54778d95f5-7hqtd", "uid": "27b40427-be52-11e9-b3cb-42010a8a0172", "resourceVersion": "60211894", "creationTimestamp": "2019-08-14T05:12:47Z", diff --git a/rds/kubernetes/testdata/services.json b/rds/kubernetes/testdata/services.json index 175411aa..b8fdb6be 100644 --- a/rds/kubernetes/testdata/services.json +++ b/rds/kubernetes/testdata/services.json @@ -136,7 +136,7 @@ { "metadata": { "name": "kubernetes", - "namespace": "default", + "namespace": "system", "selfLink": "/api/v1/namespaces/default/services/kubernetes", "uid": "ae448b87-9b4f-11e8-a95e-42010a8a0ff8", "resourceVersion": "30",