You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ratify v2 should support leader election via controller-runtime to enable safe multi-replica (HA) deployments.
Background
Currently, the Ratify v2 controller-runtime manager does not enable LeaderElection. This means:
Single replica works fine
Multiple replicas will have conflicts — specifically, the cert-controller CertRotator (added via rotator.AddRotator) will attempt certificate rotation from all replicas simultaneously, causing Secret write conflicts
Gatekeeper uses the same pattern: LeaderElection: false for single replica, configurable for multi
Anything else you would like to add?
The health probe infrastructure in PR #2559 already supports registering arbitrary checkers. The leader election checker would follow the same ReadySignal pattern used for the manager readiness check. Implementation example:
// After manager starts, register leader election checkerregistry.RegisterReadiness(healthprobe.MustNewChecker("leader-election", func() error {
select {
case<-mgr.Elected():
returnnil// this replica is the leaderdefault:
returnnil// non-leaders are still "ready" for read traffic
}
}))
// Liveness: detect stuck lease renewalregistry.RegisterLiveness(healthprobe.MustNewChecker("leader-lease", func() error {
// monitor lease renewal timestamp vs timeout// return error if lease is about to expire without renewal
}))
Reference: Gatekeeper's approach — uses LeaderElection: false but could be enabled; cert-controller's CertRotator respects manager leader election automatically.
What would you like to be added?
Ratify v2 should support leader election via controller-runtime to enable safe multi-replica (HA) deployments.
Background
Currently, the Ratify v2 controller-runtime manager does not enable
LeaderElection. This means:CertRotator(added viarotator.AddRotator) will attempt certificate rotation from all replicas simultaneously, causing Secret write conflictsProposed Changes
Enable leader election in the manager:
LeaderElection: trueinctrl.OptionsLeaderElectionID(e.g.,"ratify-leader-election")LeaderElectionNamespacefrom the pod namespaceIntegrate with the health probe system (PR feat(health): add /healthz and /readyz endpoints #2559):
mgr.Elected()channelHelm chart updates:
provider.leaderElection.enabled(default:truewhenreplicaCount > 1)provider.leaderElection.idfor custom lease nameprovider.replicaCountto enable horizontal scalingWhy this matters
cert-controllerCertRotator relies on leader election to ensure only one replica writes SecretsRelated
LeaderElection: falsefor single replica, configurable for multiAnything else you would like to add?
The health probe infrastructure in PR #2559 already supports registering arbitrary checkers. The leader election checker would follow the same
ReadySignalpattern used for the manager readiness check. Implementation example:Reference: Gatekeeper's approach — uses
LeaderElection: falsebut could be enabled; cert-controller'sCertRotatorrespects manager leader election automatically.