Skip to content

Commit 50ec13b

Browse files
committed
Make bootstrap user generated password immutable
(cherry picked from commit 2f35544)
1 parent 13c3941 commit 50ec13b

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
@@ -6366,6 +6367,7 @@ type: Opaque
63666367
---
63676368
# Source: redpanda/templates/entry-point.yaml
63686369
apiVersion: v1
6370+
immutable: true
63696371
kind: Secret
63706372
metadata:
63716373
creationTimestamp: null
@@ -16985,6 +16987,7 @@ type: Opaque
1698516987
---
1698616988
# Source: redpanda/templates/entry-point.yaml
1698716989
apiVersion: v1
16990+
immutable: true
1698816991
kind: Secret
1698916992
metadata:
1699016993
creationTimestamp: null
@@ -76956,6 +76959,7 @@ type: Opaque
7695676959
---
7695776960
# Source: redpanda/templates/entry-point.yaml
7695876961
apiVersion: v1
76962+
immutable: true
7695976963
kind: Secret
7696076964
metadata:
7696176965
creationTimestamp: null
@@ -89354,6 +89358,7 @@ type: Opaque
8935489358
---
8935589359
# Source: redpanda/templates/entry-point.yaml
8935689360
apiVersion: v1
89361+
immutable: true
8935789362
kind: Secret
8935889363
metadata:
8935989364
creationTimestamp: null
@@ -94499,6 +94504,7 @@ type: Opaque
9449994504
---
9450094505
# Source: redpanda/templates/entry-point.yaml
9450194506
apiVersion: v1
94507+
immutable: true
9450294508
kind: Secret
9450394509
metadata:
9450494510
creationTimestamp: null
@@ -157581,6 +157587,7 @@ type: Opaque
157581157587
---
157582157588
# Source: redpanda/templates/entry-point.yaml
157583157589
apiVersion: v1
157590+
immutable: true
157584157591
kind: Secret
157585157592
metadata:
157586157593
creationTimestamp: null

0 commit comments

Comments
 (0)