✨Add events for automatic certificate rotation in KubeadmControlPlane#13242
✨Add events for automatic certificate rotation in KubeadmControlPlane#13242VijetaPriya47 wants to merge 5 commits intokubernetes-sigs:mainfrom
Conversation
|
This PR is currently missing an area label, which is used to identify the modified component when generating release notes. Area labels can be added by org members by writing Please see the labels list for possible areas. 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. |
|
Hi @VijetaPriya47. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 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 |
|
@g-gaston @sivchari @fabriziopandini Could you review this please? |
This commit adds event constant definitions that will be used to emit events for automatic certificate-related actions in KubeadmControlPlane: - EventKubeconfigCertificateRotated: Emitted when kubeconfig certificate is automatically rotated due to approaching expiry - EventKubeconfigCertificateRotationFailed: Emitted when kubeconfig certificate rotation fails - EventCertificateExpiryTriggeredRollout: Emitted when a machine is marked for rollout due to certificate expiry approaching the threshold These constants provide a foundation for improved observability and monitoring of automatic certificate management operations.
This commit implements event generation for automatic kubeconfig certificate rotation to improve observability and monitoring. Changes: - Add klog/v2 import for event message formatting - Emit EventKubeconfigCertificateRotated (Normal) when kubeconfig certificate is successfully rotated due to approaching expiry - Emit EventKubeconfigCertificateRotationFailed (Warning) when rotation fails These events help administrators monitor automatic certificate management and quickly identify any rotation failures that require attention.
This commit implements event generation when machines are rolled out due to certificate expiry approaching the configured threshold. Changes: - Emit double-sided events following the established pattern: * Event on Machine (Warning): Notifies the machine why it's being rolled out * Event on KCP (Normal): Notifies the administrator what the controller is doing - Events are only emitted when rollout is specifically due to certificate expiry (detected by checking for "certificates will expire soon" or "rolloutBefore expired" in the rollout log messages) This improves observability by making it clear when automatic rollouts are triggered by certificate expiry, helping administrators understand and monitor certificate lifecycle management.
Address mentor feedback by: - Moving kubeconfig rotation success event after RegenerateSecret to prevent publishing success on failure - Defining CertificateExpiryRolloutLogMessage in internal/filters.go to avoid hardcoded string matching between filters.go and controller.go
5010584 to
c5cef6a
Compare
|
@sivchari could you review again. I;ve resolved all the changes. |
| isCertExpiryRollout := false | ||
| for _, msg := range upToDateResult.LogMessages { | ||
| if strings.Contains(msg, internal.CertificateExpiryRolloutLogMessage) { | ||
| isCertExpiryRollout = true | ||
| break | ||
| } | ||
| } |
There was a problem hiding this comment.
isCertExpiryRollout := slices.ContainsFunc(upToDateResult.LogMessages, func(msg string) bool {
return strings.Contains(msg, internal.CertificateExpiryRolloutLogMessage)
})It's simpler.
f1922a1 to
b71ef7c
Compare
|
/lgtm @sbueringer @fabriziopandini |
|
LGTM label has been added. DetailsGit tree hash: 6744e591dc05174b9a7a1462f88298ada46d6a5a |
This commit implements event generation for automatic certificate-related actions in KubeadmControlPlane to improve observability and monitoring.
Events added:
Event pattern:
Following the double-sided event pattern from PR #12930:
This improves observability by allowing operators to:
kubectl get eventsWhich issue(s) this PR fixes
Fixes #11944 (partially - certificate rotation portion)
Note: This PR addresses certificate rotation in KubeadmControlPlane. PR #12930 addresses MachineHealthCheck events.