From 785b643b2ff3b742c0e20e220b3de8103a4034f0 Mon Sep 17 00:00:00 2001 From: Ang Gao Date: Tue, 23 Mar 2021 16:12:15 +0000 Subject: [PATCH 1/5] Remove app.kubernetes.io/version label from label selectors Signed-off-by: Ang Gao --- Makefile | 8 ++++---- config/default/kustomization.yaml | 4 ++-- .../kustomize-config/metadataLabelTransformer.yaml | 9 +++++++++ 3 files changed, 15 insertions(+), 6 deletions(-) create mode 100644 config/default/kustomize-config/metadataLabelTransformer.yaml diff --git a/Makefile b/Makefile index b99a3cfe1eb..0b292a13e86 100644 --- a/Makefile +++ b/Makefile @@ -88,8 +88,8 @@ release: manifests kustomize set-version $(KUSTOMIZE) edit set image ghcr.io/kedacore/keda=${IMAGE_CONTROLLER} cd config/metrics-server && \ $(KUSTOMIZE) edit set image ghcr.io/kedacore/keda-metrics-apiserver=${IMAGE_ADAPTER} - cd config/default && \ - $(KUSTOMIZE) edit add label -f app.kubernetes.io/version:${VERSION} + @sed -i".out" -e 's@version:[ ].*@version: $(VERSION)@g' config/default/kustomize-config/metadataLabelTransformer.yaml + rm -rf config/default/kustomize-config/metadataLabelTransformer.yaml.out $(KUSTOMIZE) build config/default > keda-$(VERSION).yaml .PHONY: set-version @@ -122,8 +122,8 @@ deploy: manifests kustomize $(KUSTOMIZE) edit set image ghcr.io/kedacore/keda=${IMAGE_CONTROLLER} cd config/metrics-server && \ $(KUSTOMIZE) edit set image ghcr.io/kedacore/keda-metrics-apiserver=${IMAGE_ADAPTER} - cd config/default && \ - $(KUSTOMIZE) edit add label -f app.kubernetes.io/version:${VERSION} + @sed -i".out" -e 's@version:[ ].*@version: $(VERSION)@g' config/default/kustomize-config/metadataLabelTransformer.yaml + rm -rf config/default/kustomize-config/metadataLabelTransformer.yaml.out $(KUSTOMIZE) build config/default | kubectl apply -f - # Undeploy controller diff --git a/config/default/kustomization.yaml b/config/default/kustomization.yaml index 687c44442ed..4ae134fe5c2 100644 --- a/config/default/kustomization.yaml +++ b/config/default/kustomization.yaml @@ -19,8 +19,8 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization commonLabels: app.kubernetes.io/part-of: keda-operator - app.kubernetes.io/version: main - +transformers: +- kustomize-config/metadataLabelTransformer.yaml resources: - ../crd diff --git a/config/default/kustomize-config/metadataLabelTransformer.yaml b/config/default/kustomize-config/metadataLabelTransformer.yaml new file mode 100644 index 00000000000..4413bbe82a7 --- /dev/null +++ b/config/default/kustomize-config/metadataLabelTransformer.yaml @@ -0,0 +1,9 @@ +apiVersion: builtin +kind: LabelTransformer +metadata: + name: metadataLabelTransformer +labels: + app.kubernetes.io/version: main +fieldSpecs: +- path: metadata/labels + create: true From badae688e987bf58e96ff2c0e85567a040fcb28e Mon Sep 17 00:00:00 2001 From: Ang Gao Date: Tue, 23 Mar 2021 16:21:51 +0000 Subject: [PATCH 2/5] update Changelog Signed-off-by: Ang Gao --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0eec5f35524..1aede5c6e10 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,7 +24,7 @@ ### Improvements -- TODO ([#XXX](https://github.com/kedacore/keda/pull/XXXX)) +- Remove app.kubernetes.io/version label from label selectors ([#1696](https://github.com/kedacore/keda/pull/1696)) ### Breaking Changes From f3bf8a83f751f099a31ca9dc6c83437557dac206 Mon Sep 17 00:00:00 2001 From: Ang Gao Date: Wed, 24 Mar 2021 11:23:21 +0000 Subject: [PATCH 3/5] add comments Signed-off-by: Ang Gao --- Makefile | 4 ++++ config/default/kustomization.yaml | 2 ++ 2 files changed, 6 insertions(+) diff --git a/Makefile b/Makefile index 0b292a13e86..6e0adcf63df 100644 --- a/Makefile +++ b/Makefile @@ -88,6 +88,8 @@ release: manifests kustomize set-version $(KUSTOMIZE) edit set image ghcr.io/kedacore/keda=${IMAGE_CONTROLLER} cd config/metrics-server && \ $(KUSTOMIZE) edit set image ghcr.io/kedacore/keda-metrics-apiserver=${IMAGE_ADAPTER} + # Need this workaround to mitigate a problem with inserting labels into selectors, + # until this issue is solved: https://github.com/kubernetes-sigs/kustomize/issues/1009 @sed -i".out" -e 's@version:[ ].*@version: $(VERSION)@g' config/default/kustomize-config/metadataLabelTransformer.yaml rm -rf config/default/kustomize-config/metadataLabelTransformer.yaml.out $(KUSTOMIZE) build config/default > keda-$(VERSION).yaml @@ -122,6 +124,8 @@ deploy: manifests kustomize $(KUSTOMIZE) edit set image ghcr.io/kedacore/keda=${IMAGE_CONTROLLER} cd config/metrics-server && \ $(KUSTOMIZE) edit set image ghcr.io/kedacore/keda-metrics-apiserver=${IMAGE_ADAPTER} + # Need this workaround to mitigate a problem with inserting labels into selectors, + # until this issue is solved: https://github.com/kubernetes-sigs/kustomize/issues/1009 @sed -i".out" -e 's@version:[ ].*@version: $(VERSION)@g' config/default/kustomize-config/metadataLabelTransformer.yaml rm -rf config/default/kustomize-config/metadataLabelTransformer.yaml.out $(KUSTOMIZE) build config/default | kubectl apply -f - diff --git a/config/default/kustomization.yaml b/config/default/kustomization.yaml index 4ae134fe5c2..78785e88d6d 100644 --- a/config/default/kustomization.yaml +++ b/config/default/kustomization.yaml @@ -19,6 +19,8 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization commonLabels: app.kubernetes.io/part-of: keda-operator +# Need this transformer to mitigate a problem with inserting labels into selectors, +# until this issue is solved: https://github.com/kubernetes-sigs/kustomize/issues/1009 transformers: - kustomize-config/metadataLabelTransformer.yaml From 7200e445549644e18377e8f1cd6fdda83c8c5875 Mon Sep 17 00:00:00 2001 From: Ang Gao Date: Wed, 24 Mar 2021 11:31:43 +0000 Subject: [PATCH 4/5] fix format Signed-off-by: Ang Gao --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 6e0adcf63df..1c6b916f0b8 100644 --- a/Makefile +++ b/Makefile @@ -125,7 +125,7 @@ deploy: manifests kustomize cd config/metrics-server && \ $(KUSTOMIZE) edit set image ghcr.io/kedacore/keda-metrics-apiserver=${IMAGE_ADAPTER} # Need this workaround to mitigate a problem with inserting labels into selectors, - # until this issue is solved: https://github.com/kubernetes-sigs/kustomize/issues/1009 + # until this issue is solved: https://github.com/kubernetes-sigs/kustomize/issues/1009 @sed -i".out" -e 's@version:[ ].*@version: $(VERSION)@g' config/default/kustomize-config/metadataLabelTransformer.yaml rm -rf config/default/kustomize-config/metadataLabelTransformer.yaml.out $(KUSTOMIZE) build config/default | kubectl apply -f - From ae0d5bbab0b86b8c4410eabf974e0b7cd62afc37 Mon Sep 17 00:00:00 2001 From: Ang Gao Date: Wed, 24 Mar 2021 12:00:32 +0000 Subject: [PATCH 5/5] remove app.kubernetes.io/part-of from selector Signed-off-by: Ang Gao --- config/default/kustomization.yaml | 2 -- config/default/kustomize-config/metadataLabelTransformer.yaml | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/config/default/kustomization.yaml b/config/default/kustomization.yaml index 78785e88d6d..cdf3a30e51c 100644 --- a/config/default/kustomization.yaml +++ b/config/default/kustomization.yaml @@ -17,8 +17,6 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization -commonLabels: - app.kubernetes.io/part-of: keda-operator # Need this transformer to mitigate a problem with inserting labels into selectors, # until this issue is solved: https://github.com/kubernetes-sigs/kustomize/issues/1009 transformers: diff --git a/config/default/kustomize-config/metadataLabelTransformer.yaml b/config/default/kustomize-config/metadataLabelTransformer.yaml index 4413bbe82a7..a9deb62005b 100644 --- a/config/default/kustomize-config/metadataLabelTransformer.yaml +++ b/config/default/kustomize-config/metadataLabelTransformer.yaml @@ -4,6 +4,7 @@ metadata: name: metadataLabelTransformer labels: app.kubernetes.io/version: main + app.kubernetes.io/part-of: keda-operator fieldSpecs: - path: metadata/labels create: true