Skip to content

Commit

Permalink
Remove app.kubernetes.io/version label from label selectors (#1696)
Browse files Browse the repository at this point in the history
* Remove app.kubernetes.io/version label from label selectors

* Remove app.kubernetes.io/part-of from selector

Signed-off-by: Ang Gao <ang.gao87@gmail.com>
  • Loading branch information
anggao authored Mar 24, 2021
1 parent dfb0f60 commit dfdcc5e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 8 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,10 @@ 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}
# 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

.PHONY: set-version
Expand Down Expand Up @@ -122,8 +124,10 @@ 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}
# 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 -

# Undeploy controller
Expand Down
8 changes: 4 additions & 4 deletions config/default/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
commonLabels:
app.kubernetes.io/part-of: keda-operator
app.kubernetes.io/version: main

# 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

resources:
- ../crd
Expand Down
10 changes: 10 additions & 0 deletions config/default/kustomize-config/metadataLabelTransformer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: builtin
kind: LabelTransformer
metadata:
name: metadataLabelTransformer
labels:
app.kubernetes.io/version: main
app.kubernetes.io/part-of: keda-operator
fieldSpecs:
- path: metadata/labels
create: true

0 comments on commit dfdcc5e

Please sign in to comment.