diff --git a/cli/cmd/testdata/inject-filepath/expected/injected_nginx.yaml b/cli/cmd/testdata/inject-filepath/expected/injected_nginx.yaml index 6bceffcb10fce..57dc32cd39519 100644 --- a/cli/cmd/testdata/inject-filepath/expected/injected_nginx.yaml +++ b/cli/cmd/testdata/inject-filepath/expected/injected_nginx.yaml @@ -16,6 +16,9 @@ spec: app: nginx linkerd.io/control-plane-ns: linkerd linkerd.io/proxy-deployment: nginx + linkerd.io/proxy-root-parent: nginx + linkerd.io/proxy-root-parent-group: apps + linkerd.io/proxy-root-parent-kind: Deployment linkerd.io/workload-ns: "" spec: containers: diff --git a/cli/cmd/testdata/inject-filepath/expected/injected_nginx_redis.yaml b/cli/cmd/testdata/inject-filepath/expected/injected_nginx_redis.yaml index 290ccba07a5bf..350052e61ae20 100644 --- a/cli/cmd/testdata/inject-filepath/expected/injected_nginx_redis.yaml +++ b/cli/cmd/testdata/inject-filepath/expected/injected_nginx_redis.yaml @@ -16,6 +16,9 @@ spec: app: redis linkerd.io/control-plane-ns: linkerd linkerd.io/proxy-deployment: redis + linkerd.io/proxy-root-parent: redis + linkerd.io/proxy-root-parent-group: apps + linkerd.io/proxy-root-parent-kind: Deployment linkerd.io/workload-ns: "" spec: containers: @@ -270,6 +273,9 @@ spec: app: nginx linkerd.io/control-plane-ns: linkerd linkerd.io/proxy-deployment: nginx + linkerd.io/proxy-root-parent: nginx + linkerd.io/proxy-root-parent-group: apps + linkerd.io/proxy-root-parent-kind: Deployment linkerd.io/workload-ns: "" spec: containers: diff --git a/cli/cmd/testdata/inject-filepath/expected/injected_redis.yaml b/cli/cmd/testdata/inject-filepath/expected/injected_redis.yaml index 999344afac1be..b0268371a937c 100644 --- a/cli/cmd/testdata/inject-filepath/expected/injected_redis.yaml +++ b/cli/cmd/testdata/inject-filepath/expected/injected_redis.yaml @@ -16,6 +16,9 @@ spec: app: redis linkerd.io/control-plane-ns: linkerd linkerd.io/proxy-deployment: redis + linkerd.io/proxy-root-parent: redis + linkerd.io/proxy-root-parent-group: apps + linkerd.io/proxy-root-parent-kind: Deployment linkerd.io/workload-ns: "" spec: containers: diff --git a/cli/cmd/testdata/inject_contour.golden.yml b/cli/cmd/testdata/inject_contour.golden.yml index 4ff12a5c2cc85..7d5467babe156 100644 --- a/cli/cmd/testdata/inject_contour.golden.yml +++ b/cli/cmd/testdata/inject_contour.golden.yml @@ -24,6 +24,9 @@ spec: app: contour linkerd.io/control-plane-ns: linkerd linkerd.io/proxy-deployment: contour + linkerd.io/proxy-root-parent: contour + linkerd.io/proxy-root-parent-group: apps + linkerd.io/proxy-root-parent-kind: Deployment linkerd.io/workload-ns: heptio-contour spec: containers: diff --git a/cli/cmd/testdata/inject_emojivoto_already_injected.golden.yml b/cli/cmd/testdata/inject_emojivoto_already_injected.golden.yml index e01f63fd622d6..0b6d1d08750a5 100644 --- a/cli/cmd/testdata/inject_emojivoto_already_injected.golden.yml +++ b/cli/cmd/testdata/inject_emojivoto_already_injected.golden.yml @@ -18,6 +18,9 @@ spec: app: web-svc linkerd.io/control-plane-ns: linkerd linkerd.io/proxy-deployment: web1 + linkerd.io/proxy-root-parent: web1 + linkerd.io/proxy-root-parent-group: apps + linkerd.io/proxy-root-parent-kind: Deployment linkerd.io/workload-ns: emojivoto spec: containers: @@ -283,6 +286,9 @@ spec: app: web-svc linkerd.io/control-plane-ns: linkerd linkerd.io/proxy-deployment: web2 + linkerd.io/proxy-root-parent: web2 + linkerd.io/proxy-root-parent-group: apps + linkerd.io/proxy-root-parent-kind: Deployment linkerd.io/workload-ns: emojivoto spec: containers: @@ -548,6 +554,9 @@ spec: app: web-svc linkerd.io/control-plane-ns: linkerd linkerd.io/proxy-deployment: web3 + linkerd.io/proxy-root-parent: web3 + linkerd.io/proxy-root-parent-group: apps + linkerd.io/proxy-root-parent-kind: Deployment linkerd.io/workload-ns: emojivoto spec: containers: @@ -813,6 +822,9 @@ spec: app: web-svc linkerd.io/control-plane-ns: linkerd linkerd.io/proxy-deployment: web4 + linkerd.io/proxy-root-parent: web4 + linkerd.io/proxy-root-parent-group: apps + linkerd.io/proxy-root-parent-kind: Deployment linkerd.io/workload-ns: emojivoto spec: containers: diff --git a/cli/cmd/testdata/inject_emojivoto_deployment.golden.yml b/cli/cmd/testdata/inject_emojivoto_deployment.golden.yml index 21c327d526a5c..143a410054f9a 100644 --- a/cli/cmd/testdata/inject_emojivoto_deployment.golden.yml +++ b/cli/cmd/testdata/inject_emojivoto_deployment.golden.yml @@ -18,6 +18,9 @@ spec: app: web-svc linkerd.io/control-plane-ns: linkerd linkerd.io/proxy-deployment: web + linkerd.io/proxy-root-parent: web + linkerd.io/proxy-root-parent-group: apps + linkerd.io/proxy-root-parent-kind: Deployment linkerd.io/workload-ns: emojivoto spec: containers: diff --git a/cli/cmd/testdata/inject_emojivoto_deployment_access_log.golden.yml b/cli/cmd/testdata/inject_emojivoto_deployment_access_log.golden.yml index 6830f136a28d6..81e1dc7276b2d 100644 --- a/cli/cmd/testdata/inject_emojivoto_deployment_access_log.golden.yml +++ b/cli/cmd/testdata/inject_emojivoto_deployment_access_log.golden.yml @@ -19,6 +19,9 @@ spec: app: web-svc linkerd.io/control-plane-ns: linkerd linkerd.io/proxy-deployment: web + linkerd.io/proxy-root-parent: web + linkerd.io/proxy-root-parent-group: apps + linkerd.io/proxy-root-parent-kind: Deployment linkerd.io/workload-ns: emojivoto spec: containers: diff --git a/cli/cmd/testdata/inject_emojivoto_deployment_automountServiceAccountToken_false.golden.yml b/cli/cmd/testdata/inject_emojivoto_deployment_automountServiceAccountToken_false.golden.yml index a362a4959f6e9..5447c9ef6d3c8 100644 --- a/cli/cmd/testdata/inject_emojivoto_deployment_automountServiceAccountToken_false.golden.yml +++ b/cli/cmd/testdata/inject_emojivoto_deployment_automountServiceAccountToken_false.golden.yml @@ -18,6 +18,9 @@ spec: app: nginx linkerd.io/control-plane-ns: linkerd linkerd.io/proxy-deployment: nginx + linkerd.io/proxy-root-parent: nginx + linkerd.io/proxy-root-parent-group: apps + linkerd.io/proxy-root-parent-kind: Deployment linkerd.io/workload-ns: "" spec: automountServiceAccountToken: false diff --git a/cli/cmd/testdata/inject_emojivoto_deployment_capabilities.golden.yml b/cli/cmd/testdata/inject_emojivoto_deployment_capabilities.golden.yml index 706ae5216c18c..af25024d6268d 100644 --- a/cli/cmd/testdata/inject_emojivoto_deployment_capabilities.golden.yml +++ b/cli/cmd/testdata/inject_emojivoto_deployment_capabilities.golden.yml @@ -18,6 +18,9 @@ spec: app: web-svc linkerd.io/control-plane-ns: linkerd linkerd.io/proxy-deployment: web + linkerd.io/proxy-root-parent: web + linkerd.io/proxy-root-parent-group: apps + linkerd.io/proxy-root-parent-kind: Deployment linkerd.io/workload-ns: emojivoto spec: containers: diff --git a/cli/cmd/testdata/inject_emojivoto_deployment_config_overrides.golden.yml b/cli/cmd/testdata/inject_emojivoto_deployment_config_overrides.golden.yml index 648fdd2328543..99834ebc9fcd3 100644 --- a/cli/cmd/testdata/inject_emojivoto_deployment_config_overrides.golden.yml +++ b/cli/cmd/testdata/inject_emojivoto_deployment_config_overrides.golden.yml @@ -26,6 +26,9 @@ spec: app: web-svc linkerd.io/control-plane-ns: linkerd linkerd.io/proxy-deployment: web + linkerd.io/proxy-root-parent: web + linkerd.io/proxy-root-parent-group: apps + linkerd.io/proxy-root-parent-kind: Deployment linkerd.io/workload-ns: emojivoto spec: containers: diff --git a/cli/cmd/testdata/inject_emojivoto_deployment_controller_name.golden.yml b/cli/cmd/testdata/inject_emojivoto_deployment_controller_name.golden.yml index b4dbfd4b6547c..360ed266cc315 100644 --- a/cli/cmd/testdata/inject_emojivoto_deployment_controller_name.golden.yml +++ b/cli/cmd/testdata/inject_emojivoto_deployment_controller_name.golden.yml @@ -18,6 +18,9 @@ spec: app: web-svc linkerd.io/control-plane-ns: linkerd linkerd.io/proxy-deployment: controller + linkerd.io/proxy-root-parent: controller + linkerd.io/proxy-root-parent-group: apps + linkerd.io/proxy-root-parent-kind: Deployment linkerd.io/workload-ns: emojivoto spec: containers: @@ -283,6 +286,9 @@ spec: app: web-svc linkerd.io/control-plane-ns: linkerd linkerd.io/proxy-deployment: not-controller + linkerd.io/proxy-root-parent: not-controller + linkerd.io/proxy-root-parent-group: apps + linkerd.io/proxy-root-parent-kind: Deployment linkerd.io/workload-ns: linkerd spec: containers: diff --git a/cli/cmd/testdata/inject_emojivoto_deployment_debug.golden.yml b/cli/cmd/testdata/inject_emojivoto_deployment_debug.golden.yml index d6c89899e5a9d..0144a6eb85339 100644 --- a/cli/cmd/testdata/inject_emojivoto_deployment_debug.golden.yml +++ b/cli/cmd/testdata/inject_emojivoto_deployment_debug.golden.yml @@ -19,6 +19,9 @@ spec: app: web-svc linkerd.io/control-plane-ns: linkerd linkerd.io/proxy-deployment: web + linkerd.io/proxy-root-parent: web + linkerd.io/proxy-root-parent-group: apps + linkerd.io/proxy-root-parent-kind: Deployment linkerd.io/workload-ns: emojivoto spec: containers: diff --git a/cli/cmd/testdata/inject_emojivoto_deployment_empty_resources.golden.yml b/cli/cmd/testdata/inject_emojivoto_deployment_empty_resources.golden.yml index 4569a5d976c5c..06c798249af32 100644 --- a/cli/cmd/testdata/inject_emojivoto_deployment_empty_resources.golden.yml +++ b/cli/cmd/testdata/inject_emojivoto_deployment_empty_resources.golden.yml @@ -18,6 +18,9 @@ spec: app: web-svc linkerd.io/control-plane-ns: linkerd linkerd.io/proxy-deployment: web + linkerd.io/proxy-root-parent: web + linkerd.io/proxy-root-parent-group: apps + linkerd.io/proxy-root-parent-kind: Deployment linkerd.io/workload-ns: emojivoto spec: containers: diff --git a/cli/cmd/testdata/inject_emojivoto_deployment_hostNetwork_false.golden.yml b/cli/cmd/testdata/inject_emojivoto_deployment_hostNetwork_false.golden.yml index bab24f11599df..5f9a74e40e165 100644 --- a/cli/cmd/testdata/inject_emojivoto_deployment_hostNetwork_false.golden.yml +++ b/cli/cmd/testdata/inject_emojivoto_deployment_hostNetwork_false.golden.yml @@ -18,6 +18,9 @@ spec: app: web-svc linkerd.io/control-plane-ns: linkerd linkerd.io/proxy-deployment: web + linkerd.io/proxy-root-parent: web + linkerd.io/proxy-root-parent-group: apps + linkerd.io/proxy-root-parent-kind: Deployment linkerd.io/workload-ns: emojivoto spec: containers: diff --git a/cli/cmd/testdata/inject_emojivoto_deployment_native_sidecar.golden.yml b/cli/cmd/testdata/inject_emojivoto_deployment_native_sidecar.golden.yml index 8e916e7cc17aa..368958f76b136 100644 --- a/cli/cmd/testdata/inject_emojivoto_deployment_native_sidecar.golden.yml +++ b/cli/cmd/testdata/inject_emojivoto_deployment_native_sidecar.golden.yml @@ -19,6 +19,9 @@ spec: app: web-svc linkerd.io/control-plane-ns: linkerd linkerd.io/proxy-deployment: web + linkerd.io/proxy-root-parent: web + linkerd.io/proxy-root-parent-group: apps + linkerd.io/proxy-root-parent-kind: Deployment linkerd.io/workload-ns: emojivoto spec: containers: diff --git a/cli/cmd/testdata/inject_emojivoto_deployment_no_init_container.golden.yml b/cli/cmd/testdata/inject_emojivoto_deployment_no_init_container.golden.yml index 20e76b01ad83e..3ede5a707185f 100644 --- a/cli/cmd/testdata/inject_emojivoto_deployment_no_init_container.golden.yml +++ b/cli/cmd/testdata/inject_emojivoto_deployment_no_init_container.golden.yml @@ -18,6 +18,9 @@ spec: app: web-svc linkerd.io/control-plane-ns: linkerd linkerd.io/proxy-deployment: web + linkerd.io/proxy-root-parent: web + linkerd.io/proxy-root-parent-group: apps + linkerd.io/proxy-root-parent-kind: Deployment linkerd.io/workload-ns: emojivoto spec: containers: diff --git a/cli/cmd/testdata/inject_emojivoto_deployment_opaque_ports.golden.yml b/cli/cmd/testdata/inject_emojivoto_deployment_opaque_ports.golden.yml index a3575f103166f..5b2e7f5efa7cf 100644 --- a/cli/cmd/testdata/inject_emojivoto_deployment_opaque_ports.golden.yml +++ b/cli/cmd/testdata/inject_emojivoto_deployment_opaque_ports.golden.yml @@ -19,6 +19,9 @@ spec: app: web-svc linkerd.io/control-plane-ns: linkerd linkerd.io/proxy-deployment: web + linkerd.io/proxy-root-parent: web + linkerd.io/proxy-root-parent-group: apps + linkerd.io/proxy-root-parent-kind: Deployment linkerd.io/workload-ns: emojivoto spec: containers: diff --git a/cli/cmd/testdata/inject_emojivoto_deployment_overridden.golden.yml b/cli/cmd/testdata/inject_emojivoto_deployment_overridden.golden.yml index 88a233384e85d..3162f9680dbe0 100644 --- a/cli/cmd/testdata/inject_emojivoto_deployment_overridden.golden.yml +++ b/cli/cmd/testdata/inject_emojivoto_deployment_overridden.golden.yml @@ -19,6 +19,9 @@ spec: app: web-svc linkerd.io/control-plane-ns: linkerd linkerd.io/proxy-deployment: web + linkerd.io/proxy-root-parent: web + linkerd.io/proxy-root-parent-group: apps + linkerd.io/proxy-root-parent-kind: Deployment linkerd.io/workload-ns: emojivoto spec: containers: diff --git a/cli/cmd/testdata/inject_emojivoto_deployment_params.golden.yml b/cli/cmd/testdata/inject_emojivoto_deployment_params.golden.yml index 09402789f2cf2..787f598306a0f 100644 --- a/cli/cmd/testdata/inject_emojivoto_deployment_params.golden.yml +++ b/cli/cmd/testdata/inject_emojivoto_deployment_params.golden.yml @@ -18,6 +18,9 @@ spec: app: web-svc linkerd.io/control-plane-ns: linkerd linkerd.io/proxy-deployment: web + linkerd.io/proxy-root-parent: web + linkerd.io/proxy-root-parent-group: apps + linkerd.io/proxy-root-parent-kind: Deployment linkerd.io/workload-ns: emojivoto spec: containers: diff --git a/cli/cmd/testdata/inject_emojivoto_deployment_proxyignores.golden.yml b/cli/cmd/testdata/inject_emojivoto_deployment_proxyignores.golden.yml index a2c8926de43be..531e8623e98bf 100644 --- a/cli/cmd/testdata/inject_emojivoto_deployment_proxyignores.golden.yml +++ b/cli/cmd/testdata/inject_emojivoto_deployment_proxyignores.golden.yml @@ -20,6 +20,9 @@ spec: app: web-svc linkerd.io/control-plane-ns: linkerd linkerd.io/proxy-deployment: web + linkerd.io/proxy-root-parent: web + linkerd.io/proxy-root-parent-group: apps + linkerd.io/proxy-root-parent-kind: Deployment linkerd.io/workload-ns: emojivoto spec: containers: diff --git a/cli/cmd/testdata/inject_emojivoto_deployment_udp.golden.yml b/cli/cmd/testdata/inject_emojivoto_deployment_udp.golden.yml index 10fba99879809..c461f927c8833 100644 --- a/cli/cmd/testdata/inject_emojivoto_deployment_udp.golden.yml +++ b/cli/cmd/testdata/inject_emojivoto_deployment_udp.golden.yml @@ -18,6 +18,9 @@ spec: app: web-svc linkerd.io/control-plane-ns: linkerd linkerd.io/proxy-deployment: web + linkerd.io/proxy-root-parent: web + linkerd.io/proxy-root-parent-group: apps + linkerd.io/proxy-root-parent-kind: Deployment linkerd.io/workload-ns: emojivoto spec: containers: diff --git a/cli/cmd/testdata/inject_emojivoto_list.golden.yml b/cli/cmd/testdata/inject_emojivoto_list.golden.yml index 7c9d34b962299..b7a07e8b53d8a 100644 --- a/cli/cmd/testdata/inject_emojivoto_list.golden.yml +++ b/cli/cmd/testdata/inject_emojivoto_list.golden.yml @@ -20,6 +20,9 @@ items: app: web-svc linkerd.io/control-plane-ns: linkerd linkerd.io/proxy-deployment: web + linkerd.io/proxy-root-parent: web + linkerd.io/proxy-root-parent-group: apps + linkerd.io/proxy-root-parent-kind: Deployment linkerd.io/workload-ns: emojivoto spec: containers: @@ -284,6 +287,9 @@ items: app: emoji-svc linkerd.io/control-plane-ns: linkerd linkerd.io/proxy-deployment: emoji + linkerd.io/proxy-root-parent: emoji + linkerd.io/proxy-root-parent-group: apps + linkerd.io/proxy-root-parent-kind: Deployment linkerd.io/workload-ns: emojivoto spec: containers: diff --git a/cli/cmd/testdata/inject_emojivoto_list_empty_resources.golden.yml b/cli/cmd/testdata/inject_emojivoto_list_empty_resources.golden.yml index 7fd6cfc5b80f2..b4b27d4cac0d8 100644 --- a/cli/cmd/testdata/inject_emojivoto_list_empty_resources.golden.yml +++ b/cli/cmd/testdata/inject_emojivoto_list_empty_resources.golden.yml @@ -20,6 +20,9 @@ items: app: web-svc linkerd.io/control-plane-ns: linkerd linkerd.io/proxy-deployment: web + linkerd.io/proxy-root-parent: web + linkerd.io/proxy-root-parent-group: apps + linkerd.io/proxy-root-parent-kind: Deployment linkerd.io/workload-ns: emojivoto spec: containers: @@ -284,6 +287,9 @@ items: app: emoji-svc linkerd.io/control-plane-ns: linkerd linkerd.io/proxy-deployment: emoji + linkerd.io/proxy-root-parent: emoji + linkerd.io/proxy-root-parent-group: apps + linkerd.io/proxy-root-parent-kind: Deployment linkerd.io/workload-ns: emojivoto spec: containers: diff --git a/cli/cmd/testdata/inject_emojivoto_statefulset.golden.yml b/cli/cmd/testdata/inject_emojivoto_statefulset.golden.yml index 699e6097ff2cd..f6a9df37c798b 100644 --- a/cli/cmd/testdata/inject_emojivoto_statefulset.golden.yml +++ b/cli/cmd/testdata/inject_emojivoto_statefulset.golden.yml @@ -18,6 +18,9 @@ spec: labels: app: web-svc linkerd.io/control-plane-ns: linkerd + linkerd.io/proxy-root-parent: web + linkerd.io/proxy-root-parent-group: apps + linkerd.io/proxy-root-parent-kind: StatefulSet linkerd.io/proxy-statefulset: web linkerd.io/workload-ns: emojivoto spec: diff --git a/cli/cmd/testdata/inject_gettest_deployment.good.golden.yml b/cli/cmd/testdata/inject_gettest_deployment.good.golden.yml index a073c7a7060ef..ca8c1b9ead985 100644 --- a/cli/cmd/testdata/inject_gettest_deployment.good.golden.yml +++ b/cli/cmd/testdata/inject_gettest_deployment.good.golden.yml @@ -14,6 +14,9 @@ spec: app: get-test linkerd.io/control-plane-ns: linkerd linkerd.io/proxy-deployment: get-test-deploy-injected-1 + linkerd.io/proxy-root-parent: get-test-deploy-injected-1 + linkerd.io/proxy-root-parent-group: apps + linkerd.io/proxy-root-parent-kind: Deployment linkerd.io/workload-ns: "" spec: containers: @@ -281,6 +284,9 @@ spec: app: get-test linkerd.io/control-plane-ns: linkerd linkerd.io/proxy-deployment: get-test-deploy-injected-2 + linkerd.io/proxy-root-parent: get-test-deploy-injected-2 + linkerd.io/proxy-root-parent-group: apps + linkerd.io/proxy-root-parent-kind: Deployment linkerd.io/workload-ns: "" spec: containers: diff --git a/cli/cmd/testdata/inject_tap_deployment_debug.golden.yml b/cli/cmd/testdata/inject_tap_deployment_debug.golden.yml index 8976836374694..d21f24471db00 100644 --- a/cli/cmd/testdata/inject_tap_deployment_debug.golden.yml +++ b/cli/cmd/testdata/inject_tap_deployment_debug.golden.yml @@ -35,6 +35,9 @@ spec: linkerd.io/control-plane-component: tap linkerd.io/control-plane-ns: linkerd linkerd.io/proxy-deployment: linkerd-tap + linkerd.io/proxy-root-parent: linkerd-tap + linkerd.io/proxy-root-parent-group: apps + linkerd.io/proxy-root-parent-kind: Deployment linkerd.io/workload-ns: linkerd spec: containers: diff --git a/controller/api/destination/endpoint_translator_test.go b/controller/api/destination/endpoint_translator_test.go index 43fe66fbbe21f..d5d99904a36c0 100644 --- a/controller/api/destination/endpoint_translator_test.go +++ b/controller/api/destination/endpoint_translator_test.go @@ -30,8 +30,9 @@ var ( Name: "pod1", Namespace: "ns", Labels: map[string]string{ - k8s.ControllerNSLabel: "linkerd", - k8s.ProxyDeploymentLabel: "deployment-name", + k8s.ControllerNSLabel: "linkerd", + k8s.ProxyRootParentLabel: "deployment-name", + k8s.ProxyRootParentKindLabel: "Deployment", }, }, Spec: corev1.PodSpec{ @@ -69,8 +70,9 @@ var ( Name: "pod1", Namespace: "ns", Labels: map[string]string{ - k8s.ControllerNSLabel: "linkerd", - k8s.ProxyDeploymentLabel: "deployment-name", + k8s.ControllerNSLabel: "linkerd", + k8s.ProxyRootParentLabel: "deployment-name", + k8s.ProxyRootParentKindLabel: "Deployment", }, }, Spec: corev1.PodSpec{ @@ -108,8 +110,9 @@ var ( Name: "pod2", Namespace: "ns", Labels: map[string]string{ - k8s.ControllerNSLabel: "linkerd", - k8s.ProxyDeploymentLabel: "deployment-name", + k8s.ControllerNSLabel: "linkerd", + k8s.ProxyRootParentLabel: "deployment-name", + k8s.ProxyRootParentKindLabel: "Deployment", }, }, Spec: corev1.PodSpec{ @@ -144,8 +147,9 @@ var ( Name: "pod3", Namespace: "ns", Labels: map[string]string{ - k8s.ControllerNSLabel: "linkerd", - k8s.ProxyDeploymentLabel: "deployment-name", + k8s.ControllerNSLabel: "linkerd", + k8s.ProxyRootParentLabel: "deployment-name", + k8s.ProxyRootParentKindLabel: "Deployment", }, }, Spec: corev1.PodSpec{ @@ -180,8 +184,9 @@ var ( Name: "pod4", Namespace: "ns", Labels: map[string]string{ - k8s.ControllerNSLabel: "linkerd", - k8s.ProxyDeploymentLabel: "deployment-name", + k8s.ControllerNSLabel: "linkerd", + k8s.ProxyRootParentLabel: "deployment-name", + k8s.ProxyRootParentKindLabel: "Deployment", }, Annotations: map[string]string{ k8s.ProxyOpaquePortsAnnotation: "4", @@ -220,8 +225,9 @@ var ( Name: "podAdmin", Namespace: "ns", Labels: map[string]string{ - k8s.ControllerNSLabel: "linkerd", - k8s.ProxyDeploymentLabel: "deployment-name", + k8s.ControllerNSLabel: "linkerd", + k8s.ProxyRootParentLabel: "deployment-name", + k8s.ProxyRootParentKindLabel: "Deployment", }, }, Spec: corev1.PodSpec{ @@ -259,8 +265,9 @@ var ( Name: "podControl", Namespace: "ns", Labels: map[string]string{ - k8s.ControllerNSLabel: "linkerd", - k8s.ProxyDeploymentLabel: "deployment-name", + k8s.ControllerNSLabel: "linkerd", + k8s.ProxyRootParentLabel: "deployment-name", + k8s.ProxyRootParentKindLabel: "Deployment", }, }, Spec: corev1.PodSpec{ @@ -323,8 +330,9 @@ var ( Name: "ew-2", Namespace: "ns", Labels: map[string]string{ - k8s.ControllerNSLabel: "linkerd", - k8s.ProxyDeploymentLabel: "deployment-name", + k8s.ControllerNSLabel: "linkerd", + k8s.ProxyRootParentLabel: "deployment-name", + k8s.ProxyRootParentKindLabel: "Deployment", }, }, Spec: ewv1beta1.ExternalWorkloadSpec{ @@ -350,8 +358,9 @@ var ( Name: "ew-3", Namespace: "ns", Labels: map[string]string{ - k8s.ControllerNSLabel: "linkerd", - k8s.ProxyDeploymentLabel: "deployment-name", + k8s.ControllerNSLabel: "linkerd", + k8s.ProxyRootParentLabel: "deployment-name", + k8s.ProxyRootParentKindLabel: "Deployment", }, }, Spec: ewv1beta1.ExternalWorkloadSpec{ @@ -480,8 +489,9 @@ var ( Name: "pod1", Namespace: "ns", Labels: map[string]string{ - k8s.ControllerNSLabel: "linkerd", - k8s.ProxyDeploymentLabel: "deployment-name", + k8s.ControllerNSLabel: "linkerd", + k8s.ProxyRootParentLabel: "deployment-name", + k8s.ProxyRootParentKindLabel: "Deployment", }, }, Spec: corev1.PodSpec{ @@ -497,8 +507,9 @@ var ( Name: "pod1", Namespace: "ns", Labels: map[string]string{ - k8s.ControllerNSLabel: "linkerd", - k8s.ProxyDeploymentLabel: "deployment-name", + k8s.ControllerNSLabel: "linkerd", + k8s.ProxyRootParentLabel: "deployment-name", + k8s.ProxyRootParentKindLabel: "Deployment", }, }, Spec: corev1.PodSpec{ diff --git a/controller/api/destination/watcher/endpoints_watcher.go b/controller/api/destination/watcher/endpoints_watcher.go index 170ad0540fd37..e0d9199d2073e 100644 --- a/controller/api/destination/watcher/endpoints_watcher.go +++ b/controller/api/destination/watcher/endpoints_watcher.go @@ -1145,13 +1145,13 @@ func (pp *portPublisher) newPodRefAddress( if err != nil { return Address{}, PodID{}, fmt.Errorf("unable to fetch pod %v: %w", id, err) } - ownerKind, ownerName := pp.metadataAPI.GetOwnerKindAndName(context.Background(), pod, false) + ownerType, ownerMeta := pp.metadataAPI.GetRootOwnerKindAndName(context.Background(), &pod.TypeMeta, &pod.ObjectMeta, false) addr := Address{ IP: endpointIP, Port: endpointPort, Pod: pod, - OwnerName: ownerName, - OwnerKind: ownerKind, + OwnerName: ownerMeta.Name, + OwnerKind: strings.ToLower(ownerType.Kind), } return addr, id, nil diff --git a/controller/api/destination/watcher/workload_watcher.go b/controller/api/destination/watcher/workload_watcher.go index 892c116b6a1db..a893533ab7e3b 100644 --- a/controller/api/destination/watcher/workload_watcher.go +++ b/controller/api/destination/watcher/workload_watcher.go @@ -695,9 +695,9 @@ func (wp *workloadPublisher) updatePod(pod *corev1.Pod) { // Fill in ownership. if wp.addr.Pod != nil { - ownerKind, ownerName := wp.metadataAPI.GetOwnerKindAndName(context.Background(), wp.addr.Pod, true) - wp.addr.OwnerKind = ownerKind - wp.addr.OwnerName = ownerName + ownerType, ownerMeta := wp.metadataAPI.GetRootOwnerKindAndName(context.Background(), &wp.addr.Pod.TypeMeta, &wp.addr.Pod.ObjectMeta, true) + wp.addr.OwnerKind = strings.ToLower(ownerType.Kind) + wp.addr.OwnerName = ownerMeta.Name } // Compute opaque protocol. diff --git a/controller/k8s/api_test.go b/controller/k8s/api_test.go index 3a0bb25f31bad..1e63f6ef491b8 100644 --- a/controller/k8s/api_test.go +++ b/controller/k8s/api_test.go @@ -1245,17 +1245,7 @@ metadata: t.Fatalf("Expected name to be [%s], got [%s]", tt.expectedOwnerName, ownerName) } - ownerKind, ownerName = metadataAPI.GetOwnerKindAndName(context.Background(), pod, retry) - - if ownerKind != tt.expectedOwnerKind { - t.Fatalf("Expected kind to be [%s], got [%s]", tt.expectedOwnerKind, ownerKind) - } - - if ownerName != tt.expectedOwnerName { - t.Fatalf("Expected name to be [%s], got [%s]", tt.expectedOwnerName, ownerName) - } - - tm, om := metadataAPI.GetRootOwnerKindAndName(context.Background(), &pod.TypeMeta, &pod.ObjectMeta) + tm, om := metadataAPI.GetRootOwnerKindAndName(context.Background(), &pod.TypeMeta, &pod.ObjectMeta, retry) if tm.Kind != tt.expectedRootOwnerKind { t.Fatalf("Expected root kind to be [%s], got [%s]", tt.expectedRootOwnerKind, tm.Kind) diff --git a/controller/k8s/metadata_api.go b/controller/k8s/metadata_api.go index c324cd01ad4ae..f6138d9d23906 100644 --- a/controller/k8s/metadata_api.go +++ b/controller/k8s/metadata_api.go @@ -8,9 +8,6 @@ import ( "github.com/linkerd/linkerd2/pkg/k8s" "github.com/prometheus/client_golang/prometheus" log "github.com/sirupsen/logrus" - appsv1 "k8s.io/api/apps/v1" - batchv1 "k8s.io/api/batch/v1" - corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/meta" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" @@ -209,80 +206,16 @@ func (api *MetadataAPI) GetByNamespaceFiltered( return objMetas, nil } -// GetOwnerKindAndName returns the pod owner's kind and name, using owner -// references from the Kubernetes API. The kind is represented as the -// Kubernetes singular resource type (e.g. deployment, daemonset, job, etc.). -// If retry is true, when the shared informer cache doesn't return anything we -// try again with a direct Kubernetes API call. -func (api *MetadataAPI) GetOwnerKindAndName(ctx context.Context, pod *corev1.Pod, retry bool) (string, string) { - ownerRefs := pod.GetOwnerReferences() - if len(ownerRefs) == 0 { - // pod without a parent - return "pod", pod.Name - } else if len(ownerRefs) > 1 { - log.Debugf("unexpected owner reference count (%d): %+v", len(ownerRefs), ownerRefs) - return "pod", pod.Name - } - - parent := ownerRefs[0] - var parentObj metav1.Object - var err error - switch parent.Kind { - case "Job": - parentObj, err = api.getByNamespace(Job, pod.Namespace, parent.Name) - if err != nil { - log.Warnf("failed to retrieve job from indexer %s/%s: %s", pod.Namespace, parent.Name, err) - if retry { - parentObj, err = api.client. - Resource(batchv1.SchemeGroupVersion.WithResource("jobs")). - Namespace(pod.Namespace). - Get(ctx, parent.Name, metav1.GetOptions{}) - if err != nil { - log.Warnf("failed to retrieve job from direct API call %s/%s: %s", pod.Namespace, parent.Name, err) - } - } - } - case "ReplicaSet": - var rsObj *metav1.PartialObjectMetadata - rsObj, err = api.getByNamespace(RS, pod.Namespace, parent.Name) - if err != nil { - log.Warnf("failed to retrieve replicaset from indexer %s/%s: %s", pod.Namespace, parent.Name, err) - if retry { - rsObj, err = api.client. - Resource(appsv1.SchemeGroupVersion.WithResource("replicasets")). - Namespace(pod.Namespace). - Get(ctx, parent.Name, metav1.GetOptions{}) - if err != nil { - log.Warnf("failed to retrieve replicaset from direct API call %s/%s: %s", pod.Namespace, parent.Name, err) - } - } - } - - if rsObj == nil || !isValidRSParent(rsObj) { - return strings.ToLower(parent.Kind), parent.Name - } - parentObj = rsObj - default: - return strings.ToLower(parent.Kind), parent.Name - } - - if err == nil && len(parentObj.GetOwnerReferences()) == 1 { - grandParent := parentObj.GetOwnerReferences()[0] - return strings.ToLower(grandParent.Kind), grandParent.Name - } - return strings.ToLower(parent.Kind), parent.Name -} - // GetRootOwnerKindAndName returns the resource's owner's type and metadata, using owner // references from the Kubernetes API. Parent refs are recursively traversed to find the // root parent resource, at least as far as the controller has permissions to query. // This will attempt to lookup resources through the shared informer cache where possible, // but may fall back to direct Kubernetes API calls where necessary. -func (api *MetadataAPI) GetRootOwnerKindAndName(ctx context.Context, tm *metav1.TypeMeta, om *metav1.ObjectMeta) (*metav1.TypeMeta, *metav1.ObjectMeta) { +func (api *MetadataAPI) GetRootOwnerKindAndName(ctx context.Context, tm *metav1.TypeMeta, om *metav1.ObjectMeta, retry bool) (*metav1.TypeMeta, *metav1.ObjectMeta) { ownerRefs := om.OwnerReferences if len(ownerRefs) == 0 { // resource without a parent - log.Debugf("Found root owner ref (%s)", om) + log.Debugf("Found root owner ref in ns %s: %s/%s: %s", om.Namespace, tm.APIVersion, tm.Kind, om.Name) return tm, om } else if len(ownerRefs) > 1 { log.Debugf("unexpected owner reference count (%d): %+v", len(ownerRefs), ownerRefs) @@ -290,6 +223,7 @@ func (api *MetadataAPI) GetRootOwnerKindAndName(ctx context.Context, tm *metav1. } parentRef := ownerRefs[0] + parentType := metav1.TypeMeta{Kind: parentRef.Kind, APIVersion: parentRef.APIVersion} // The set of resources that we look up in the indexer are fairly niche. They all must be able to: // - be a parent of another resource, usually a Pod // - have a parent resource themselves @@ -300,15 +234,24 @@ func (api *MetadataAPI) GetRootOwnerKindAndName(ctx context.Context, tm *metav1. case "Job": parent, err := api.getByNamespace(Job, om.Namespace, parentRef.Name) if err == nil { - return api.GetRootOwnerKindAndName(ctx, &parent.TypeMeta, &parent.ObjectMeta) + return api.GetRootOwnerKindAndName(ctx, &parentType, &parent.ObjectMeta, retry) } log.Warnf("failed to retrieve job from indexer %s/%s: %s", om.Namespace, parentRef.Name, err) + if !retry { + return &parentType, &metav1.ObjectMeta{Name: parentRef.Name, Namespace: om.Namespace} + } case "ReplicaSet": parent, err := api.getByNamespace(RS, om.Namespace, parentRef.Name) if err == nil { - return api.GetRootOwnerKindAndName(ctx, &parent.TypeMeta, &parent.ObjectMeta) + return api.GetRootOwnerKindAndName(ctx, &parentType, &parent.ObjectMeta, retry) } log.Warnf("failed to retrieve replicaset from indexer %s/%s: %s", om.Namespace, parentRef.Name, err) + if !retry { + return &parentType, &metav1.ObjectMeta{Name: parentRef.Name, Namespace: om.Namespace} + } + case "": + log.Warnf("parent ref has no kind: %v", parentRef) + return tm, om } resource := schema.FromAPIVersionAndKind(parentRef.APIVersion, parentRef.Kind). @@ -319,9 +262,9 @@ func (api *MetadataAPI) GetRootOwnerKindAndName(ctx context.Context, tm *metav1. Get(ctx, parentRef.Name, metav1.GetOptions{}) if err != nil { log.Warnf("failed to retrieve resource from direct API call %s/%s/%s: %s", schema.FromAPIVersionAndKind(parentRef.APIVersion, parentRef.Kind), om.Namespace, parentRef.Name, err) - return &metav1.TypeMeta{Kind: parentRef.Kind, APIVersion: parentRef.APIVersion}, &metav1.ObjectMeta{Name: parentRef.Name, Namespace: om.Namespace} + return &parentType, &metav1.ObjectMeta{Name: parentRef.Name, Namespace: om.Namespace} } - return api.GetRootOwnerKindAndName(ctx, &parent.TypeMeta, &parent.ObjectMeta) + return api.GetRootOwnerKindAndName(ctx, &parentType, &parent.ObjectMeta, retry) } func (api *MetadataAPI) addInformer(res APIResource, informerLabels prometheus.Labels) error { diff --git a/controller/proxy-injector/webhook.go b/controller/proxy-injector/webhook.go index 071e2014b3c3e..0a082c20ef71c 100644 --- a/controller/proxy-injector/webhook.go +++ b/controller/proxy-injector/webhook.go @@ -56,7 +56,6 @@ func Inject(linkerdNamespace string, overrider inject.ValueOverrider) webhook.Ha return nil, err } resourceConfig := inject.NewResourceConfig(valuesConfig, inject.OriginWebhook, linkerdNamespace). - WithOwnerRetriever(ownerRetriever(ctx, api, request.Namespace)). WithRootOwnerRetriever(rootOwnerRetriever(ctx, api, request.Namespace)). WithNsAnnotations(ns.GetAnnotations()). WithKind(request.Kind.Kind) @@ -217,16 +216,9 @@ func Inject(linkerdNamespace string, overrider inject.ValueOverrider) webhook.Ha } } -func ownerRetriever(ctx context.Context, api *k8s.MetadataAPI, ns string) inject.OwnerRetrieverFunc { - return func(p *v1.Pod) (string, string) { - p.SetNamespace(ns) - return api.GetOwnerKindAndName(ctx, p, true) - } -} - func rootOwnerRetriever(ctx context.Context, api *k8s.MetadataAPI, ns string) inject.RootOwnerRetrieverFunc { return func(tm *metav1.TypeMeta, om *metav1.ObjectMeta) (*metav1.TypeMeta, *metav1.ObjectMeta) { om.SetNamespace(ns) - return api.GetRootOwnerKindAndName(ctx, tm, om) + return api.GetRootOwnerKindAndName(ctx, tm, om, true) } } diff --git a/controller/proxy-injector/webhook_test.go b/controller/proxy-injector/webhook_test.go index e7e304c4630b6..d710bd3b5de8d 100644 --- a/controller/proxy-injector/webhook_test.go +++ b/controller/proxy-injector/webhook_test.go @@ -113,7 +113,6 @@ func TestGetPodPatch(t *testing.T) { fakeReq := getFakePodReq(pod) fullConf := testCase.conf. WithKind(fakeReq.Kind.Kind). - WithOwnerRetriever(ownerRetrieverFake). WithRootOwnerRetriever(rootOwnerRetrieverFake) _, err = fullConf.ParseMetaAndYAML(fakeReq.Object.Raw) if err != nil { @@ -138,7 +137,6 @@ func TestGetPodPatch(t *testing.T) { pod := fileContents(factory, t, "pod-with-debug-enabled.yaml") fakeReq := getFakePodReq(pod) conf := confNsEnabled().WithKind(fakeReq.Kind.Kind). - WithOwnerRetriever(ownerRetrieverFake). WithRootOwnerRetriever(rootOwnerRetrieverFake) _, err = conf.ParseMetaAndYAML(fakeReq.Object.Raw) if err != nil { @@ -161,7 +159,6 @@ func TestGetPodPatch(t *testing.T) { pod := fileContents(factory, t, "pod-with-custom-debug-tag.yaml") fakeReq := getFakePodReq(pod) conf := confNsEnabled().WithKind(fakeReq.Kind.Kind). - WithOwnerRetriever(ownerRetrieverFake). WithRootOwnerRetriever(rootOwnerRetrieverFake) _, err = conf.ParseMetaAndYAML(fakeReq.Object.Raw) if err != nil { @@ -185,7 +182,6 @@ func TestGetPodPatch(t *testing.T) { fakeReq := getFakePodReq(pod) conf := confNsWithoutOpaquePorts(). WithKind(fakeReq.Kind.Kind). - WithOwnerRetriever(ownerRetrieverFake). WithRootOwnerRetriever(rootOwnerRetrieverFake) _, err = conf.ParseMetaAndYAML(fakeReq.Object.Raw) if err != nil { @@ -210,7 +206,6 @@ func TestGetPodPatch(t *testing.T) { fakeReq := getFakePodReq(pod) conf := confNsWithoutOpaquePorts(). WithKind(fakeReq.Kind.Kind). - WithOwnerRetriever(ownerRetrieverFake). WithRootOwnerRetriever(rootOwnerRetrieverFake) _, err = conf.ParseMetaAndYAML(fakeReq.Object.Raw) if err != nil { @@ -238,7 +233,6 @@ func TestGetPodPatch(t *testing.T) { fakeReq := getFakePodReq(pod) conf := confNsWithConfigAnnotations(). WithKind(fakeReq.Kind.Kind). - WithOwnerRetriever(ownerRetrieverFake). WithRootOwnerRetriever(rootOwnerRetrieverFake) _, err = conf.ParseMetaAndYAML(fakeReq.Object.Raw) if err != nil { @@ -372,7 +366,6 @@ func TestGetAnnotationPatch(t *testing.T) { fakeReq := getFakeServiceReq(service) fullConf := testCase.conf. WithKind(fakeReq.Kind.Kind). - WithOwnerRetriever(ownerRetrieverFake). WithRootOwnerRetriever(rootOwnerRetrieverFake) _, err = fullConf.ParseMetaAndYAML(fakeReq.Object.Raw) if err != nil { @@ -417,10 +410,6 @@ func getFakeServiceReq(b []byte) *admissionv1beta1.AdmissionRequest { } } -func ownerRetrieverFake(p *corev1.Pod) (string, string) { - return pkgK8s.Deployment, "owner-deployment" -} - func rootOwnerRetrieverFake(tm *metav1.TypeMeta, om *metav1.ObjectMeta) (*metav1.TypeMeta, *metav1.ObjectMeta) { return &metav1.TypeMeta{Kind: "Deployment", APIVersion: "apps/v1"}, &metav1.ObjectMeta{Name: "owner-deployment"} } diff --git a/pkg/inject/inject.go b/pkg/inject/inject.go index 2130a7dfa1a64..6b02f67c4275e 100644 --- a/pkg/inject/inject.go +++ b/pkg/inject/inject.go @@ -112,10 +112,6 @@ const ( OriginUnknown ) -// OwnerRetrieverFunc is a function that returns a pod's owner reference -// kind and name -type OwnerRetrieverFunc func(*corev1.Pod) (string, string) - // RootOwnerRetrieverFunc is a function that returns a pod's root owner reference // type and metadata type RootOwnerRetrieverFunc func(*metav1.TypeMeta, *metav1.ObjectMeta) (*metav1.TypeMeta, *metav1.ObjectMeta) @@ -133,7 +129,6 @@ type ResourceConfig struct { // The resources's annotations will be applied on top of these, which // allows the nsAnnotations to act as a default. nsAnnotations map[string]string - ownerRetriever OwnerRetrieverFunc rootOwnerRetriever RootOwnerRetrieverFunc origin Origin @@ -590,13 +585,6 @@ func (conf *ResourceConfig) WithNsAnnotations(m map[string]string) *ResourceConf return conf } -// WithOwnerRetriever enriches ResourceConfig with a function that allows to retrieve -// the kind and name of the workload's owner reference -func (conf *ResourceConfig) WithOwnerRetriever(f OwnerRetrieverFunc) *ResourceConfig { - conf.ownerRetriever = f - return conf -} - // WithRootOwnerRetriever enriches ResourceConfig with a function that allows to retrieve // the kind and name of the workload's root owner reference func (conf *ResourceConfig) WithRootOwnerRetriever(f RootOwnerRetrieverFunc) *ResourceConfig { @@ -942,44 +930,68 @@ func (conf *ResourceConfig) JSONToYAML(bytes []byte) ([]byte, error) { func (conf *ResourceConfig) populateMeta(obj runtime.Object) error { switch v := obj.(type) { case *appsv1.Deployment: + gvk := v.TypeMeta.GroupVersionKind() conf.workload.obj = v conf.workload.Meta = &v.ObjectMeta conf.pod.labels[k8s.ProxyDeploymentLabel] = v.Name + conf.pod.labels[k8s.ProxyRootParentLabel] = v.Name + conf.pod.labels[k8s.ProxyRootParentGroupLabel] = gvk.Group + conf.pod.labels[k8s.ProxyRootParentKindLabel] = gvk.Kind conf.pod.labels[k8s.WorkloadNamespaceLabel] = v.Namespace conf.complete(&v.Spec.Template) case *corev1.ReplicationController: + gvk := v.TypeMeta.GroupVersionKind() conf.workload.obj = v conf.workload.Meta = &v.ObjectMeta conf.pod.labels[k8s.ProxyReplicationControllerLabel] = v.Name + conf.pod.labels[k8s.ProxyRootParentLabel] = v.Name + conf.pod.labels[k8s.ProxyRootParentGroupLabel] = gvk.Group + conf.pod.labels[k8s.ProxyRootParentKindLabel] = gvk.Kind conf.pod.labels[k8s.WorkloadNamespaceLabel] = v.Namespace conf.complete(v.Spec.Template) case *appsv1.ReplicaSet: + gvk := v.TypeMeta.GroupVersionKind() conf.workload.obj = v conf.workload.Meta = &v.ObjectMeta conf.pod.labels[k8s.ProxyReplicaSetLabel] = v.Name + conf.pod.labels[k8s.ProxyRootParentLabel] = v.Name + conf.pod.labels[k8s.ProxyRootParentGroupLabel] = gvk.Group + conf.pod.labels[k8s.ProxyRootParentKindLabel] = gvk.Kind conf.pod.labels[k8s.WorkloadNamespaceLabel] = v.Namespace conf.complete(&v.Spec.Template) case *batchv1.Job: + gvk := v.TypeMeta.GroupVersionKind() conf.workload.obj = v conf.workload.Meta = &v.ObjectMeta conf.pod.labels[k8s.ProxyJobLabel] = v.Name + conf.pod.labels[k8s.ProxyRootParentLabel] = v.Name + conf.pod.labels[k8s.ProxyRootParentGroupLabel] = gvk.Group + conf.pod.labels[k8s.ProxyRootParentKindLabel] = gvk.Kind conf.pod.labels[k8s.WorkloadNamespaceLabel] = v.Namespace conf.complete(&v.Spec.Template) case *appsv1.DaemonSet: + gvk := v.TypeMeta.GroupVersionKind() conf.workload.obj = v conf.workload.Meta = &v.ObjectMeta conf.pod.labels[k8s.ProxyDaemonSetLabel] = v.Name + conf.pod.labels[k8s.ProxyRootParentLabel] = v.Name + conf.pod.labels[k8s.ProxyRootParentGroupLabel] = gvk.Group + conf.pod.labels[k8s.ProxyRootParentKindLabel] = gvk.Kind conf.pod.labels[k8s.WorkloadNamespaceLabel] = v.Namespace conf.complete(&v.Spec.Template) case *appsv1.StatefulSet: + gvk := v.TypeMeta.GroupVersionKind() conf.workload.obj = v conf.workload.Meta = &v.ObjectMeta conf.pod.labels[k8s.ProxyStatefulSetLabel] = v.Name + conf.pod.labels[k8s.ProxyRootParentLabel] = v.Name + conf.pod.labels[k8s.ProxyRootParentGroupLabel] = gvk.Group + conf.pod.labels[k8s.ProxyRootParentKindLabel] = gvk.Kind conf.pod.labels[k8s.WorkloadNamespaceLabel] = v.Namespace conf.complete(&v.Spec.Template) @@ -1002,26 +1014,24 @@ func (conf *ResourceConfig) populateMeta(obj runtime.Object) error { conf.pod.spec = &v.Spec conf.pod.meta = &v.ObjectMeta - if conf.ownerRetriever != nil { - kind, name := conf.ownerRetriever(v) - conf.workload.ownerRef = &metav1.OwnerReference{Kind: kind, Name: name} - switch kind { + if conf.rootOwnerRetriever != nil { + tm, om := conf.rootOwnerRetriever(&v.TypeMeta, &v.ObjectMeta) + + switch strings.ToLower(tm.Kind) { case k8s.Deployment: - conf.pod.labels[k8s.ProxyDeploymentLabel] = name + conf.pod.labels[k8s.ProxyDeploymentLabel] = om.Name case k8s.ReplicationController: - conf.pod.labels[k8s.ProxyReplicationControllerLabel] = name + conf.pod.labels[k8s.ProxyReplicationControllerLabel] = om.Name case k8s.ReplicaSet: - conf.pod.labels[k8s.ProxyReplicaSetLabel] = name + conf.pod.labels[k8s.ProxyReplicaSetLabel] = om.Name case k8s.Job: - conf.pod.labels[k8s.ProxyJobLabel] = name + conf.pod.labels[k8s.ProxyJobLabel] = om.Name case k8s.DaemonSet: - conf.pod.labels[k8s.ProxyDaemonSetLabel] = name + conf.pod.labels[k8s.ProxyDaemonSetLabel] = om.Name case k8s.StatefulSet: - conf.pod.labels[k8s.ProxyStatefulSetLabel] = name + conf.pod.labels[k8s.ProxyStatefulSetLabel] = om.Name } - } - if conf.rootOwnerRetriever != nil { - tm, om := conf.rootOwnerRetriever(&v.TypeMeta, &v.ObjectMeta) + conf.pod.labels[k8s.ProxyRootParentLabel] = om.Name conf.pod.labels[k8s.ProxyRootParentKindLabel] = tm.Kind conf.pod.labels[k8s.ProxyRootParentGroupLabel] = tm.GroupVersionKind().Group