Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add manage-cert-rotation: yes label to cs-ca-certificate CR #2467

Merged
merged 7 commits into from
Apr 1, 2025
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions internal/controller/bootstrap/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,27 @@ func (b *Bootstrap) CreateOrUpdateFromYaml(yamlContent []byte, alwaysUpdate ...b
obj.Object["spec"].(map[string]interface{})["config"] = sub.Object["spec"].(map[string]interface{})["config"]
}
update = !equality.Semantic.DeepEqual(sub.Object["spec"], obj.Object["spec"])
} else if gvk.Kind == "Certificate" {
// ignore renewBefore time when updating the certificate
cert := &unstructured.Unstructured{}
cert.SetGroupVersionKind(schema.GroupVersionKind{
Group: "cert-manager.io",
Version: "v1",
Kind: "Certificate",
})
certKey := types.NamespacedName{
Name: obj.GetName(),
Namespace: obj.GetNamespace(),
}
if err := b.Client.Get(ctx, certKey, cert); err != nil {
klog.Errorf("Failed to get certificate for %s.", obj.GetName())
return err
}
// use renewBefore time in certificate in the cluster
if obj.Object["spec"].(map[string]interface{})["renewBefore"] != nil {
obj.Object["spec"].(map[string]interface{})["renewBefore"] = cert.Object["spec"].(map[string]interface{})["renewBefore"]
}
update = !equality.Semantic.DeepEqual(cert.Object["spec"], obj.Object["spec"]) || !equality.Semantic.DeepEqual(cert.GetLabels(), obj.GetLabels())
} else {
v1IsLarger, convertErr := util.CompareVersion(obj.GetAnnotations()["version"], objInCluster.GetAnnotations()["version"])
if convertErr != nil {
Expand Down
3 changes: 2 additions & 1 deletion internal/controller/constant/certmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ metadata:
app.kubernetes.io/instance: cs-ca-certificate
app.kubernetes.io/managed-by: cert-manager-controller
app.kubernetes.io/name: Certificate
operator.ibm.com/managedByCsOperator: "true"
operator.ibm.com/managedByCsOperator: 'true'
ibm-cert-manager-operator/refresh-ca-chain: 'true'
manage-cert-rotation: 'yes'
name: cs-ca-certificate
namespace: "placeholder"
spec:
Expand Down
Loading