ensure default issuer is ok
@@ -118,10 +118,7 @@ func (r *KappNSReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
func (r *KappNSReconciler) reconcileDefaultCAIssuerAndCert() error {
defaultCAIssuerName := "default-cert-issuer"
- caIssuer := v1alpha1.HttpsCertIssuer{}
- err := r.Get(r.ctx, types.NamespacedName{Name: defaultCAIssuerName}, &caIssuer)
- if errors.IsNotFound(err) {
- caIssuer = v1alpha1.HttpsCertIssuer{
+ expectedCAIssuer := v1alpha1.HttpsCertIssuer{
ObjectMeta: metav1.ObjectMeta{
Name: defaultCAIssuerName,
},
@@ -130,7 +127,19 @@ func (r *KappNSReconciler) reconcileDefaultCAIssuerAndCert() error {
},
}
- if err := r.Create(r.ctx, &caIssuer); err != nil {
+ currentCAIssuer := v1alpha1.HttpsCertIssuer{}
+ err := r.Get(r.ctx, types.NamespacedName{Name: defaultCAIssuerName}, &currentCAIssuer)
+ if err != nil {
+ if errors.IsNotFound(err) {
+ return err
+ }
+
+ if err := r.Create(r.ctx, &expectedCAIssuer); err != nil {
+ return err
+ }
+ } else {
+ currentCAIssuer.Spec = expectedCAIssuer.Spec
+ if err := r.Update(r.ctx, &currentCAIssuer); err != nil {
return err
}
}
