From 04d6bd506628a347669d75bb46ca148cf0e165db Mon Sep 17 00:00:00 2001 From: "navid.shariaty" Date: Sat, 28 Oct 2023 12:26:19 +0330 Subject: [PATCH] fix unwanted labels --- config/manager/manager.yaml | 2 +- k8sutils/agesecret.go | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/config/manager/manager.yaml b/config/manager/manager.yaml index a868783..15abbd5 100644 --- a/config/manager/manager.yaml +++ b/config/manager/manager.yaml @@ -51,7 +51,7 @@ spec: resources: limits: cpu: 3 - memory: 1Gi + memory: 4Gi requests: cpu: 1 memory: 1Gi diff --git a/k8sutils/agesecret.go b/k8sutils/agesecret.go index a279396..3386a9c 100644 --- a/k8sutils/agesecret.go +++ b/k8sutils/agesecret.go @@ -22,6 +22,9 @@ var ( unwantedAnnotations = []string{ "kubectl.kubernetes.io/last-applied-configuration", } + unwantedLabels = []string{ + "app.kubernetes.io/instance", + } ) func finalizeAgeSecret(ageSecret *v1alpha1.AgeSecret, k8sclient client.Client) error { @@ -66,6 +69,7 @@ func CreateOrUpdateSecretObj(ageSecret *v1alpha1.AgeSecret, secret *corev1.Secre err := k8sclient.Get(context.Background(), types.NamespacedName{Namespace: secret.Namespace, Name: secret.Name}, secretToLoad) if err != nil { if errors.IsNotFound(err) { + logger.Info("secret not found, creating...", "namespace", secret.Namespace, "secretName", secret.Name) errCreateChildSecret := k8sclient.Create(context.Background(), secret) if errCreateChildSecret != nil { ageSecret.Status.Health = lang.AgeSecretStatusUnhealthy @@ -140,7 +144,11 @@ func CheckAgeKeyReference(ageSecret *v1alpha1.AgeSecret, k8sclient client.Client } func cloneLabels(labels map[string]string) map[string]string { - return cloneMap(labels) + tmpLabels := cloneMap(labels) + for _, label := range unwantedLabels { + delete(tmpLabels, label) + } + return tmpLabels } func cloneAnnotations(annotations map[string]string) map[string]string {