Skip to content

Commit b150ffd

Browse files
committed
Make bootstrap user generated password immutable
(cherry picked from commit 2f35544)
1 parent 5f974be commit b150ffd

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
@@ -211,6 +211,8 @@ func SecretBootstrapUser(dot *helmette.Dot) *corev1.Secret {
211211
// that a password be explicitly set?
212212
// See also: https://github.com/redpanda-data/helm-charts/issues/1596
213213
if existing, ok := helmette.Lookup[corev1.Secret](dot, dot.Release.Namespace, secretName); ok {
214+
// make any existing secret immutable
215+
existing.Immutable = ptr.To(true)
214216
return existing
215217
}
216218

@@ -231,7 +233,8 @@ func SecretBootstrapUser(dot *helmette.Dot) *corev1.Secret {
231233
Namespace: dot.Release.Namespace,
232234
Labels: FullLabels(dot),
233235
},
234-
Type: corev1.SecretTypeOpaque,
236+
Immutable: ptr.To(true),
237+
Type: corev1.SecretTypeOpaque,
235238
StringData: map[string]string{
236239
"password": password,
237240
},

charts/redpanda/templates/_secrets.go.tpl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@
9999
{{- $existing_4 := (index $_207_existing_4_ok_5 0) -}}
100100
{{- $ok_5 := (index $_207_existing_4_ok_5 1) -}}
101101
{{- if $ok_5 -}}
102+
{{- $_ := (set $existing_4 "immutable" true) -}}
102103
{{- $_is_returning = true -}}
103104
{{- (dict "r" $existing_4) | toJson -}}
104105
{{- break -}}
@@ -109,7 +110,7 @@
109110
{{- $password = $userPassword -}}
110111
{{- end -}}
111112
{{- $_is_returning = true -}}
112-
{{- (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 -}}
113+
{{- (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 -}}
113114
{{- break -}}
114115
{{- end -}}
115116
{{- end -}}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4883,6 +4883,7 @@ type: Opaque
48834883
---
48844884
# Source: redpanda/templates/entry-point.yaml
48854885
apiVersion: v1
4886+
immutable: true
48864887
kind: Secret
48874888
metadata:
48884889
creationTimestamp: null
@@ -6330,6 +6331,7 @@ type: Opaque
63306331
---
63316332
# Source: redpanda/templates/entry-point.yaml
63326333
apiVersion: v1
6334+
immutable: true
63336335
kind: Secret
63346336
metadata:
63356337
creationTimestamp: null
@@ -16667,6 +16669,7 @@ type: Opaque
1666716669
---
1666816670
# Source: redpanda/templates/entry-point.yaml
1666916671
apiVersion: v1
16672+
immutable: true
1667016673
kind: Secret
1667116674
metadata:
1667216675
creationTimestamp: null
@@ -75633,6 +75636,7 @@ type: Opaque
7563375636
---
7563475637
# Source: redpanda/templates/entry-point.yaml
7563575638
apiVersion: v1
75639+
immutable: true
7563675640
kind: Secret
7563775641
metadata:
7563875642
creationTimestamp: null
@@ -88973,6 +88977,7 @@ type: Opaque
8897388977
---
8897488978
# Source: redpanda/templates/entry-point.yaml
8897588979
apiVersion: v1
88980+
immutable: true
8897688981
kind: Secret
8897788982
metadata:
8897888983
creationTimestamp: null
@@ -92337,6 +92342,7 @@ type: Opaque
9233792342
---
9233892343
# Source: redpanda/templates/entry-point.yaml
9233992344
apiVersion: v1
92345+
immutable: true
9234092346
kind: Secret
9234192347
metadata:
9234292348
creationTimestamp: null
@@ -153891,6 +153897,7 @@ type: Opaque
153891153897
---
153892153898
# Source: redpanda/templates/entry-point.yaml
153893153899
apiVersion: v1
153900+
immutable: true
153894153901
kind: Secret
153895153902
metadata:
153896153903
creationTimestamp: null

0 commit comments

Comments
 (0)