diff --git a/pkg/plugins/config/k8s/store.go b/pkg/plugins/config/k8s/store.go index 07445df2b6b1..43f9c31e8350 100644 --- a/pkg/plugins/config/k8s/store.go +++ b/pkg/plugins/config/k8s/store.go @@ -91,6 +91,7 @@ func (s *KubernetesStore) Update(ctx context.Context, r core_model.Resource, fs if !ok { return newInvalidTypeError() } + opts := core_store.NewUpdateOptions(fs...) cm := &kube_core.ConfigMap{ TypeMeta: kube_meta.TypeMeta{ Kind: "ConfigMap", @@ -103,7 +104,12 @@ func (s *KubernetesStore) Update(ctx context.Context, r core_model.Resource, fs }, } - labels, annotations := k8s.SplitLabelsAndAnnotations(cm.GetLabels(), cm.GetAnnotations()) + updateLabels := cm.GetLabels() + if opts.ModifyLabels { + updateLabels = opts.Labels + } + + labels, annotations := k8s.SplitLabelsAndAnnotations(updateLabels, cm.GetAnnotations()) cm.GetObjectMeta().SetLabels(labels) cm.GetObjectMeta().SetAnnotations(annotations) diff --git a/pkg/plugins/secrets/k8s/store.go b/pkg/plugins/secrets/k8s/store.go index 6958ba741f06..fd30e075b72f 100644 --- a/pkg/plugins/secrets/k8s/store.go +++ b/pkg/plugins/secrets/k8s/store.go @@ -93,7 +93,11 @@ func (s *KubernetesStore) Update(ctx context.Context, r core_model.Resource, fs } secret.Namespace = s.namespace - setLabelsAnnotationsAndMesh(secret, r.GetMeta().GetMesh(), opts.Labels) + updateLabels := r.GetMeta().GetLabels() + if opts.ModifyLabels { + updateLabels = opts.Labels + } + setLabelsAnnotationsAndMesh(secret, r.GetMeta().GetMesh(), updateLabels) if err := s.writer.Update(ctx, secret); err != nil { if kube_apierrs.IsConflict(err) {