Skip to content

Commit a370b00

Browse files
committed
Add Kubernetes secure bootstrap documentation
Add documentation for auth.sasl.bootstrapUser configuration to enable secure by default cluster deployments with authentication enforced from the first startup. Changes: - Add secure bootstrap section to k-production-deployment.adoc showing quick example configuration - Add comprehensive bootstrap superuser section to authentication.adoc partial with when to use, configuration steps, verification, usage examples, and security best practices - Include note about secretRef requirement discovered during testing Tested on kind cluster with both default and custom bootstrap user configurations. Verified bootstrap user creation, ACL management, and new user functionality. Closes: DOC-242
1 parent 1d14295 commit a370b00

2 files changed

Lines changed: 217 additions & 0 deletions

File tree

modules/deploy/pages/redpanda/kubernetes/k-production-deployment.adoc

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,32 @@ auth:
545545

546546
See also: xref:manage:kubernetes/security/authentication/k-authentication.adoc[]
547547

548+
=== Secure bootstrap
549+
550+
To deploy a "secure by default" cluster with authentication enabled from the moment it starts, configure a bootstrap user using `auth.sasl.bootstrapUser`. This creates the initial superuser at cluster formation time, before any client connections are accepted.
551+
552+
This approach is recommended for production deployments where you want to ensure authentication is enforced immediately, without a window where the cluster is accessible without credentials.
553+
554+
[source,yaml]
555+
----
556+
auth:
557+
sasl:
558+
enabled: true
559+
mechanism: "SCRAM-SHA-512"
560+
secretRef: "sasl-password-secret"
561+
users: []
562+
bootstrapUser:
563+
name: "kubernetes-controller" # Optional, defaults to "kubernetes-controller"
564+
secretKeyRef:
565+
name: "bootstrap-user-secret"
566+
key: "password"
567+
mechanism: "SCRAM-SHA-256" # Options: SCRAM-SHA-256 or SCRAM-SHA-512
568+
----
569+
570+
The bootstrap user is automatically added to the `superusers` list and can be used to create additional users and configure ACLs after the cluster is deployed.
571+
572+
See also: xref:manage:kubernetes/security/authentication/k-authentication.adoc#bootstrap[Bootstrap superuser at cluster formation]
573+
548574
=== Resources
549575

550576
By default, the resources allocated to Redpanda are for a development environment. In a production cluster, the resources you allocate should be proportionate to your machine type. You should determine and set these values before deploying the cluster.

modules/manage/partials/authentication.adoc

Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,197 @@ helm upgrade --install redpanda redpanda/redpanda --namespace <namespace> --crea
396396
====
397397
--
398398
======
399+
400+
[[bootstrap]]
401+
=== Bootstrap superuser at cluster formation
402+
403+
When deploying a new Redpanda cluster with authentication enabled, you can configure a bootstrap user that is created automatically at cluster formation time. This ensures that your cluster is "secure by default" with authentication enforced from the first startup, without any window where the cluster is accessible without credentials.
404+
405+
The `auth.sasl.bootstrapUser` configuration creates an initial superuser before the cluster accepts client connections. This user is automatically added to the `superusers` list and can be used to create additional users and configure ACLs.
406+
407+
==== When to use bootstrap user
408+
409+
Use the bootstrap user configuration when:
410+
411+
- Deploying a new cluster with authentication enabled from the start
412+
- Automating cluster deployments where manual user creation is not feasible
413+
- Ensuring security compliance requirements for "secure by default" configuration
414+
- Following the principle of least privilege by eliminating any unauthenticated access window
415+
416+
NOTE: The bootstrap user is only created on the first startup of the cluster. The configuration is ignored on subsequent restarts. To create additional users after the cluster is running, use `rpk security user create` or update the `auth.sasl.users` list.
417+
418+
==== Configure bootstrap user
419+
420+
. Create a Kubernetes Secret to store the bootstrap user password:
421+
+
422+
[,bash]
423+
----
424+
kubectl --namespace <namespace> create secret generic bootstrap-user-secret \
425+
--from-literal=password='<your-secure-password>'
426+
----
427+
+
428+
TIP: Generate a strong random password using a tool like `openssl rand -base64 32` or your organization's password management system.
429+
+
430+
When using `auth.sasl.secretRef` with an empty `users` list (as shown in the examples below), you must also create the Secret referenced by `secretRef`, even if it contains no user data:
431+
+
432+
[,bash]
433+
----
434+
kubectl --namespace <namespace> create secret generic redpanda-superusers \
435+
--from-literal=superusers.txt=""
436+
----
437+
+
438+
This Secret is required by the Helm chart when `secretRef` is specified, regardless of whether the `users` list is empty.
439+
440+
. Configure the bootstrap user in your Helm values:
441+
+
442+
[tabs]
443+
======
444+
Operator::
445+
+
446+
--
447+
.`redpanda-cluster.yaml`
448+
[,yaml,lines=10-16]
449+
----
450+
apiVersion: cluster.redpanda.com/v1alpha2
451+
kind: Redpanda
452+
metadata:
453+
name: redpanda
454+
spec:
455+
chartRef: {}
456+
clusterSpec:
457+
auth:
458+
sasl:
459+
enabled: true
460+
secretRef: redpanda-superusers
461+
users: []
462+
bootstrapUser:
463+
name: "kubernetes-controller" <1>
464+
secretKeyRef:
465+
name: "bootstrap-user-secret"
466+
key: "password"
467+
mechanism: "SCRAM-SHA-256" <2>
468+
----
469+
<1> Optional. Defaults to `kubernetes-controller` if not specified. This is the username that will be created.
470+
<2> Optional. The SASL/SCRAM authentication mechanism. Valid values are `SCRAM-SHA-256` or `SCRAM-SHA-512`. Defaults to `SCRAM-SHA-256`.
471+
472+
```bash
473+
kubectl apply -f redpanda-cluster.yaml --namespace <namespace>
474+
```
475+
476+
--
477+
Helm::
478+
+
479+
--
480+
[tabs]
481+
====
482+
--values::
483+
+
484+
.`enable-sasl-with-bootstrap.yaml`
485+
[,yaml,lines=3-11]
486+
----
487+
auth:
488+
sasl:
489+
enabled: true
490+
secretRef: redpanda-superusers
491+
users: []
492+
bootstrapUser:
493+
name: "kubernetes-controller" <1>
494+
secretKeyRef:
495+
name: "bootstrap-user-secret"
496+
key: "password"
497+
mechanism: "SCRAM-SHA-256" <2>
498+
----
499+
<1> Optional. Defaults to `kubernetes-controller` if not specified. This is the username that will be created.
500+
<2> Optional. The SASL/SCRAM authentication mechanism. Valid values are `SCRAM-SHA-256` or `SCRAM-SHA-512`. Defaults to `SCRAM-SHA-256`.
501+
+
502+
```bash
503+
helm upgrade --install redpanda redpanda/redpanda --namespace <namespace> --create-namespace \
504+
--values enable-sasl-with-bootstrap.yaml
505+
```
506+
507+
--set::
508+
+
509+
[,bash,lines=2-6]
510+
----
511+
helm upgrade --install redpanda redpanda/redpanda --namespace <namespace> --create-namespace \
512+
--set auth.sasl.enabled=true \
513+
--set auth.sasl.secretRef=redpanda-superusers \
514+
--set auth.sasl.bootstrapUser.name=kubernetes-controller \
515+
--set auth.sasl.bootstrapUser.secretKeyRef.name=bootstrap-user-secret \
516+
--set auth.sasl.bootstrapUser.secretKeyRef.key=password \
517+
--set auth.sasl.bootstrapUser.mechanism=SCRAM-SHA-256
518+
----
519+
520+
====
521+
--
522+
======
523+
524+
. Verify that the bootstrap user was created successfully:
525+
+
526+
[,bash]
527+
----
528+
kubectl --namespace <namespace> exec -it redpanda-0 -- \
529+
rpk security user list \
530+
-X user=kubernetes-controller \
531+
-X pass='<your-secure-password>' \
532+
-X sasl.mechanism=SCRAM-SHA-256
533+
----
534+
+
535+
Expected output:
536+
+
537+
[.no-copy]
538+
----
539+
USERNAME
540+
kubernetes-controller
541+
----
542+
543+
==== Use the bootstrap user
544+
545+
After the cluster is deployed with the bootstrap user, you can use these credentials to:
546+
547+
. Create additional SCRAM users:
548+
+
549+
[,bash]
550+
----
551+
kubectl --namespace <namespace> exec -it redpanda-0 -- \
552+
rpk security user create <new-username> \
553+
-p '<new-password>' \
554+
--mechanism SCRAM-SHA-256 \
555+
-X user=kubernetes-controller \
556+
-X pass='<bootstrap-password>' \
557+
-X sasl.mechanism=SCRAM-SHA-256
558+
----
559+
560+
. Create ACLs to grant permissions:
561+
+
562+
[,bash]
563+
----
564+
kubectl --namespace <namespace> exec -it redpanda-0 -- \
565+
rpk security acl create --allow-principal User:<new-username> \
566+
--operation all \
567+
--topic <topic-name> \
568+
-X user=kubernetes-controller \
569+
-X pass='<bootstrap-password>' \
570+
-X sasl.mechanism=SCRAM-SHA-256
571+
----
572+
573+
==== Combine with bootstrap configuration
574+
575+
For complete "secure by default" configuration, combine the bootstrap user with xref:deploy:redpanda/manual/production/production-deployment.adoc#configure-a-bootstrap-file[cluster bootstrap configuration] to set `admin_api_require_auth: true` and other security settings at cluster formation time.
576+
577+
The operator automatically manages the `RP_BOOTSTRAP_USER` environment variable based on your `auth.sasl.bootstrapUser` configuration. This environment variable is read by Redpanda only on the first startup to create the initial user.
578+
579+
[NOTE]
580+
====
581+
Security best practices:
582+
583+
- Use strong, randomly generated passwords stored in Kubernetes Secrets
584+
- The bootstrap user has full superuser privileges - use it only for initial setup
585+
- Create dedicated users with appropriate ACLs for applications
586+
- Consider rotating the bootstrap user password after initial cluster setup is complete
587+
- Document the bootstrap user credentials in your organization's secret management system
588+
====
589+
399590
endif::[]
400591

401592
ifndef::env-kubernetes[]

0 commit comments

Comments
 (0)