feat(server): support TLS certificate hot-reload#1870
Open
lunarwhite wants to merge 3 commits into
Open
Conversation
Signed-off-by: Yuedong Wu <dwcn22@outlook.com>
Signed-off-by: Yuedong Wu <dwcn22@outlook.com>
Signed-off-by: Yuedong Wu <dwcn22@outlook.com>
|
All contributors have signed the DCO ✍️ ✅ |
Author
|
I have read the DCO document and I hereby sign the DCO. |
Author
|
recheck |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add polling-based TLS certificate hot-reload to the gateway, allowing cert/key/CA rotation without restarting the server. Uses
ArcSwapfor atomic config swapping so in-flight TLS handshakes are never blocked.Related Issue
Fixes #1836
Changes
reload_interval_secsconfig field to[openshell.gateway.tls](default0= disabled)TlsAcceptorinternals withArcSwap<ServerConfig>for lock-free atomic swapsreload()for on-demand cert refresh andspawn_reload_worker()for periodic pollingreloadIntervalSecsin the Helm chart values and gateway-config templategenerate_test_certs_with_ca,install_rustls_provider,write_test_file) intotls_test_utils.rsTesting
mise run pre-commitpassesE2E test record
Step 1: Create cluster
Step 2: Enable TLS + reload
Create
deploy/helm/openshell/ci/values-reload-test.yaml:Add to
deploy/helm/openshell/skaffold.yamlafter- ci/values-skaffold.yaml:- ci/values-reload-test.yamlStep 3: Deploy
Step 4: Verify reload worker started
KUBECONFIG=kubeconfig kubectl -n openshell logs openshell-0 | grep -i reloadOutput:
Step 5: Capture initial cert fingerprint
Output:
Step 6: Overwrite TLS secret (simulate cert-manager renewal)
Output:
Step 7: Wait for kubelet sync + reload ticks
Step 8: Verify new cert is served — no pod restart
8a. Pod restarts
Output:
8b. Current cert from gateway
Output:
8c. Cert stored in Secret (should match gateway)
Output:
Results
A0:21:<...>:6541:90:<...>:1Binterval_seconds=10The gateway detected the updated certificate on disk and atomically swapped the active TLS config without a pod restart. The reload worker re-reads cert/key/CA files every
reloadIntervalSecsand the new cert was served within the kubelet sync window + one reload tick.Checklist
docs/reference/gateway-config.mdxupdated