Skip to content

Commit

Permalink
fix: use only one ingress (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosthe19916 authored Aug 8, 2024
1 parent 9659ee9 commit e563956
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 117 deletions.
1 change: 0 additions & 1 deletion src/main/java/org/trustify/operator/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public class Constants {


public static final String INGRESS_SUFFIX = "-" + TRUSTI_SERVER_NAME + "-ingress";
public static final String INGRESS_SECURE_SUFFIX = "-" + TRUSTI_SERVER_NAME + "-secure-ingress";

//
public static final String DB_SECRET_USERNAME = "username";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import io.fabric8.kubernetes.api.model.networking.v1.Ingress;
import io.fabric8.kubernetes.api.model.networking.v1.IngressTLS;
import io.fabric8.kubernetes.api.model.networking.v1.IngressTLSBuilder;
import io.javaoperatorsdk.operator.api.reconciler.Context;
import io.javaoperatorsdk.operator.api.reconciler.dependent.DependentResource;
import io.javaoperatorsdk.operator.processing.dependent.kubernetes.KubernetesDependent;
Expand All @@ -11,13 +12,14 @@
import org.trustify.operator.cdrs.v2alpha1.TrustifySpec;
import org.trustify.operator.utils.CRDUtils;

import java.util.Collections;
import java.util.Map;

@KubernetesDependent(labelSelector = ServerIngress.LABEL_SELECTOR, resourceDiscriminator = ServerIngressDiscriminator.class)
@ApplicationScoped
public class ServerIngress extends ServerIngressBase {

public static final String LABEL_SELECTOR = "app.kubernetes.io/managed-by=trustify-operator,component=server,component-variant=http";
public static final String LABEL_SELECTOR = "app.kubernetes.io/managed-by=trustify-operator,component=server,component-variant=https";

@Override
@SuppressWarnings("unchecked")
Expand All @@ -28,16 +30,14 @@ protected Ingress desired(Trustify cr, Context<Trustify> context) {
getIngressName(cr),
Map.of(
"component", "server",
"component-variant", "http"
"component-variant", "https"
),
Map.of(
"console.alpha.openshift.io/overview-app-route", "true"
)
Collections.emptyMap()
);
}

@Override
public boolean isMet(DependentResource<Ingress, Trustify> dependentResource, Trustify cr, Context<Trustify> context) {
public boolean isMet(DependentResource<Ingress, Trustify> dependentResource, Trustify primary, Context<Trustify> context) {
return context.getSecondaryResource(Ingress.class, new ServerIngressDiscriminator())
.map(in -> {
final var status = in.getStatus();
Expand Down Expand Up @@ -68,7 +68,12 @@ protected String getHostname(Trustify cr) {

@Override
protected IngressTLS getIngressTLS(Trustify cr) {
return null;
String tlsSecretName = CRDUtils.getValueFromSubSpec(cr.getSpec().httpSpec(), TrustifySpec.HttpSpec::tlsSecret)
.orElse(null);

return new IngressTLSBuilder()
.withSecretName(tlsSecretName)
.build();
}

public static String getIngressName(Trustify cr) {
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import org.trustify.operator.cdrs.v2alpha1.TrustifyStatusCondition;
import org.trustify.operator.cdrs.v2alpha1.server.ServerDeployment;
import org.trustify.operator.cdrs.v2alpha1.server.ServerIngress;
import org.trustify.operator.cdrs.v2alpha1.server.ServerIngressSecure;
import org.trustify.operator.cdrs.v2alpha1.server.ServerService;
import org.trustify.operator.cdrs.v2alpha1.db.DBDeployment;
import org.trustify.operator.cdrs.v2alpha1.db.DBPersistentVolumeClaim;
Expand All @@ -38,8 +37,7 @@
@Dependent(name = "server-deployment", type = ServerDeployment.class, dependsOn = {"db-service"}, readyPostcondition = ServerDeployment.class, useEventSourceWithName = TrustifyReconciler.DEPLOYMENT_EVENT_SOURCE),
@Dependent(name = "server-service", type = ServerService.class, dependsOn = {"db-service"}, useEventSourceWithName = TrustifyReconciler.SERVICE_EVENT_SOURCE),

@Dependent(name = "ingress", type = ServerIngress.class, dependsOn = {"db-service"}, readyPostcondition = ServerIngress.class, useEventSourceWithName = TrustifyReconciler.INGRESS_EVENT_SOURCE),
@Dependent(name = "ingress-secure", type = ServerIngressSecure.class, dependsOn = {"db-service"}, readyPostcondition = ServerIngressSecure.class, useEventSourceWithName = TrustifyReconciler.INGRESS_EVENT_SOURCE)
@Dependent(name = "ingress", type = ServerIngress.class, dependsOn = {"db-service"}, readyPostcondition = ServerIngress.class, useEventSourceWithName = TrustifyReconciler.INGRESS_EVENT_SOURCE)
}
)
public class TrustifyReconciler implements Reconciler<Trustify>, ContextInitializer<Trustify>,
Expand Down

0 comments on commit e563956

Please sign in to comment.