certrotation: restructure controller to own plumbing and cert creation#2151
certrotation: restructure controller to own plumbing and cert creation#2151sanchezl wants to merge 2 commits intoopenshift:masterfrom
Conversation
Update certrotation controller to use the new library-go certrotation API from openshift/library-go#2151: - SigningCAConfig, CABundleConfig, TargetCertKeyPairConfig replace old types - ClientCertConfig/ServingCertConfig replace ClientRotation/ServingRotation - Controller takes kubeClient and kubeInformersForNamespaces - PKI provider created by caller, gated on ConfigurablePKI feature gate - PKI informer cache sync registered with cachesToSync Does not compile until library-go is vendored with the new types.
Update certrotation controller to use the new library-go certrotation API from openshift/library-go#2151: - SigningCAConfig, CABundleConfig, TargetCertKeyPairConfig replace old types - ClientCertConfig/ServingCertConfig replace ClientRotation/ServingRotation - Controller takes kubeClient and kubeInformersForNamespaces - PKI provider created by caller, gated on ConfigurablePKI feature gate - PKI informer cache sync registered with cachesToSync Vendors library-go from sanchezl/library-go certrotation-refactor branch.
3a74583 to
1bc2ee6
Compare
Update certrotation controller to use the new library-go certrotation API from openshift/library-go#2151: - SigningCAConfig, CABundleConfig, TargetCertKeyPairConfig replace old types - ClientCertConfig/ServingCertConfig replace ClientRotation/ServingRotation - Controller takes kubeClient and kubeInformersForNamespaces - PKI provider created by caller, gated on ConfigurablePKI feature gate - PKI informer cache sync registered with cachesToSync - AdditionalAnnotations referenced from certrotation package (no tlsartifact) Vendors library-go from sanchezl/library-go certrotation-refactor branch.
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: sanchezl 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 |
1bc2ee6 to
8dcae8d
Compare
Update certrotation controller to use the new library-go certrotation API from openshift/library-go#2151: - SigningCAConfig, CABundleConfig, TargetCertKeyPairConfig replace old types - ClientCertConfig/ServingCertConfig replace ClientRotation/ServingRotation - Controller takes kubeClient and kubeInformersForNamespaces - PKI provider created by caller, gated on ConfigurablePKI feature gate - PKI informer cache sync registered with cachesToSync - AdditionalAnnotations referenced from certrotation package (no tlsartifact) Vendors library-go from sanchezl/library-go certrotation-refactor branch.
Update certrotation controller to use the new library-go certrotation API from openshift/library-go#2151 (refactor-only, no PKI support): - SigningCAConfig, CABundleConfig, TargetCertKeyPairConfig replace old types - ClientCertConfig/ServingCertConfig replace ClientRotation/ServingRotation - Controller takes kubeClient and kubeInformersForNamespaces - No PKI provider, no CertificateName fields Vendors library-go from sanchezl/library-go certrotation-refactor branch.
8dcae8d to
062d3b2
Compare
Replace hybrid data+behavior structs with pure config types: - RotatedSigningCASecret -> SigningCAConfig - CABundleConfigMap -> CABundleConfig - RotatedSelfSignedCertKeySecret -> TargetCertKeyPairConfig Flatten TargetCertCreator interface into sealed TargetCertConfig with typed variants (ClientCertConfig, ServingCertConfig, SignerCertConfig). The controller type-switches on the variant to create certs. Move all Ensure/set/needNew methods from data structs to CertRotationController. The controller now takes kubernetes.Interface and KubeInformersForNamespaces, deriving informers and listers from the config struct Namespace+Name fields. This eliminates the per-struct Informer/Lister/Client/EventRecorder plumbing and removes the TargetCertCreator, TargetCertRechecker, and KeyPairGeneratorConfigurable interfaces along with the ClientRotation, ServingRotation, and SignerRotation types.
Move ensureSigningCertKeyPair, ensureConfigMapCABundle, ensureTargetCertKeyPair, and setTargetCertKeyPairSecret from signer.go, cabundle.go, and target.go into client_cert_rotation_controller.go. This consolidates all controller sync logic in one file, leaving only config types and pure helper functions in the per-artifact files.
062d3b2 to
a957edb
Compare
|
@sanchezl: all tests passed! Full PR test history. Your PR dashboard. 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. I understand the commands that are listed here. |
|
@sanchezl please ask people who work with you on the feature for review. thanks. |
|
Closing in favor of library-go#2145. The structural refactor approach didn't work well with how cluster-etcd-operator uses the certrotation package — went with the original PR instead. |
Context
This addresses structural concerns raised during review of PR #2145. The certrotation package had hybrid data+behavior structs (
RotatedSigningCASecret,CABundleConfigMap,RotatedSelfSignedCertKeySecret) that carried informers, listers, clients, event recorders, AND CRUD methods. This PR restructures the package so the controller owns all plumbing and cert creation logic, and the caller passes pure config structs.PKI support is added separately in PR #2152.
Proof PR: openshift/cluster-kube-apiserver-operator#2089
What changed
New config types replace old hybrid structs
RotatedSigningCASecretSigningCAConfigCABundleConfigMapCABundleConfigRotatedSelfSignedCertKeySecretTargetCertKeyPairConfigThe new types carry only configuration (Namespace, Name, Validity, Refresh, AdditionalAnnotations, etc.) — no Informer, Lister, Client, or EventRecorder fields.
Sealed interface replaces TargetCertCreator
The
TargetCertCreatorinterface and its implementations (ClientRotation,ServingRotation,SignerRotation) are removed. In their place:The controller type-switches on the variant to create certs. No more
KeyPairGeneratorConfigurableinterface or runtime mutation.Controller owns all plumbing
NewCertRotationControllernow takeskubernetes.InterfaceandKubeInformersForNamespacesand derives informers/listers from the config struct Namespace+Name fields:All
Ensure*,set*, andneedNew*methods moved from the data structs to the controller.Removed types and interfaces
TargetCertCreatorinterfaceTargetCertRecheckerinterfaceKeyPairGeneratorConfigurableinterfaceClientRotation,ServingRotation,SignerRotationstructsServingHostnameFunctypeconfigurablePKIEnabledbool fieldsFiles guide
signer.goSigningCAConfigstruct (pure data), helper functions stay as package-levelcabundle.goCABundleConfigstruct (pure data),manageCABundleConfigMapstays as package-level functiontarget.goTargetCertKeyPairConfig, sealedTargetCertConfiginterface,ClientCertConfig/ServingCertConfig/SignerCertConfigvariants,needNewTargetCertKeyPairwith integrated hostname checkingclient_cert_rotation_controller.goCertRotationControllerwith all moved methods,ensureSigningCertKeyPair/ensureConfigMapCABundle/ensureTargetCertKeyPair*_test.goTest plan
go build ./...passesgo test ./pkg/operator/certrotation/...passesgo vet ./pkg/operator/certrotation/...passes