Skip to content

Commit 6086bf8

Browse files
committed
Make bootstrap user generated password immutable
(cherry picked from commit 2f35544)
1 parent 51eecd7 commit 6086bf8

File tree

4 files changed

+17
-2
lines changed

4 files changed

+17
-2
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
project: charts/redpanda
2+
kind: Changed
3+
body: The generated bootstrap user password secret is now immutable. It was always intended to be a single-time generation, and now that is enforced at the Kubernetes API layer.
4+
time: 2025-06-18T18:28:09.325375-04:00

charts/redpanda/secrets.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,8 @@ func SecretBootstrapUser(dot *helmette.Dot) *corev1.Secret {
213213
// that a password be explicitly set?
214214
// See also: https://github.com/redpanda-data/helm-charts/issues/1596
215215
if existing, ok := helmette.Lookup[corev1.Secret](dot, dot.Release.Namespace, secretName); ok {
216+
// make any existing secret immutable
217+
existing.Immutable = ptr.To(true)
216218
return existing
217219
}
218220

@@ -233,7 +235,8 @@ func SecretBootstrapUser(dot *helmette.Dot) *corev1.Secret {
233235
Namespace: dot.Release.Namespace,
234236
Labels: FullLabels(dot),
235237
},
236-
Type: corev1.SecretTypeOpaque,
238+
Immutable: ptr.To(true),
239+
Type: corev1.SecretTypeOpaque,
237240
StringData: map[string]string{
238241
"password": password,
239242
},

charts/redpanda/templates/_secrets.go.tpl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@
101101
{{- $existing_4 := (index $_209_existing_4_ok_5 0) -}}
102102
{{- $ok_5 := (index $_209_existing_4_ok_5 1) -}}
103103
{{- if $ok_5 -}}
104+
{{- $_ := (set $existing_4 "immutable" true) -}}
104105
{{- $_is_returning = true -}}
105106
{{- (dict "r" $existing_4) | toJson -}}
106107
{{- break -}}
@@ -111,7 +112,7 @@
111112
{{- $password = $userPassword -}}
112113
{{- end -}}
113114
{{- $_is_returning = true -}}
114-
{{- (dict "r" (mustMergeOverwrite (dict "metadata" (dict "creationTimestamp" (coalesce nil))) (mustMergeOverwrite (dict) (dict "apiVersion" "v1" "kind" "Secret")) (dict "metadata" (mustMergeOverwrite (dict "creationTimestamp" (coalesce nil)) (dict "name" $secretName "namespace" $dot.Release.Namespace "labels" (get (fromJson (include "redpanda.FullLabels" (dict "a" (list $dot)))) "r"))) "type" "Opaque" "stringData" (dict "password" $password)))) | toJson -}}
115+
{{- (dict "r" (mustMergeOverwrite (dict "metadata" (dict "creationTimestamp" (coalesce nil))) (mustMergeOverwrite (dict) (dict "apiVersion" "v1" "kind" "Secret")) (dict "metadata" (mustMergeOverwrite (dict "creationTimestamp" (coalesce nil)) (dict "name" $secretName "namespace" $dot.Release.Namespace "labels" (get (fromJson (include "redpanda.FullLabels" (dict "a" (list $dot)))) "r"))) "immutable" true "type" "Opaque" "stringData" (dict "password" $password)))) | toJson -}}
115116
{{- break -}}
116117
{{- end -}}
117118
{{- end -}}

charts/redpanda/testdata/template-cases.golden.txtar

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4910,6 +4910,7 @@ type: Opaque
49104910
---
49114911
# Source: redpanda/templates/entry-point.yaml
49124912
apiVersion: v1
4913+
immutable: true
49134914
kind: Secret
49144915
metadata:
49154916
creationTimestamp: null
@@ -6368,6 +6369,7 @@ type: Opaque
63686369
---
63696370
# Source: redpanda/templates/entry-point.yaml
63706371
apiVersion: v1
6372+
immutable: true
63716373
kind: Secret
63726374
metadata:
63736375
creationTimestamp: null
@@ -16989,6 +16991,7 @@ type: Opaque
1698916991
---
1699016992
# Source: redpanda/templates/entry-point.yaml
1699116993
apiVersion: v1
16994+
immutable: true
1699216995
kind: Secret
1699316996
metadata:
1699416997
creationTimestamp: null
@@ -76950,6 +76953,7 @@ type: Opaque
7695076953
---
7695176954
# Source: redpanda/templates/entry-point.yaml
7695276955
apiVersion: v1
76956+
immutable: true
7695376957
kind: Secret
7695476958
metadata:
7695576959
creationTimestamp: null
@@ -89350,6 +89354,7 @@ type: Opaque
8935089354
---
8935189355
# Source: redpanda/templates/entry-point.yaml
8935289356
apiVersion: v1
89357+
immutable: true
8935389358
kind: Secret
8935489359
metadata:
8935589360
creationTimestamp: null
@@ -94497,6 +94502,7 @@ type: Opaque
9449794502
---
9449894503
# Source: redpanda/templates/entry-point.yaml
9449994504
apiVersion: v1
94505+
immutable: true
9450094506
kind: Secret
9450194507
metadata:
9450294508
creationTimestamp: null
@@ -157685,6 +157691,7 @@ type: Opaque
157685157691
---
157686157692
# Source: redpanda/templates/entry-point.yaml
157687157693
apiVersion: v1
157694+
immutable: true
157688157695
kind: Secret
157689157696
metadata:
157690157697
creationTimestamp: null

0 commit comments

Comments
 (0)