From 0d687c739b7f94307037bc078ab7e6b559f292ad Mon Sep 17 00:00:00 2001 From: Michael Edgar Date: Sun, 29 Sep 2024 07:23:43 -0400 Subject: [PATCH] Set a default ingressClassName on OpenShift to avoid monitoring alert Signed-off-by: Michael Edgar --- .../streamshub/console/dependents/ConsoleIngress.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/operator/src/main/java/com/github/streamshub/console/dependents/ConsoleIngress.java b/operator/src/main/java/com/github/streamshub/console/dependents/ConsoleIngress.java index 3b6a48298..cfc0d14ca 100644 --- a/operator/src/main/java/com/github/streamshub/console/dependents/ConsoleIngress.java +++ b/operator/src/main/java/com/github/streamshub/console/dependents/ConsoleIngress.java @@ -6,6 +6,7 @@ import com.github.streamshub.console.api.v1alpha1.Console; import io.fabric8.kubernetes.api.model.networking.v1.Ingress; +import io.fabric8.openshift.api.model.Route; import io.javaoperatorsdk.operator.api.reconciler.Context; import io.javaoperatorsdk.operator.processing.dependent.kubernetes.CRUDKubernetesDependentResource; import io.javaoperatorsdk.operator.processing.dependent.kubernetes.KubernetesDependent; @@ -41,6 +42,7 @@ protected Ingress desired(Console primary, Context context) { .withLabels(commonLabels("console")) .endMetadata() .editSpec() + .withIngressClassName(getIngressClassName(context)) .editDefaultBackend() .editService() .withName(service.instanceName(primary)) @@ -61,4 +63,12 @@ protected Ingress desired(Console primary, Context context) { .endSpec() .build(); } + + /** + * The class name is not required for functionality on OCP. However, monitoring + * will issue an alert if it is not present. + */ + private String getIngressClassName(Context context) { + return context.getClient().supports(Route.class) ? "openshift-default" : null; + } }