Skip to content

Commit 26383ba

Browse files
committed
Address pr feedback
1 parent 0cfa62a commit 26383ba

File tree

8 files changed

+31
-29
lines changed

8 files changed

+31
-29
lines changed

operator/controller/src/main/java/io/apicurio/registry/operator/Constants.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package io.apicurio.registry.operator;
22

33
import io.apicurio.registry.operator.api.v1.ApicurioRegistry3;
4+
import io.fabric8.kubernetes.api.model.HTTPGetActionBuilder;
5+
import io.fabric8.kubernetes.api.model.IntOrString;
46
import io.fabric8.kubernetes.api.model.Probe;
57
import io.fabric8.kubernetes.api.model.ProbeBuilder;
68
import io.fabric8.kubernetes.api.model.Quantity;
@@ -26,15 +28,8 @@ public class Constants {
2628
public static final Map<String, Quantity> DEFAULT_LIMITS = Map.of("cpu",
2729
new QuantityBuilder().withAmount("1").build(), "memory",
2830
new QuantityBuilder().withAmount("1300").withFormat("Mi").build());
29-
public static final Probe DEFAULT_READINESS_PROBE = new ProbeBuilder().withNewHttpGet()
30-
.withPath("/health/ready").withNewPort().withValue(8080).endPort().endHttpGet()
31-
.withInitialDelaySeconds(15).withTimeoutSeconds(5).withPeriodSeconds(10).withSuccessThreshold(1)
32-
.withFailureThreshold(3).build();
33-
34-
public static final Probe DEFAULT_LIVENESS_PROBE = new ProbeBuilder().withNewHttpGet()
35-
.withPath("/health/live").withNewPort().withValue(8080).endPort().endHttpGet()
36-
.withInitialDelaySeconds(15).withTimeoutSeconds(5).withPeriodSeconds(10).withSuccessThreshold(1)
37-
.withFailureThreshold(3).build();
31+
public static final Probe DEFAULT_READINESS_PROBE = new ProbeBuilder().withHttpGet(new HTTPGetActionBuilder().withPath("/health/ready").withPort(new IntOrString(8080)).withScheme("HTTP").build()).build();
32+
public static final Probe DEFAULT_LIVENESS_PROBE = new ProbeBuilder().withHttpGet(new HTTPGetActionBuilder().withPath("/health/live").withPort(new IntOrString(8080)).withScheme("HTTP").build()).build();
3833

3934
public static final Probe TLS_DEFAULT_READINESS_PROBE = new ProbeBuilder().withNewHttpGet()
4035
.withScheme("HTTPS").withPath("/health/ready").withNewPort().withValue(8443).endPort().endHttpGet()

operator/controller/src/main/java/io/apicurio/registry/operator/EnvironmentVariables.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ public class EnvironmentVariables {
1111
public static final String QUARKUS_TLS_KEY_STORE_P12_PASSWORD = "QUARKUS_TLS_KEY_STORE_P12_PASSWORD";
1212
public static final String QUARKUS_TLS_TRUST_STORE_P12_PATH = "QUARKUS_TLS_TRUST_STORE_P12_PATH";
1313
public static final String QUARKUS_TLS_TRUST_STORE_P12_PASSWORD = "QUARKUS_TLS_TRUST_STORE_P12_PASSWORD";
14-
public static final String QUARKUS_OIDC_TLS_TLS_CONFIGURATION_NAME = "QUARKUS_OIDC_TLS_TLS_CONFIGURATION_NAME";
15-
1614
public static final String APICURIO_REST_DELETION_ARTIFACT_VERSION_ENABLED = "APICURIO_REST_DELETION_ARTIFACT-VERSION_ENABLED";
1715
public static final String APICURIO_REST_DELETION_ARTIFACT_ENABLED = "APICURIO_REST_DELETION_ARTIFACT_ENABLED";
1816
public static final String APICURIO_REST_DELETION_GROUP_ENABLED = "APICURIO_REST_DELETION_GROUP_ENABLED";

operator/controller/src/main/java/io/apicurio/registry/operator/feat/TLS.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,8 @@ private static Optional<TLSSpec> getTlsSpec(ApicurioRegistry3 primary) {
6464
.map(ApicurioRegistry3Spec::getApp)
6565
.map(AppSpec::getTls);
6666
}
67+
68+
public static boolean insecureRequestsEnabled(TLSSpec tlsSpec) {
69+
return "enabled".equals(tlsSpec.getInsecureRequests());
70+
}
6771
}

operator/controller/src/main/java/io/apicurio/registry/operator/resource/ResourceFactory.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ public Deployment getDefaultAppDeployment(ApicurioRegistry3 primary) {
5858
ofNullable(primary.getSpec()).map(ApicurioRegistry3Spec::getApp)
5959
.map(AppSpec::getPodTemplateSpec).orElse(null)); // TODO:
6060

61-
var readinessProbe = new ProbeBuilder().withHttpGet(new HTTPGetActionBuilder().withPath("/health/ready").withPort(new IntOrString(8080)).withScheme("HTTP").build()).build();
62-
var livenessProbe = new ProbeBuilder().withHttpGet(new HTTPGetActionBuilder().withPath("/health/live").withPort(new IntOrString(8080)).withScheme("HTTP").build()).build();
61+
var readinessProbe = DEFAULT_READINESS_PROBE;
62+
var livenessProbe = DEFAULT_LIVENESS_PROBE;
63+
var containerPort = List.of(new ContainerPortBuilder().withName("http").withProtocol("TCP").withContainerPort(8080).build());
6364

6465
Optional<TLSSpec> tlsSpec = ofNullable(primary.getSpec())
6566
.map(ApicurioRegistry3Spec::getApp)
@@ -68,6 +69,7 @@ public Deployment getDefaultAppDeployment(ApicurioRegistry3 primary) {
6869
if (tlsSpec.isPresent()) {
6970
readinessProbe = TLS_DEFAULT_READINESS_PROBE;
7071
livenessProbe = TLS_DEFAULT_LIVENESS_PROBE;
72+
containerPort = List.of(new ContainerPortBuilder().withName("https").withProtocol("TCP").withContainerPort(8443).build());
7173
}
7274

7375
// Replicas
@@ -77,7 +79,7 @@ public Deployment getDefaultAppDeployment(ApicurioRegistry3 primary) {
7779
r.getSpec().getTemplate(),
7880
REGISTRY_APP_CONTAINER_NAME,
7981
Configuration.getAppImage(),
80-
List.of(new ContainerPortBuilder().withName("http").withProtocol("TCP").withContainerPort(8080).build()),
82+
containerPort,
8183
readinessProbe,
8284
livenessProbe,
8385
Map.of("cpu", new Quantity("500m"), "memory", new Quantity("512Mi")),

operator/controller/src/main/java/io/apicurio/registry/operator/resource/app/AppNetworkPolicyResource.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import io.apicurio.registry.operator.api.v1.ApicurioRegistry3;
44
import io.apicurio.registry.operator.api.v1.ApicurioRegistry3Spec;
55
import io.apicurio.registry.operator.api.v1.spec.AppSpec;
6+
import io.apicurio.registry.operator.feat.TLS;
67
import io.apicurio.registry.operator.resource.LabelDiscriminators.AppNetworkPolicyDiscriminator;
78
import io.fabric8.kubernetes.api.model.IntOrStringBuilder;
89
import io.fabric8.kubernetes.api.model.networking.v1.NetworkPolicy;
@@ -50,7 +51,7 @@ protected NetworkPolicy desired(ApicurioRegistry3 primary, Context<ApicurioRegis
5051
var httpPolicy = new io.fabric8.kubernetes.api.model.networking.v1.NetworkPolicyPortBuilder()
5152
.withPort(new IntOrStringBuilder().withValue(8080).build()).build();
5253

53-
if (tls.getInsecureRequests() != null && !tls.getInsecureRequests().equals("enabled")) {
54+
if (!TLS.insecureRequestsEnabled(tls)) {
5455
networkPolicy.getSpec().setIngress(List.of(new NetworkPolicyIngressRuleBuilder()
5556
.withPorts(httpsPolicy)
5657
.build()));

operator/controller/src/main/java/io/apicurio/registry/operator/resource/app/AppServiceResource.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import io.apicurio.registry.operator.api.v1.ApicurioRegistry3;
44
import io.apicurio.registry.operator.api.v1.ApicurioRegistry3Spec;
55
import io.apicurio.registry.operator.api.v1.spec.AppSpec;
6+
import io.apicurio.registry.operator.feat.TLS;
67
import io.fabric8.kubernetes.api.model.IntOrStringBuilder;
78
import io.fabric8.kubernetes.api.model.Service;
89
import io.fabric8.kubernetes.api.model.ServicePortBuilder;
@@ -48,7 +49,7 @@ protected Service desired(ApicurioRegistry3 primary, Context<ApicurioRegistry3>
4849
.withTargetPort(new IntOrStringBuilder().withValue(8443).build())
4950
.build();
5051

51-
if (tls.getInsecureRequests() != null && tls.getInsecureRequests().equals("enabled")) {
52+
if (!TLS.insecureRequestsEnabled(tls)) {
5253
s.getSpec().setPorts(List.of(httpsPort, httpPort));
5354
}
5455
else {

operator/controller/src/test/java/io/apicurio/registry/operator/it/TlsITTest.java

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import io.fabric8.kubernetes.api.model.networking.v1.NetworkPolicyIngressRule;
88
import io.fabric8.kubernetes.client.utils.Serialization;
99
import io.quarkus.test.junit.QuarkusTest;
10+
import org.junit.jupiter.api.Assertions;
1011
import org.junit.jupiter.api.BeforeAll;
1112
import org.junit.jupiter.api.Test;
1213

@@ -68,6 +69,7 @@ void testTLS() {
6869
.withName(registry.getMetadata().getName() + "-app-service").get().getSpec();
6970

7071
assertThat(service.getClusterIP()).isNotBlank();
72+
Assertions.assertEquals(1, service.getPorts().size());
7173
assertThat(service.getPorts().get(0).getPort()).isEqualTo(443);
7274
assertThat(service.getClusterIP()).isNotBlank();
7375
return true;
@@ -86,9 +88,12 @@ void testTLS() {
8688

8789
// Network Policy
8890
await().ignoreExceptions().until(() -> {
89-
assertThat(client.network().v1().networkPolicies().inNamespace(namespace)
91+
NetworkPolicyIngressRule networkPolicyIngressRule = client.network().v1().networkPolicies().inNamespace(namespace)
9092
.withName("simple-app-networkpolicy").get().getSpec().getIngress()
91-
.get(0).getPorts().get(0).getPort().getIntVal()).isEqualTo(8443);
93+
.get(0);
94+
Assertions.assertEquals(1, networkPolicyIngressRule.getPorts().size());
95+
96+
assertThat(networkPolicyIngressRule.getPorts().get(0).getPort().getIntVal()).isEqualTo(8443);
9297
return true;
9398
});
9499
}
@@ -134,26 +139,22 @@ void testTLSInsecureTrafficEnabled() {
134139
assertThat(service.getClusterIP()).isNotBlank();
135140
assertThat(service.getPorts().get(0).getPort()).isEqualTo(443);
136141
assertThat(service.getPorts().get(1).getPort()).isEqualTo(8080);
142+
143+
Assertions.assertEquals(2, service.getPorts().size());
144+
137145
assertThat(service.getClusterIP()).isNotBlank();
138146
return true;
139147
});
140148

141-
// Ingresses
142-
await().ignoreExceptions().until(() -> {
143-
assertThat(client.network().v1().ingresses().inNamespace(namespace)
144-
.withName(registry.getMetadata().getName() + "-app-ingress").get().getSpec().getRules()
145-
.get(0).getHost()).isEqualTo(registry.getSpec().getApp().getIngress().getHost());
146-
assertThat(client.network().v1().ingresses().inNamespace(namespace)
147-
.withName(registry.getMetadata().getName() + "-ui-ingress").get().getSpec().getRules()
148-
.get(0).getHost()).isEqualTo(registry.getSpec().getUi().getIngress().getHost());
149-
return true;
150-
});
151149

152150
// Network Policy
153151
await().ignoreExceptions().until(() -> {
154152
NetworkPolicyIngressRule networkPolicyIngressRule = client.network().v1().networkPolicies().inNamespace(namespace)
155153
.withName("simple-app-networkpolicy").get().getSpec().getIngress()
156154
.get(0);
155+
156+
Assertions.assertEquals(2, networkPolicyIngressRule.getPorts().size());
157+
157158
assertThat(networkPolicyIngressRule.getPorts().get(0).getPort().getIntVal()).isEqualTo(8443);
158159
assertThat(networkPolicyIngressRule.getPorts().get(1).getPort().getIntVal()).isEqualTo(8080);
159160
return true;

operator/controller/src/test/resources/k8s/examples/tls/simple-with_tls.apicurioregistry3.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ spec:
2626
host: simple-ui.apps.cluster.example
2727
env:
2828
- name: REGISTRY_API_URL
29-
value: https://simple-app.apps.cluster.example/apis/registry/v3
29+
value: https://simple-app.apps.cluster.example/apis/registry/v3 # This example is only suitable for in-cluster connections. An external https ingress would need to be created manually for external access.

0 commit comments

Comments
 (0)