Skip to content

Wire certwatcher for dynamic client TLS cert reloading#16

Open
cahillsf wants to merge 1 commit into
v2.2-ddfrom
stephen.cahill/certwatcher-client-tls
Open

Wire certwatcher for dynamic client TLS cert reloading#16
cahillsf wants to merge 1 commit into
v2.2-ddfrom
stephen.cahill/certwatcher-client-tls

Conversation

@cahillsf
Copy link
Copy Markdown

@cahillsf cahillsf commented Apr 9, 2026

Description of your changes

When Emissary rotates TLS certs on disk via atomic symlink swaps, Crossplane's client mTLS config (used for gRPC connections to Functions) was loaded once at startup and never reloaded. This required manual kubectl rollout restart to pick up new certs.

This wires controller-runtime's certwatcher into the client TLS config path:

  • Creates a certwatcher for the client cert+key files (fsnotify + 10s polling fallback)
  • Sets GetClientCertificate on the tls.Config so each TLS handshake uses the latest cached cert
  • Registers a callback to reload and rebuild RootCAs when the cert rotates (works with Emissary's atomic symlink swap since all files rotate together)
  • Registers the watcher with the controller manager via mgr.Add() for proper lifecycle management

Note: server-side webhook certs already reload dynamically — controller-runtime's webhook server sets up its own certwatcher internally.

Builds on top of # which added support for reading TLS certs from disk.

Fixes #

I have:

@cahillsf cahillsf force-pushed the stephen.cahill/certwatcher-client-tls branch from 54359c8 to eafe635 Compare April 21, 2026 14:08
@cahillsf cahillsf changed the base branch from main to stephen.cahill/CLOUDR-1422-custom-function-dns April 21, 2026 14:09
@cahillsf cahillsf force-pushed the stephen.cahill/CLOUDR-1422-custom-function-dns branch from e9f498b to 18ab4a7 Compare April 24, 2026 17:38
Emissary rotates TLS certs on disk via atomic symlink swaps, but
Crossplane's client mTLS config was loaded once at startup. This
adds a controller-runtime certwatcher to dynamically reload client
certs and CA on rotation, eliminating the need for manual rollout
restarts.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@cahillsf cahillsf force-pushed the stephen.cahill/certwatcher-client-tls branch from eafe635 to e5ee6fd Compare April 24, 2026 17:38
Base automatically changed from stephen.cahill/CLOUDR-1422-custom-function-dns to v2.2-dd May 5, 2026 14:18
@cahillsf
Copy link
Copy Markdown
Author

cahillsf commented May 5, 2026

@cahillsf cahillsf marked this pull request as ready for review May 5, 2026 14:21
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.

1 participant