From 2649b4bf745d95eafae8c18fbc81a877079245c9 Mon Sep 17 00:00:00 2001 From: dbarbosa Date: Wed, 13 Dec 2023 20:32:23 -0300 Subject: [PATCH] Add label platform/application to pods Add support to 'app.starlingx.io/component' to be overwritten by user override, with possible values being 'platform' and 'application'. With 'platform' being the default value. This change will also restart the pods if the label changes. Test Plan: PASS: build-pkgs -c -p metrics-server-helm/stx-metrics-server-helm PASS: upload/apply/remove/delete/update metrics-server. PASS: Install metrics-server and check if pods have the label 'app.starlingx.io/component' with the value 'platform'. PASS: Change the value of the isApplicationLabel to true using "system helm-override-update" and check, if after re-applying the app, the label 'app.starlingx.component' changes to application' in the pods. PASS: Use 'system application-apply metrics-server' when there is a change to be applied to 'app.starlingx.component' and verify if the pod is restarted. PASS: If "isApplicationLabel" is updated with a value other than true or false, the label on the pods "app.starlingx.io/component" will not change. Story: 2010612 Task: 49098 Change-Id: I9c732fface93ba426b1a1f0421aefaf8a7a10f0a Signed-off-by: David Barbosa Bastos --- metrics-server-helm/debian/deb_folder/rules | 1 + ...001-Add-sample-app-to-metrics-server.patch | 7 +-- ...d-label-platform-application-to-pods.patch | 49 +++++++++++++++++++ readme.md | 1 + 4 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 metrics-server-helm/files/0002-Add-label-platform-application-to-pods.patch diff --git a/metrics-server-helm/debian/deb_folder/rules b/metrics-server-helm/debian/deb_folder/rules index 90d8bc4..d07a90c 100644 --- a/metrics-server-helm/debian/deb_folder/rules +++ b/metrics-server-helm/debian/deb_folder/rules @@ -15,6 +15,7 @@ override_dh_auto_build: # Apply patch to code cd metrics-server && patch -p1 < ../0001-Add-sample-app-to-metrics-server.patch + cd metrics-server && patch -p1 < ../0002-Add-label-platform-application-to-pods.patch # Create the TGZ file. make metrics-server diff --git a/metrics-server-helm/files/0001-Add-sample-app-to-metrics-server.patch b/metrics-server-helm/files/0001-Add-sample-app-to-metrics-server.patch index 0cb40eb..db2ed0f 100644 --- a/metrics-server-helm/files/0001-Add-sample-app-to-metrics-server.patch +++ b/metrics-server-helm/files/0001-Add-sample-app-to-metrics-server.patch @@ -1,7 +1,7 @@ -From da1d57493657751bc5cce4379f254182e3ea0e73 Mon Sep 17 00:00:00 2001 +From 84565d75db7481edd3c27a29c010afb4fb688b4c Mon Sep 17 00:00:00 2001 From: Luiz Felipe Kina Date: Thu, 21 Sep 2023 15:24:19 -0300 -Subject: [PATCH] Add sample app to metrics-server +Subject: [PATCH 1/2] Add sample app to metrics-server --- templates/sample-app-cluster-role-binding.yml | 16 ++++++++++++ @@ -125,4 +125,5 @@ index fba10aa..b31a5fb 100644 + tag: stx.7.0-v1.0.0 + -- -2.25.1 +2.34.1 + diff --git a/metrics-server-helm/files/0002-Add-label-platform-application-to-pods.patch b/metrics-server-helm/files/0002-Add-label-platform-application-to-pods.patch new file mode 100644 index 0000000..73a29d5 --- /dev/null +++ b/metrics-server-helm/files/0002-Add-label-platform-application-to-pods.patch @@ -0,0 +1,49 @@ +From acb714d1a5b52b7246f616858fa2ee5e44f51289 Mon Sep 17 00:00:00 2001 +From: dbarbosa +Date: Wed, 13 Dec 2023 18:39:15 -0300 +Subject: [PATCH 2/2] Add label platform/application to pods + +Add support to 'app.starlingx.io/component' to be overwritten +by user override, with possible values being 'platform' and +'application'. With 'platform' being the default value. This +change will also restart the pods if the label in namespace +change. +--- + templates/deployment.yaml | 2 ++ + values.yaml | 1 + + 2 files changed, 3 insertions(+) + +diff --git a/templates/deployment.yaml b/templates/deployment.yaml +index 1d656fc..097c55f 100644 +--- a/templates/deployment.yaml ++++ b/templates/deployment.yaml +@@ -21,12 +21,14 @@ spec: + template: + metadata: + labels: ++ app.starlingx.io/component: {{ ternary "application" "platform" .Values.isApplicationLabel}} + {{- include "metrics-server.selectorLabels" . | nindent 8 }} + {{- with .Values.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.podAnnotations }} + annotations: ++ configchecksum: {{ toYaml .Values.isApplicationLabel | sha256sum | trunc 63 }} + {{- toYaml . | nindent 8 }} + {{- end }} + spec: +diff --git a/values.yaml b/values.yaml +index b31a5fb..e6992c9 100644 +--- a/values.yaml ++++ b/values.yaml +@@ -45,6 +45,7 @@ apiService: + # The PEM encoded CA bundle for TLS verification + caBundle: "" + ++isApplicationLabel: false + commonLabels: {} + podLabels: {} + podAnnotations: {} +-- +2.34.1 + diff --git a/readme.md b/readme.md index 4aace28..99748cd 100644 --- a/readme.md +++ b/readme.md @@ -21,6 +21,7 @@ metrics-server-armada-app │ │ └── meta_data.yaml │ └── files │ ├── 0001-Add-sample-app-to-metrics-server.patch +| ├── 0002-Add-label-platform-application-to-pods.patch │ └── Makefile ├── readme.md ├── requirements.txt