Skip to content

Commit c19f6cb

Browse files
committed
Add missing labels to deployment in injection-deploy mutation
1 parent eb2aeba commit c19f6cb

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

pkg/mutation/mutation_deploy.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,18 @@ func injectionDeploy(request *admissionv1.AdmissionRequest) (*admissionv1.Admiss
9090
if enhanceType, ok := deploy.Labels[config.EnhanceTypeLabel]; ok && enhanceType == config.EnhanceTypeSidecar {
9191
log.Infof("[mutation] /injection-deploy: add label %s to deployment %s/%s", config.SidecarEnhanceLabel, deploy.Name, deploy.Namespace)
9292
target.Spec.Template.Labels[config.SidecarEnhanceLabel] = "true"
93+
target.Spec.Template.Labels[config.ApplicationLabel] = target.Labels[config.ApplicationLabel]
94+
target.Spec.Template.Labels[config.ServiceNameLabel] = target.Labels[config.ServiceNameLabel]
95+
target.Spec.Template.Labels[config.ServiceGroupLabel] = target.Labels[config.ServiceGroupLabel]
9396
added = true
9497
} else {
9598
// Check if the x-live-enabled label exists in deploy's spec.template.metadata.labels; if not, add it.
9699
if _, ok := deploy.Spec.Template.Labels[config.WebHookMatchKey]; !ok {
97100
log.Infof("[mutation] /injection-deploy: add label %s to deployment %s/%s", config.WebHookMatchKey, deploy.Name, deploy.Namespace)
98101
target.Spec.Template.Labels[config.WebHookMatchKey] = config.WebHookMatchValue
102+
target.Spec.Template.Labels[config.ApplicationLabel] = target.Labels[config.ApplicationLabel]
103+
target.Spec.Template.Labels[config.ServiceNameLabel] = target.Labels[config.ServiceNameLabel]
104+
target.Spec.Template.Labels[config.ServiceGroupLabel] = target.Labels[config.ServiceGroupLabel]
99105
added = true
100106
}
101107
}

0 commit comments

Comments
 (0)