From ee391a7b8d9e78dc5a1634501c2ff837946393ad Mon Sep 17 00:00:00 2001 From: Unchained Date: Sat, 7 Mar 2026 11:01:04 +0200 Subject: [PATCH] feat: add deployment-metadata configmap to trigger pod restarts on git changes --- k8s/deployment-nodejs.yaml | 8 ++++---- k8s/kustomization.yaml | 16 +++++++++++++--- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/k8s/deployment-nodejs.yaml b/k8s/deployment-nodejs.yaml index ba818f6..9f16fe3 100644 --- a/k8s/deployment-nodejs.yaml +++ b/k8s/deployment-nodejs.yaml @@ -18,10 +18,6 @@ spec: metadata: labels: app: storefront - annotations: - # Flux will substitute this with the actual git revision - # Changing this annotation forces pod restart on git updates - gitRevision: ${GIT_REVISION:-unknown} spec: initContainers: - name: clone @@ -120,6 +116,10 @@ spec: - start ports: - containerPort: 3000 + envFrom: + - configMapRef: + name: deployment-metadata + optional: true env: - name: NODE_ENV value: "production" diff --git a/k8s/kustomization.yaml b/k8s/kustomization.yaml index ebb3f6f..b269891 100644 --- a/k8s/kustomization.yaml +++ b/k8s/kustomization.yaml @@ -1,6 +1,16 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: -- deployment-nodejs.yaml -- service.yaml -- ingress.yaml + - deployment-nodejs.yaml + - service.yaml + - ingress.yaml + +# Generate a ConfigMap with git revision info +# This ConfigMap changes on each Flux reconciliation, triggering pod restarts +configMapGenerator: + - name: deployment-metadata + literals: + - GIT_REVISION=${GIT_REVISION} + - DEPLOY_TIME=${DEPLOY_TIME} + options: + disableNameSuffixHash: false # Changing hash forces pod restart