-
Notifications
You must be signed in to change notification settings - Fork 218
OCPBUGS-9037, OCPBUGS-64565: Use cluster wildcard certificate for ingress canary #1155
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -7,17 +7,23 @@ import ( | |||||
| "github.com/google/go-cmp/cmp" | ||||||
| "github.com/google/go-cmp/cmp/cmpopts" | ||||||
|
|
||||||
| operatorv1 "github.com/openshift/api/operator/v1" | ||||||
| "github.com/openshift/cluster-ingress-operator/pkg/manifests" | ||||||
| "github.com/openshift/cluster-ingress-operator/pkg/operator/controller" | ||||||
|
|
||||||
| appsv1 "k8s.io/api/apps/v1" | ||||||
| corev1 "k8s.io/api/core/v1" | ||||||
| "k8s.io/apimachinery/pkg/api/errors" | ||||||
| "k8s.io/apimachinery/pkg/types" | ||||||
| ) | ||||||
|
|
||||||
| // ensureCanaryDaemonSet ensures the canary daemonset exists | ||||||
| func (r *reconciler) ensureCanaryDaemonSet() (bool, *appsv1.DaemonSet, error) { | ||||||
| desired := desiredCanaryDaemonSet(r.config.CanaryImage) | ||||||
| secretName, err := r.canarySecretName(controller.CanaryDaemonSetName().Namespace) | ||||||
| if err != nil { | ||||||
| return false, nil, err | ||||||
| } | ||||||
|
Comment on lines
+22
to
+25
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not get the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In order to enable |
||||||
| desired := desiredCanaryDaemonSet(r.config.CanaryImage, secretName.Name) | ||||||
| haveDs, current, err := r.currentCanaryDaemonSet() | ||||||
| if err != nil { | ||||||
| return false, nil, err | ||||||
|
|
@@ -80,7 +86,7 @@ func (r *reconciler) updateCanaryDaemonSet(current, desired *appsv1.DaemonSet) ( | |||||
|
|
||||||
| // desiredCanaryDaemonSet returns the desired canary daemonset read in | ||||||
| // from manifests | ||||||
| func desiredCanaryDaemonSet(canaryImage string) *appsv1.DaemonSet { | ||||||
| func desiredCanaryDaemonSet(canaryImage, secretName string) *appsv1.DaemonSet { | ||||||
| daemonset := manifests.CanaryDaemonSet() | ||||||
| name := controller.CanaryDaemonSetName() | ||||||
| daemonset.Name = name.Name | ||||||
|
|
@@ -97,6 +103,8 @@ func desiredCanaryDaemonSet(canaryImage string) *appsv1.DaemonSet { | |||||
| daemonset.Spec.Template.Spec.Containers[0].Image = canaryImage | ||||||
| daemonset.Spec.Template.Spec.Containers[0].Command = []string{"ingress-operator", CanaryHealthcheckCommand} | ||||||
|
|
||||||
| daemonset.Spec.Template.Spec.Volumes[0].Secret.SecretName = secretName | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be better to call
Suggested change
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And then you could test the secret generation in |
||||||
|
|
||||||
| return daemonset | ||||||
| } | ||||||
|
|
||||||
|
|
@@ -196,3 +204,15 @@ func cmpTolerations(a, b corev1.Toleration) bool { | |||||
| } | ||||||
| return true | ||||||
| } | ||||||
|
|
||||||
| func (r *reconciler) canarySecretName(Namespace string) (types.NamespacedName, error) { | ||||||
| defaultIC := operatorv1.IngressController{} | ||||||
| defaultICName := types.NamespacedName{ | ||||||
| Name: manifests.DefaultIngressControllerName, | ||||||
| Namespace: r.config.Namespace, | ||||||
| } | ||||||
| if err := r.client.Get(context.TODO(), defaultICName, &defaultIC); err != nil { | ||||||
| return types.NamespacedName{}, err | ||||||
| } | ||||||
| return controller.RouterEffectiveDefaultCertificateSecretName(&defaultIC, Namespace), nil | ||||||
| } | ||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -10,6 +10,7 @@ import ( | |||||
| "time" | ||||||
|
|
||||||
| logf "github.com/openshift/cluster-ingress-operator/pkg/log" | ||||||
| "github.com/openshift/cluster-ingress-operator/pkg/manifests" | ||||||
| "github.com/openshift/cluster-ingress-operator/pkg/operator/controller" | ||||||
| ingresscontroller "github.com/openshift/cluster-ingress-operator/pkg/operator/controller/ingress" | ||||||
|
|
||||||
|
|
@@ -105,6 +106,33 @@ func (r *reconciler) Reconcile(ctx context.Context, request reconcile.Request) ( | |||||
| if _, err := r.ensureDefaultCertificateForIngress(ca, deployment.Namespace, deploymentRef, ingress); err != nil { | ||||||
| errs = append(errs, fmt.Errorf("failed to ensure default cert for %s: %v", ingress.Name, err)) | ||||||
| } | ||||||
| if ingress.Name == manifests.DefaultIngressControllerName { | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add a comment to explain why this logic only applies to the "default" IngressController. Namely, the canary check is specifically for verifying that the default IngressController is ready. |
||||||
| log.Info("ensuring canary certificate") | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| daemonset := &appsv1.DaemonSet{} | ||||||
| err = r.client.Get(ctx, controller.CanaryDaemonSetName(), daemonset) | ||||||
| if err != nil { | ||||||
| if errors.IsNotFound(err) { | ||||||
| // All ingresses should have a deployment, so this one may not have been | ||||||
| // created yet. Retry after a reasonable amount of time. | ||||||
| log.Info("canary daemonset not found; will retry default cert sync") | ||||||
| result.RequeueAfter = 5 * time.Second | ||||||
| } else { | ||||||
| errs = append(errs, fmt.Errorf("failed to get daemonset: %v", err)) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use |
||||||
| } | ||||||
| } else { | ||||||
| trueVar := true | ||||||
| canaryRef := metav1.OwnerReference{ | ||||||
| APIVersion: "apps/v1", | ||||||
| Kind: "Daemonset", | ||||||
| Name: daemonset.Name, | ||||||
| UID: daemonset.UID, | ||||||
| Controller: &trueVar, | ||||||
| } | ||||||
| if _, err := r.ensureDefaultCertificateForIngress(ca, "openshift-ingress-canary", canaryRef, ingress); err != nil { | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't there need to be a different function to ensure a canary cert rather than ensure a default cert? Does this ensure the correct cert?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The intent is that the canary application should use the default IngressController's default certificate. This way, as long as the default IngressController has a correctly configured default certificate, so too will the canary application. Because #978 changed the canary application to use a TLS passthrough route, the only way to have the canary application use the default IngressController's default certificate is to copy that certificate to the canary application's namespace and configure the application to use that copy of the certificate. If I understand correctly, |
||||||
| errs = append(errs, fmt.Errorf("failed to ensure canary cert for %s: %v", ingress.Name, err)) | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: