Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions cockroachdb-legacy/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,20 @@ All notable changes to the CockroachDB Helm chart will be documented in this fil
### Changed
- Updated the self-signer image to `1.11` for operator-managed certificate rotation fixes.

### Fixed
- The self-signer certificate-rotation CronJobs now render with the same pod and container
`securityContext` as the install Job, require `tls.enabled` like the install Job, and the rotation
Role grants the same rules as the install Role. Previously the rotation pods ran without a
securityContext, so namespaces enforcing Pod Security Admission `restricted` rejected them,
rotation never ran and certificates eventually expired.

### Upgrade notes
- On OpenShift, if you granted a SecurityContextConstraint to the self-signer install
ServiceAccount so that it can run as user 1000, grant the same SCC to the rotation
ServiceAccount (`<release>-cockroachdb-rotate-self-signer`), or set
`tls.certs.selfSigner.securityContext.enabled=false`. The rotation CronJobs now set the same
`securityContext` as the install Job.

## [22.0.4] 2026-09-23
### Changed
- Updated the default CockroachDB image version from `v26.3.1` to `v26.3.2`.
Expand Down
48 changes: 48 additions & 0 deletions cockroachdb-legacy/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,54 @@ Define the default values for the certificate selfSigner inputs
{{- printf "%s-client" $base -}}
{{- end -}}

{{/*
The self-signer install Job, the pre-delete cleaner Job and the two rotation CronJobs run the same
image against the same resources. They take their gate, pod security and RBAC from the templates
below so that the four cannot drift apart. The gate also guards the self-signer Role, RoleBinding
and ServiceAccount templates.
*/}}
{{- define "selfcerts.enabled" -}}
{{- if and .Values.tls.enabled .Values.tls.certs.selfSigner.enabled -}}true{{- end -}}
{{- end -}}

{{- define "selfcerts.podSecurityContext" -}}
{{- if .Values.tls.certs.selfSigner.securityContext.enabled -}}
securityContext:
seccompProfile:
type: "RuntimeDefault"
runAsGroup: 1000
runAsUser: 1000
fsGroup: 1000
runAsNonRoot: true
{{- end }}
{{- end -}}

{{- define "selfcerts.containerSecurityContext" -}}
{{- if .Values.tls.certs.selfSigner.securityContext.enabled -}}
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop: ["ALL"]
{{- end }}
{{- end -}}

{{- define "selfcerts.roleRules" -}}
- apiGroups: [""]
resources: ["secrets"]
verbs: ["create", "get", "update", "delete"]
- apiGroups: ["apps"]
resources: ["statefulsets"]
verbs: ["get"]
resourceNames:
- {{ template "cockroachdb.fullname" . }}
- apiGroups: [""]
resources: ["pods"]
verbs: ["delete", "get"]
- apiGroups: [""]
resources: ["configmaps"]
verbs: ["create", "get", "update", "delete"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Can we remove the ConfigMap delete permission and its corresponding test assertion? The self-signer currently creates/updates the CA ConfigMap but does not delete it during rotation or uninstall cleanup.

{{- end -}}

{{- define "selfcerts.minimumCertDuration" -}}
{{- if .Values.tls.certs.selfSigner.minimumCertDuration -}}
{{- print (.Values.tls.certs.selfSigner.minimumCertDuration | trimSuffix "h") -}}
Expand Down
8 changes: 7 additions & 1 deletion cockroachdb-legacy/templates/cronjob-ca-certSelfSigner.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if and .Values.tls.enabled (and .Values.tls.certs.selfSigner.enabled (not .Values.tls.certs.selfSigner.caProvided)) }}
{{- if and (include "selfcerts.enabled" .) (not .Values.tls.certs.selfSigner.caProvided) }}
{{- if .Values.tls.certs.selfSigner.rotateCerts }}
{{- if .Capabilities.APIVersions.Has "batch/v1/CronJob" }}
apiVersion: batch/v1
Expand Down Expand Up @@ -31,6 +31,9 @@ spec:
{{- if and .Values.tls.enabled .Values.tls.selfSigner.image.credentials }}
imagePullSecrets:
- name: {{ template "cockroachdb.fullname" . }}.init-certs.registry
{{- end }}
{{- with include "selfcerts.podSecurityContext" . }}
{{- . | nindent 10 }}
{{- end }}
restartPolicy: Never
{{- with .Values.tls.selfSigner.affinity }}
Expand Down Expand Up @@ -61,6 +64,9 @@ spec:
value: {{ .Release.Namespace }}
- name: CLUSTER_DOMAIN
value: {{ .Values.clusterDomain}}
{{- with include "selfcerts.containerSecurityContext" . }}
{{- . | nindent 12 }}
{{- end }}
serviceAccountName: {{ template "rotatecerts.fullname" . }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if and .Values.tls.certs.selfSigner.enabled .Values.tls.certs.selfSigner.rotateCerts }}
{{- if and (include "selfcerts.enabled" .) .Values.tls.certs.selfSigner.rotateCerts }}
{{- if .Capabilities.APIVersions.Has "batch/v1/CronJob" }}
apiVersion: batch/v1
{{- else }}
Expand Down Expand Up @@ -31,6 +31,9 @@ spec:
imagePullSecrets:
- name: {{ template "cockroachdb.fullname" . }}.init-certs.registry
{{- end }}
{{- with include "selfcerts.podSecurityContext" . }}
{{- . | nindent 10 }}
{{- end }}
restartPolicy: Never
{{- with .Values.tls.selfSigner.affinity }}
affinity: {{- toYaml . | nindent 12 }}
Expand Down Expand Up @@ -73,5 +76,8 @@ spec:
- name: ADDITIONAL_SANS
value: {{ .Values.tls.certs.selfSigner.additionalSANs | join "," | quote }}
{{- end }}
{{- with include "selfcerts.containerSecurityContext" . }}
{{- . | nindent 12 }}
{{- end }}
serviceAccountName: {{ template "rotatecerts.fullname" . }}
{{- end}}
19 changes: 5 additions & 14 deletions cockroachdb-legacy/templates/job-certSelfSigner.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if and .Values.tls.enabled .Values.tls.certs.selfSigner.enabled }}
{{- if include "selfcerts.enabled" . }}
apiVersion: batch/v1
kind: Job
metadata:
Expand Down Expand Up @@ -35,14 +35,8 @@ spec:
imagePullSecrets:
- name: {{ template "cockroachdb.fullname" . }}.init-certs.registry
{{- end }}
{{- if and .Values.tls.certs.selfSigner.securityContext.enabled }}
securityContext:
seccompProfile:
type: "RuntimeDefault"
runAsGroup: 1000
runAsUser: 1000
fsGroup: 1000
runAsNonRoot: true
{{- with include "selfcerts.podSecurityContext" . }}
{{- . | nindent 6 }}
{{- end }}
restartPolicy: Never
{{- with .Values.tls.selfSigner.affinity }}
Expand Down Expand Up @@ -84,11 +78,8 @@ spec:
- name: ADDITIONAL_SANS
value: {{ .Values.tls.certs.selfSigner.additionalSANs | join "," | quote }}
{{- end }}
{{- if and .Values.tls.certs.selfSigner.securityContext.enabled }}
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop: ["ALL"]
{{- with include "selfcerts.containerSecurityContext" . }}
{{- . | nindent 10 }}
{{- end }}
serviceAccountName: {{ template "selfcerts.fullname" . }}
{{- end}}
19 changes: 5 additions & 14 deletions cockroachdb-legacy/templates/job-cleaner.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if and .Values.tls.enabled .Values.tls.certs.selfSigner.enabled }}
{{- if include "selfcerts.enabled" . }}
apiVersion: batch/v1
kind: Job
metadata:
Expand Down Expand Up @@ -31,14 +31,8 @@ spec:
annotations: {{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- if and .Values.tls.certs.selfSigner.securityContext.enabled }}
securityContext:
seccompProfile:
type: "RuntimeDefault"
runAsGroup: 1000
runAsUser: 1000
fsGroup: 1000
runAsNonRoot: true
{{- with include "selfcerts.podSecurityContext" . }}
{{- . | nindent 6 }}
{{- end }}
{{- if and .Values.tls.enabled .Values.tls.selfSigner.image.credentials }}
imagePullSecrets:
Expand All @@ -64,11 +58,8 @@ spec:
env:
- name: STATEFULSET_NAME
value: {{ template "cockroachdb.fullname" . }}
{{- if and .Values.tls.certs.selfSigner.securityContext.enabled }}
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop: ["ALL"]
{{- with include "selfcerts.containerSecurityContext" . }}
{{- . | nindent 10 }}
{{- end }}
serviceAccountName: {{ template "rotatecerts.fullname" . }}
{{- end}}
14 changes: 2 additions & 12 deletions cockroachdb-legacy/templates/role-certRotateSelfSigner.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if and .Values.tls.enabled .Values.tls.certs.selfSigner.enabled }}
{{- if include "selfcerts.enabled" . }}
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
Expand All @@ -13,15 +13,5 @@ metadata:
{{- toYaml . | nindent 4 }}
{{- end }}
rules:
- apiGroups: [""]
resources: ["secrets"]
verbs: ["create", "get", "update", "delete"]
- apiGroups: ["apps"]
resources: ["statefulsets"]
verbs: ["get"]
resourceNames:
- {{ template "cockroachdb.fullname" . }}
- apiGroups: [""]
resources: ["pods"]
verbs: ["delete", "get"]
{{- include "selfcerts.roleRules" . | nindent 2 }}
{{- end }}
17 changes: 2 additions & 15 deletions cockroachdb-legacy/templates/role-certSelfSigner.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if and .Values.tls.enabled .Values.tls.certs.selfSigner.enabled }}
{{- if include "selfcerts.enabled" . }}
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
Expand All @@ -19,18 +19,5 @@ metadata:
{{- toYaml . | nindent 4 }}
{{- end }}
rules:
- apiGroups: [""]
resources: ["secrets"]
verbs: ["create", "get", "update", "delete"]
- apiGroups: ["apps"]
resources: ["statefulsets"]
verbs: ["get"]
resourceNames:
- {{ template "cockroachdb.fullname" . }}
- apiGroups: [""]
resources: ["pods"]
verbs: ["delete", "get"]
- apiGroups: [""]
resources: ["configmaps"]
verbs: ["create", "get", "update", "delete"]
{{- include "selfcerts.roleRules" . | nindent 2 }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if and .Values.tls.enabled .Values.tls.certs.selfSigner.enabled }}
{{- if include "selfcerts.enabled" . }}
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if and .Values.tls.enabled .Values.tls.certs.selfSigner.enabled }}
{{- if include "selfcerts.enabled" . }}
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if and .Values.tls.enabled .Values.tls.certs.selfSigner.enabled }}
{{- if include "selfcerts.enabled" . }}
{{ template "cockroachdb.tls.certs.selfSigner.validation" . }}
kind: ServiceAccount
apiVersion: v1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if and .Values.tls.enabled .Values.tls.certs.selfSigner.enabled }}
{{- if include "selfcerts.enabled" . }}
{{ template "cockroachdb.tls.certs.selfSigner.validation" . }}
kind: ServiceAccount
apiVersion: v1
Expand Down
7 changes: 7 additions & 0 deletions cockroachdb-operator/charts/cockroachdb/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
leaving the CA ConfigMap stale, and attempting StatefulSet restarts in deployments
that do not use StatefulSets.
- Updated the self-signer image to `1.11`, which includes these fixes.
- The self-signer certificate-rotation CronJobs now render with the same pod and container
`securityContext` as the install Job, and the rotation Role grants the same rules as the install
Role, including the OpenShift `securitycontextconstraints` rule. Previously the rotation pods ran
without a securityContext, so namespaces enforcing Pod Security Admission `restricted` rejected
them, rotation never ran and certificates eventually expired. The rotation ServiceAccount now
holds the `securitycontextconstraints` `use` grant permanently, as the install ServiceAccount
does for the duration of the pre-install hook.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Could we shorten the changelog to “Fixed permission drift between self-signer install and rotation jobs by sharing their RBAC rules”?


### Upgrade notes
- Node certificates rotated by affected self-signer versions may be missing join-service
Expand Down
51 changes: 51 additions & 0 deletions cockroachdb-operator/charts/cockroachdb/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,57 @@ Define the default values for the certificate selfSigner inputs
{{- printf "%s-client" $base -}}
{{- end -}}

{{/*
The self-signer install Job, the pre-delete cleaner Job and the two rotation CronJobs run the same
image against the same resources. They take their gate, pod security and RBAC from the templates
below so that the four cannot drift apart. The gate also guards the self-signer Role, RoleBinding
and ServiceAccount templates. The securitycontextconstraints rule is specific to this chart; the
legacy chart grants none.
*/}}
{{- define "selfcerts.enabled" -}}
{{- if and .Values.cockroachdb.tls.enabled .Values.cockroachdb.tls.selfSigner.enabled -}}true{{- end -}}
{{- end -}}

{{- define "selfcerts.podSecurityContext" -}}
{{- if .Values.cockroachdb.tls.selfSigner.securityContext.enabled -}}
securityContext:
seccompProfile:
type: "RuntimeDefault"
runAsGroup: 1000
runAsUser: 1000
fsGroup: 1000
runAsNonRoot: true
{{- end }}
{{- end -}}

{{- define "selfcerts.containerSecurityContext" -}}
{{- if .Values.cockroachdb.tls.selfSigner.securityContext.enabled -}}
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop: ["ALL"]
{{- end }}
{{- end -}}

{{- define "selfcerts.roleRules" -}}
- apiGroups: [""]
resources: ["secrets"]
verbs: ["create", "get", "update", "delete"]
- apiGroups: ["apps"]
resources: ["statefulsets"]
verbs: ["get"]
resourceNames:
- {{ template "cockroachdb.fullname" . }}
- apiGroups: [""]
resources: ["pods"]
verbs: ["delete", "get"]
- apiGroups: [""]
resources: ["configmaps"]
verbs: ["create", "get", "update", "delete"]
- apiGroups: [ "security.openshift.io" ]
resources: [ "securitycontextconstraints" ]
verbs: [ "use" ]
{{- end -}}

{{- define "selfcerts.minimumCertDuration" -}}
{{- if .Values.cockroachdb.tls.selfSigner.minimumCertDuration -}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if and .Values.cockroachdb.tls.enabled (and .Values.cockroachdb.tls.selfSigner.enabled (not .Values.cockroachdb.tls.selfSigner.caProvided)) }}
{{- if and (include "selfcerts.enabled" .) (not .Values.cockroachdb.tls.selfSigner.caProvided) }}
{{- if .Values.cockroachdb.tls.selfSigner.rotateCerts }}
apiVersion: batch/v1
kind: CronJob
Expand Down Expand Up @@ -27,6 +27,9 @@ spec:
{{- if and .Values.cockroachdb.tls.enabled .Values.cockroachdb.tls.selfSigner.image.credentials }}
imagePullSecrets:
- name: {{ template "cockroachdb.fullname" . }}.init-certs.registry
{{- end }}
{{- with include "selfcerts.podSecurityContext" . }}
{{- . | nindent 10 }}
{{- end }}
restartPolicy: Never
{{- with .Values.cockroachdb.tls.selfSigner.affinity }}
Expand Down Expand Up @@ -58,6 +61,9 @@ spec:
value: {{ .Release.Namespace }}
- name: CLUSTER_DOMAIN
value: {{ .Values.cockroachdb.clusterDomain}}
{{- with include "selfcerts.containerSecurityContext" . }}
{{- . | nindent 14 }}
{{- end }}
serviceAccountName: {{ template "rotatecerts.fullname" . }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if and .Values.cockroachdb.tls.selfSigner.enabled .Values.cockroachdb.tls.selfSigner.rotateCerts }}
{{- if and (include "selfcerts.enabled" .) .Values.cockroachdb.tls.selfSigner.rotateCerts }}
apiVersion: batch/v1
kind: CronJob
metadata:
Expand Down Expand Up @@ -27,6 +27,9 @@ spec:
imagePullSecrets:
- name: {{ template "cockroachdb.fullname" . }}.init-certs.registry
{{- end }}
{{- with include "selfcerts.podSecurityContext" . }}
{{- . | nindent 10 }}
{{- end }}
restartPolicy: Never
{{- with .Values.cockroachdb.tls.selfSigner.affinity }}
affinity: {{- toYaml . | nindent 12 }}
Expand Down Expand Up @@ -70,5 +73,8 @@ spec:
- name: ADDITIONAL_SANS
value: {{ .Values.cockroachdb.tls.selfSigner.additionalSANs | join "," | quote }}
{{- end }}
{{- with include "selfcerts.containerSecurityContext" . }}
{{- . | nindent 14 }}
{{- end }}
serviceAccountName: {{ template "rotatecerts.fullname" . }}
{{- end}}
Loading
Loading