Skip to content

tests: add CA rotation integration test and manual testing tools#21158

Open
aaomidi wants to merge 3 commits intoetcd-io:mainfrom
aaomidi:ca-reload-tests
Open

tests: add CA rotation integration test and manual testing tools#21158
aaomidi wants to merge 3 commits intoetcd-io:mainfrom
aaomidi:ca-reload-tests

Conversation

@aaomidi
Copy link

@aaomidi aaomidi commented Jan 18, 2026

Summary

Add integration test that validates live CA rotation without cluster restart. Also add manual testing infrastructure in hack/mtls/.

Changes

Integration test (tests/integration/v3_ca_rotation_test.go):

  • Phase 1: Start cluster with CA1, verify operations work
  • Phase 2: Add CA2 to trust bundle, verify CA2-signed clients work
  • Phase 3: Rotate certs to CA2, remove CA1 from trust bundle
  • Phase 4: Verify CA1-signed clients are rejected

Manual testing (hack/mtls/):

  • test-rotation.sh: 5-phase rotation test with 4-node cluster
  • Makefile: Certificate generation using cfssl
  • Procfile: goreman-based cluster configuration
  • README.md: Usage documentation

Background

This PR is a split of #21074 into smaller, reviewable pieces as requested by maintainers.

Stacking

This PR is part of a stacked PR series for CA hot-reload support (issue #11555):

  1. tlsutil: add CAReloader for dynamic CA certificate reloading #21156 - tlsutil: add CAReloadermust be merged first
  2. transport,embed: integrate CA hot-reload support #21157 - transport,embed: integrate CA hot-reload supportmust be merged second
  3. This PR - tests: add CA rotation integration test

Please review #21156 and #21157 first.


Part 3 of 3 for CA hot-reload support.
Replaces #21074 (split into smaller PRs)
Fixes #11555

Signed-off-by: Amir Omidi amir@aaomidi.com

@k8s-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: aaomidi
Once this PR has been reviewed and has the lgtm label, please assign ahrtr for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot
Copy link

Hi @aaomidi. 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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions 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.

Add CAReloader that polls CA files and updates the certificate pool
when changes are detected (using SHA256 hashing). This enables
zero-downtime CA rotation for mTLS clusters.

Key changes:
- Add CAReloader struct with Start/Stop lifecycle management
- Use sync.RWMutex for thread-safe pool access
- Graceful fallback: invalid CA files keep using cached pool
- Add Prometheus metrics for reload operations

Part 1 of CA hot-reload support (issue etcd-io#11555).

Signed-off-by: Amir Omidi <amir@aaomidi.com>
Integrate CAReloader into the transport layer for both server and
client TLS configurations. Add server flags to enable the feature.

Transport changes:
- Add ReloadTrustedCA and CAReloadInterval fields to TLSInfo
- Server: use VerifyConnection callback with dynamic CA pool
- Client: use DialTLSContext to inject fresh RootCAs per connection
- Add caReloaderTracker for proper cleanup on shutdown

Server changes:
- Add --peer-tls-reload-ca flag
- Add --client-tls-reload-ca flag
- Add --tls-ca-reload-interval flag (default 10s)
- Wire up cleanup in Etcd.Close()

The feature is disabled by default and must be explicitly enabled.

Part 2 of CA hot-reload support (issue etcd-io#11555).

Signed-off-by: Amir Omidi <amir@aaomidi.com>
Add integration test that validates live CA rotation without cluster
restart. Also add manual testing infrastructure in hack/mtls/.

Integration test covers:
- Starting cluster with CA1
- Adding CA2 to trust bundle
- Removing CA1 and verifying rejection

Manual testing (hack/mtls/):
- 4-phase rotation test with 4-node cluster
- Makefile for cert generation with cfssl
- Procfile for goreman-based cluster

Part 3 of CA hot-reload support (issue etcd-io#11555).

Signed-off-by: Amir Omidi <amir@aaomidi.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

ETCD doesn't automatically load changes to ca bundles for peer-trusted-ca-file or trusted-ca-file

2 participants