From d250c7dc2ce0983bf80cf136988c43bcb7d371db Mon Sep 17 00:00:00 2001 From: Parthtiw710 Date: Mon, 13 Jul 2026 00:43:48 +0530 Subject: [PATCH] feat(pipedv1/kubernetes): support config hash annotation for StatefulSets and DaemonSets Signed-off-by: Parthtiw710 --- .../plugin/kubernetes/deployment/annotate.go | 4 +- .../kubernetes/deployment/annotate_test.go | 152 ++++++++++++++++++ 2 files changed, 153 insertions(+), 3 deletions(-) diff --git a/pkg/app/pipedv1/plugin/kubernetes/deployment/annotate.go b/pkg/app/pipedv1/plugin/kubernetes/deployment/annotate.go index 007c843db9..ef5dab547f 100644 --- a/pkg/app/pipedv1/plugin/kubernetes/deployment/annotate.go +++ b/pkg/app/pipedv1/plugin/kubernetes/deployment/annotate.go @@ -47,12 +47,10 @@ func annotateConfigHash(manifests []provider.Manifest) error { } for _, m := range manifests { - if m.IsDeployment() { + if m.IsDeployment() || m.IsStatefulSet() || m.IsDaemonSet() { if err := annotateConfigHashToWorkload(m, configMaps, secrets); err != nil { return err } - - // TODO: Add support for other workload types, such as StatefulSet, DaemonSet, etc. } } diff --git a/pkg/app/pipedv1/plugin/kubernetes/deployment/annotate_test.go b/pkg/app/pipedv1/plugin/kubernetes/deployment/annotate_test.go index d150ac5983..d9c1bd29ea 100644 --- a/pkg/app/pipedv1/plugin/kubernetes/deployment/annotate_test.go +++ b/pkg/app/pipedv1/plugin/kubernetes/deployment/annotate_test.go @@ -330,6 +330,158 @@ metadata: type: Opaque data: one: "MQ==" +`, + }, + { + name: "StatefulSet config", + manifests: ` +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: canary-by-statefulset-change + labels: + app: canary-by-statefulset-change +spec: + serviceName: "nginx" + replicas: 2 + selector: + matchLabels: + app: canary-by-statefulset-change + template: + metadata: + labels: + app: canary-by-statefulset-change + spec: + containers: + - name: nginx + image: nginx:1.14.2 + volumeMounts: + - name: config + mountPath: /etc/nginx-config + readOnly: true + volumes: + - name: config + configMap: + name: canary-by-statefulset-change +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: canary-by-statefulset-change +data: + two: "2" +`, + expected: ` +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: canary-by-statefulset-change + labels: + app: canary-by-statefulset-change +spec: + serviceName: "nginx" + replicas: 2 + selector: + matchLabels: + app: canary-by-statefulset-change + template: + metadata: + labels: + app: canary-by-statefulset-change + annotations: + pipecd.dev/config-hash: 77ck6gt828 + spec: + containers: + - name: nginx + image: nginx:1.14.2 + volumeMounts: + - name: config + mountPath: /etc/nginx-config + readOnly: true + volumes: + - name: config + configMap: + name: canary-by-statefulset-change +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: canary-by-statefulset-change +data: + two: "2" +`, + }, + { + name: "DaemonSet config", + manifests: ` +apiVersion: apps/v1 +kind: DaemonSet +metadata: + name: canary-by-daemonset-change + labels: + app: canary-by-daemonset-change +spec: + selector: + matchLabels: + app: canary-by-daemonset-change + template: + metadata: + labels: + app: canary-by-daemonset-change + spec: + containers: + - name: fluentd-elasticsearch + image: fluentd:v1.8 + volumeMounts: + - name: config + mountPath: /var/log + volumes: + - name: config + configMap: + name: canary-by-daemonset-change +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: canary-by-daemonset-change +data: + two: "2" +`, + expected: ` +apiVersion: apps/v1 +kind: DaemonSet +metadata: + name: canary-by-daemonset-change + labels: + app: canary-by-daemonset-change +spec: + selector: + matchLabels: + app: canary-by-daemonset-change + template: + metadata: + labels: + app: canary-by-daemonset-change + annotations: + pipecd.dev/config-hash: bm69558hh6 + spec: + containers: + - name: fluentd-elasticsearch + image: fluentd:v1.8 + volumeMounts: + - name: config + mountPath: /var/log + volumes: + - name: config + configMap: + name: canary-by-daemonset-change +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: canary-by-daemonset-change +data: + two: "2" `, }, }