feat: mount server/peer cert secrets into the etcd container#375
Conversation
The server and peer Certificate secrets are already provisioned and their Volumes are added to the StatefulSet pod spec when spec.tls is set, but the etcd container never mounts them, so the certs are invisible to etcd. Add VolumeMounts on the etcd container for the server and peer cert secrets (/etc/etcd/server-tls/ and /etc/etcd/peer-tls/), gated on spec.tls != nil and appended independently of StorageSpec so a TLS cluster without persistent storage still receives the mounts. The data-dir mount in the StorageSpec branch now appends rather than assigns, preserving the cert mounts when both are set. This is a safe no-op without the TLS flags (etcd ignores unused files) and is the first step of wiring TLS into the etcd data path; the flags that reference these paths land in a follow-up. Note: the StatefulSet pod template is immutable for existing clusters, so this takes effect for new or recreated clusters; TLS is a create-time property and a live cleartext cluster should be migrated to a new TLS cluster, not flipped in place. Refs etcd-io#371 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Xavier Lange <xrlange@gmail.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: xrl The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @xrl. Thanks for your PR. I'm waiting for a etcd-io member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
Superseding this PR. The TLS work was reshaped into independent |
What
Mount the already-provisioned server and peer cert secrets into the etcd container.
When
spec.tlsis set, the operator already provisions the server/peerCertificates and adds their secretVolumes to the StatefulSet pod spec(
createOrPatchStatefulSet). However, the etcd container never mounts thosevolumes, so the certificates are present in the pod spec but invisible to
etcd. This PR adds the missing
VolumeMounts.Change
VolumeMounts on the etcd container for the server and peer cert secrets:server-secret→/etc/etcd/server-tls/peer-secret→/etc/etcd/peer-tls/spec.tls != nil, and appended independently ofStorageSpecsoa TLS cluster without persistent storage still receives the cert mounts.
StorageSpec != nilbranch now appendsrather than assigns the
VolumeMountsslice, so the cert mounts are preservedwhen both TLS and storage are configured.
Volumenames; paths are factored intoconstants so the follow-up TLS-flags change references exactly the same paths.
Why this is safe / why now
Mounting cert files with no TLS flags is a no-op: etcd ignores files it is
not told to use. This keeps the change independently shippable and the cluster
always bootable. It is the first step of wiring TLS into the etcd data path; the
flags that consume these mount paths (
--cert-file,--peer-cert-file, …,plus the
https://scheme flip) land in a separate follow-up PR so each stepstays independently reviewable.
Migration note
The StatefulSet pod template is immutable for existing clusters, so this takes
effect for new or recreated clusters. TLS is a create-time property — a
running cleartext cluster should be migrated to a fresh TLS cluster rather than
flipped in place.
Test
Extended the controller unit tests with
TestCreateOrPatchStatefulSetTLSCertMounts,which renders the StatefulSet through the real
createOrPatchStatefulSetpath(controller-runtime fake client) and asserts both cert
VolumeMounts are presentwith the correct names and mount paths when
spec.tls != nil, absent when nil,and that the data-dir mount coexists with the cert mounts when
StorageSpecisalso set. Verified the test fails against the unmodified code and passes after
the change.
Refs #371
Related work — etcd TLS data-path enablement
The operator provisions cert-manager certificates but currently runs etcd in cleartext. This PR is one step of a small, dependency-ordered series wiring TLS through the data path (
→marks this PR):*tls.Configthrough the operator's etcd client