Skip to content

Commit

Permalink
feat(operator): Added component option to disable managed Ingress (#5923
Browse files Browse the repository at this point in the history
)

* Added component option to disable managed Ingress

* Revert a install.yaml change

* Apply PR feedback

* Revert a install.yaml change
  • Loading branch information
EricWittmann authored Feb 11, 2025
1 parent 45abce9 commit f618cce
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,15 @@ public boolean isMet(DependentResource<Ingress, ApicurioRegistry3> resource,
ApicurioRegistry3 primary, Context<ApicurioRegistry3> 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;
}
}

Expand Down Expand Up @@ -76,12 +79,15 @@ public boolean isMet(DependentResource<Ingress, ApicurioRegistry3> resource,
ApicurioRegistry3 primary, Context<ApicurioRegistry3> 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;
}
}

Expand Down Expand Up @@ -125,12 +131,15 @@ public boolean isMet(DependentResource<Ingress, ApicurioRegistry3> resource,
ApicurioRegistry3 primary, Context<ApicurioRegistry3> 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;
}
}

Expand Down
18 changes: 18 additions & 0 deletions operator/install/install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

@JsonDeserialize(using = None.class)
@JsonInclude(NON_NULL)
@JsonPropertyOrder({ "host" })
@JsonPropertyOrder({ "enabled", "host" })
@NoArgsConstructor
@AllArgsConstructor(access = PRIVATE)
@SuperBuilder(toBuilder = true)
Expand All @@ -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.
Expand Down

0 comments on commit f618cce

Please sign in to comment.