Skip to content

Commit

Permalink
Set a default ingressClassName on OpenShift to avoid monitoring alert
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Edgar <[email protected]>
  • Loading branch information
MikeEdgar committed Oct 1, 2024
1 parent 3454a0a commit 0d687c7
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -41,6 +42,7 @@ protected Ingress desired(Console primary, Context<Console> context) {
.withLabels(commonLabels("console"))
.endMetadata()
.editSpec()
.withIngressClassName(getIngressClassName(context))
.editDefaultBackend()
.editService()
.withName(service.instanceName(primary))
Expand All @@ -61,4 +63,12 @@ protected Ingress desired(Console primary, Context<Console> 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<Console> context) {
return context.getClient().supports(Route.class) ? "openshift-default" : null;
}
}

0 comments on commit 0d687c7

Please sign in to comment.