Skip to content

Share the self-signer gate, securityContext and Role rules across the install Job and rotation CronJobs - #691

Open
isaactwong wants to merge 2 commits into
masterfrom
paired-path-c-cronjob-templates-match-job
Open

isaactwong wants to merge 2 commits into
masterfrom
paired-path-c-cronjob-templates-match-job

Conversation

@isaactwong

Copy link
Copy Markdown

In both charts the self-signer install Job, the pre-delete cleaner Job and the two certificate-rotation CronJobs were four hand-written copies of one pod spec, and the copies had drifted. The rotation CronJobs rendered without the pod and container securityContext the install Job sets, so a namespace enforcing Pod Security Admission restricted admitted the install and rejected every rotation pod; the legacy chart's client/node CronJob rendered without the tls.enabled check its own ServiceAccount and Role have; and the rotate Role was a narrower copy of the install Role.

Each chart now defines the gate, both securityContext blocks and the Role rules once in _helpers.tpl (selfcerts.enabled, selfcerts.podSecurityContext, selfcerts.containerSecurityContext, selfcerts.roleRules), and the four workloads plus the self-signer Role, RoleBinding and ServiceAccount templates include them. The install Job, cleaner Job and install Role render byte-for-byte as before; the CronJobs gain the securityContext blocks and the gate, and the rotate Role gains the install Role's remaining rules.

The first commit adds a template test that renders the four workloads and both Roles for each chart and compares them. It passes on master by recording the drift; the second commit flips it to equality, with the securityContext on and off and the gate checked from both sides.

One behavior worth a reviewer's eye: in the operator chart the install Role's unscoped securitycontextconstraints use rule now sits on the permanent rotation ServiceAccount as well (the install ServiceAccount holds it only for the pre-install hook). The CronJobs need an SCC to run as user 1000 on OpenShift, so this mirrors how the install Job already works; scoping the grant with resourceNames would change the install path too and is left to a follow-up.

Fixes #690

🤖 Generated with Claude Code

isaactwong and others added 2 commits October 20, 2026 10:38
The install Job and the two certificate-rotation CronJobs are three
hand-written copies of one pod spec, in both charts. This test renders
them side by side and compares what must agree: the pod and container
securityContext, the TLS gate, and the rules of the Role each runs under.

It currently records the drift. The CronJobs render without either
securityContext block, the legacy chart's client/node CronJob renders
with TLS off while its ServiceAccount and Role do not, and the rotate
Role is a narrower copy of the install Role. The pre-delete cleaner Job
is a fourth copy of the pod spec and still matches the install Job; the
test pins that too so it cannot drift later. The next commit makes the
three share one definition and flips these assertions to equality.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The install Job applied a pod and container securityContext under
selfSigner.securityContext.enabled; the two rotation CronJobs did not.
On a namespace enforcing Pod Security Admission "restricted" the install
succeeded and every rotation pod was rejected, so certificates expired
on schedule. The client/node CronJob also rendered without the
tls.enabled check the Job and its own RBAC objects have, and the rotate
Role was a narrower copy of the install Role (missing the OpenShift
securitycontextconstraints rule in the operator chart).

Each chart now defines the gate, both securityContext blocks and the
Role rules once in _helpers.tpl, and the install Job, the pre-delete
cleaner Job, both CronJobs, both Roles and the self-signer RBAC
templates include them. The install Job and install Role render
byte-for-byte as before. The rotation CronJobs gain the securityContext
blocks and the tls.enabled gate; the rotate Role gains the install
Role's remaining rules. The RoleBinding, ServiceAccount and cleaner Job
edits are one-line gate swaps; their output is unchanged. In the
operator chart the rotation ServiceAccount now holds the
securitycontextconstraints grant permanently.

The pair test now compares all four workloads against the install Job
with the securityContext on and off, checks the client/node CronJob
gate from both sides, and asserts the rules the rotate Role used to
lack.

Fixes #690

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

self-signer rotation CronJobs drift from the install Job (gate, securityContext, RBAC)

1 participant