diff --git a/operator/controller/src/main/java/io/apicurio/registry/operator/resource/ActivationConditions.java b/operator/controller/src/main/java/io/apicurio/registry/operator/resource/ActivationConditions.java index 69f6dabc84..c3f242a6dd 100644 --- a/operator/controller/src/main/java/io/apicurio/registry/operator/resource/ActivationConditions.java +++ b/operator/controller/src/main/java/io/apicurio/registry/operator/resource/ActivationConditions.java @@ -39,12 +39,15 @@ public boolean isMet(DependentResource resource, ApicurioRegistry3 primary, Context context) { var enabled = ofNullable(primary.getSpec()).map(ApicurioRegistry3Spec::getApp) + .map(ComponentSpec::getIngress).map(IngressSpec::getEnabled).orElse(Boolean.TRUE); + var hasIngressHost = ofNullable(primary.getSpec()).map(ApicurioRegistry3Spec::getApp) .map(AppSpec::getIngress).map(IngressSpec::getHost).map(host -> !isBlank(host)) .orElse(false); - if (!enabled) { + boolean isManaged = enabled && hasIngressHost; + if (!isManaged) { ((AppIngressResource) resource).delete(primary, context); } - return enabled; + return isManaged; } } @@ -76,12 +79,15 @@ public boolean isMet(DependentResource resource, ApicurioRegistry3 primary, Context context) { var enabled = ofNullable(primary.getSpec()).map(ApicurioRegistry3Spec::getUi) + .map(ComponentSpec::getIngress).map(IngressSpec::getEnabled).orElse(Boolean.TRUE); + var hasIngressHost = ofNullable(primary.getSpec()).map(ApicurioRegistry3Spec::getUi) .map(UiSpec::getIngress).map(IngressSpec::getHost).map(host -> !isBlank(host)) .orElse(false); - if (!enabled) { + boolean isManaged = enabled && hasIngressHost; + if (!isManaged) { ((UIIngressResource) resource).delete(primary, context); } - return enabled; + return isManaged; } } @@ -125,12 +131,15 @@ public boolean isMet(DependentResource resource, ApicurioRegistry3 primary, Context context) { var enabled = ofNullable(primary.getSpec()).map(ApicurioRegistry3Spec::getStudioUi) + .map(ComponentSpec::getIngress).map(IngressSpec::getEnabled).orElse(Boolean.TRUE); + var hasIngressHost = ofNullable(primary.getSpec()).map(ApicurioRegistry3Spec::getStudioUi) .map(StudioUiSpec::getIngress).map(IngressSpec::getHost).map(host -> !isBlank(host)) .orElse(false); - if (!enabled) { + boolean isManaged = enabled && hasIngressHost; + if (!isManaged) { ((StudioUIIngressResource) resource).delete(primary, context); } - return enabled; + return isManaged; } } diff --git a/operator/install/install.yaml b/operator/install/install.yaml index 4438491914..a90136bb8b 100644 --- a/operator/install/install.yaml +++ b/operator/install/install.yaml @@ -99,6 +99,12 @@ spec: ingress: description: Configure Ingress for the component. properties: + enabled: + description: | + Whether an Ingress should be managed by the operator. Defaults to 'true'. + + Set this to 'false' if you want to create your own custom Ingress. + type: boolean host: description: |- Configure hostname of the operator-managed Ingress. If the value is empty, the operator will not create an Ingress resource for the component. @@ -3258,6 +3264,12 @@ spec: ingress: description: Configure Ingress for the component. properties: + enabled: + description: | + Whether an Ingress should be managed by the operator. Defaults to 'true'. + + Set this to 'false' if you want to create your own custom Ingress. + type: boolean host: description: |- Configure hostname of the operator-managed Ingress. If the value is empty, the operator will not create an Ingress resource for the component. @@ -6258,6 +6270,12 @@ spec: ingress: description: Configure Ingress for the component. properties: + enabled: + description: | + Whether an Ingress should be managed by the operator. Defaults to 'true'. + + Set this to 'false' if you want to create your own custom Ingress. + type: boolean host: description: |- Configure hostname of the operator-managed Ingress. If the value is empty, the operator will not create an Ingress resource for the component. diff --git a/operator/model/src/main/java/io/apicurio/registry/operator/api/v1/spec/IngressSpec.java b/operator/model/src/main/java/io/apicurio/registry/operator/api/v1/spec/IngressSpec.java index 06f9228ff6..dcdd330538 100644 --- a/operator/model/src/main/java/io/apicurio/registry/operator/api/v1/spec/IngressSpec.java +++ b/operator/model/src/main/java/io/apicurio/registry/operator/api/v1/spec/IngressSpec.java @@ -12,7 +12,7 @@ @JsonDeserialize(using = None.class) @JsonInclude(NON_NULL) -@JsonPropertyOrder({ "host" }) +@JsonPropertyOrder({ "enabled", "host" }) @NoArgsConstructor @AllArgsConstructor(access = PRIVATE) @SuperBuilder(toBuilder = true) @@ -21,6 +21,18 @@ @ToString public class IngressSpec { + /** + * Indicates whether to create and manage an Ingress for the component + */ + @JsonProperty("enabled") + @JsonPropertyDescription(""" + Whether an Ingress should be managed by the operator. Defaults to 'true'. + + Set this to 'false' if you want to create your own custom Ingress. + """) + @JsonSetter(nulls = Nulls.SKIP) + private Boolean enabled; + /** * Configure hostname of the operator-managed Ingress. If the value is empty, the operator will not create * an Ingress resource for the component.