From 977ac7e22aba63f9398e395df9058a8565c1e3f5 Mon Sep 17 00:00:00 2001 From: Dean Roehrich Date: Mon, 8 Jul 2024 11:19:00 -0500 Subject: [PATCH] Add version labels to release manifest Deployment/DaemonSet (#77) Change make-kustomization.sh to add component/version labels only to Deployment/Daemonset in the manifest. By doing only these resources, rather than all resources, we minimize the noise in a manifest update to the gitops repo. If run locally the labels will be: app.kubernetes.io/component: lustre-csi-driver app.kubernetes.io/version: If run from nnf-deploy's "make manifests" the labels will be: app.kubernetes.io/component: lustre-csi-driver app.kubernetes.io/version: app.kubernetes.io/part-of: nnf app.kubernetes.io/nnf-version: Signed-off-by: Dean Roehrich --- hack/make-kustomization.sh | 45 +++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/hack/make-kustomization.sh b/hack/make-kustomization.sh index 56cd3a3..362a298 100755 --- a/hack/make-kustomization.sh +++ b/hack/make-kustomization.sh @@ -29,24 +29,43 @@ then mkdir "$OVERLAY_DIR" fi -cat < "$OVERLAY_DIR"/kustomization.yaml -resources: -- ../$OVERLAY - -commonLabels: - app.kubernetes.io/version: "$TAG" - app.kubernetes.io/component: lustre-csi-driver -EOF +COMPONENT_LABELS=" + - op: add + path: /metadata/labels/app.kubernetes.io~1version + value: "$TAG" + - op: add + path: /metadata/labels/app.kubernetes.io~1component + value: lustre-csi-driver +" +NNF_VER_LABELS="" if [[ -n $NNF_VERSION ]] then - cat <> "$OVERLAY_DIR"/kustomization.yaml - app.kubernetes.io/nnf-version: "$NNF_VERSION" - app.kubernetes.io/part-of: nnf -EOF + NNF_VER_LABELS=" + - op: add + path: /metadata/labels/app.kubernetes.io~1nnf-version + value: "$NNF_VERSION" + - op: add + path: /metadata/labels/app.kubernetes.io~1part-of + value: nnf +" fi -cat <> "$OVERLAY_DIR"/kustomization.yaml +cat < "$OVERLAY_DIR"/kustomization.yaml +resources: +- ../$OVERLAY + +patches: +- target: + kind: Deployment + patch: |- +$COMPONENT_LABELS +$NNF_VER_LABELS +- target: + kind: DaemonSet + patch: |- +$COMPONENT_LABELS +$NNF_VER_LABELS apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization