Skip to content

Commit 4d2980c

Browse files
authored
Merge pull request #148 from franvila/fixCertManager
Fix cert manager
2 parents b42c082 + b3e2799 commit 4d2980c

File tree

7 files changed

+54
-30
lines changed

7 files changed

+54
-30
lines changed

.github/renovate.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,17 @@
3030
"depNameTemplate": "hashicorp/vault",
3131
"datasourceTemplate": "docker"
3232
},
33+
{
34+
"customType": "regex",
35+
"fileMatch": [
36+
"kroxylicious-systemtests/src/main/resources/helm_cert_manager_overrides.yaml"
37+
],
38+
"matchStrings": [
39+
"tag:.*(?<currentValue>\\d+\\.\\d+.\\d+)"
40+
],
41+
"depNameTemplate": "jetstack/cert-manager",
42+
"datasourceTemplate": "docker"
43+
},
3344
{
3445
"customType": "regex",
3546
"fileMatch": [

kroxylicious-kubernetes-api/src/main/resources/META-INF/fabric8/kafkaproxyingresses.kroxylicious.io-v1.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ spec:
6868
clusterIP:
6969
type: object
7070
description: |-
71-
clusterIP specifies that this ingress is for access within the same Kubernetes cluster using
71+
specifies that this ingress is for access within the same Kubernetes cluster using
7272
ClusterIP Kubernetes Services.
7373
required: [ "protocol" ]
7474
properties:
@@ -79,8 +79,8 @@ spec:
7979
loadBalancer:
8080
type: object
8181
description: |-
82-
clusterIP specifies that this ingress is for access within the same Kubernetes cluster using
83-
ClusterIP Kubernetes Services.
82+
specifies that this ingress is for access from outside the Kubernetes cluster
83+
via a LoadBalancer Kubernetes Services.
8484
required: [ "bootstrapAddress", "advertisedBrokerAddressPattern"]
8585
x-kubernetes-validations:
8686
- rule: "self.advertisedBrokerAddressPattern.contains('$(nodeId)')"

kroxylicious-systemtests/src/main/java/io/kroxylicious/systemtests/Constants.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ private Constants() {
2929
public static final String KROXYLICIOUS_TLS_CA_NAME = "ca.pem";
3030
public static final String KROXYLICIOUS_OPERATOR_SUBSCRIPTION_NAME = Environment.KROXYLICIOUS_OLM_DEPLOYMENT_NAME + "-v" + Environment.KROXYLICIOUS_OPERATOR_VERSION
3131
+ "-sub";
32-
public static final String KROXYLICIOUS_OPERATOR_OLM_LABEL = Environment.KROXYLICIOUS_OLM_DEPLOYMENT_NAME + "-operator-v" + Environment.KROXYLICIOUS_OPERATOR_VERSION;
3332

3433
/**
3534
* Strimzi cluster operator deployment name
@@ -120,10 +119,6 @@ private Constants() {
120119
public static final String KCAT_CLIENT_IMAGE = "quay.io/kroxylicious/kcat:1.7.1";
121120
public static final String KAF_CLIENT_IMAGE = "quay.io/kroxylicious/kaf:v0.2.7";
122121

123-
/**
124-
* The cert manager url to install it on kubernetes
125-
*/
126-
public static final String CERT_MANAGER_URL = "https://github.com/cert-manager/cert-manager/releases/latest/download/cert-manager.yaml";
127122
/**
128123
* the kubernetes labels used to identify the test kafka clients pods
129124
*/

kroxylicious-systemtests/src/main/java/io/kroxylicious/systemtests/installation/kroxylicious/CertManager.java

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,22 @@
77
package io.kroxylicious.systemtests.installation.kroxylicious;
88

99
import java.io.IOException;
10+
import java.nio.file.Path;
1011
import java.util.ArrayList;
1112
import java.util.List;
13+
import java.util.Map;
14+
import java.util.Optional;
1215

1316
import org.slf4j.Logger;
1417
import org.slf4j.LoggerFactory;
1518

1619
import io.fabric8.certmanager.api.model.v1.CertificateBuilder;
1720
import io.fabric8.certmanager.api.model.v1.IssuerBuilder;
18-
import io.fabric8.kubernetes.api.model.HasMetadata;
19-
import io.fabric8.kubernetes.client.dsl.NamespaceListVisitFromServerGetDeleteRecreateWaitApplicable;
2021

2122
import io.kroxylicious.systemtests.Constants;
2223
import io.kroxylicious.systemtests.resources.manager.ResourceManager;
23-
import io.kroxylicious.systemtests.utils.DeploymentUtils;
2424
import io.kroxylicious.systemtests.utils.NamespaceUtils;
25+
import io.kroxylicious.systemtests.utils.TestUtils;
2526

2627
import static io.kroxylicious.systemtests.k8s.KubeClusterResource.kubeClient;
2728

@@ -32,17 +33,21 @@ public class CertManager {
3233
private static final Logger LOGGER = LoggerFactory.getLogger(CertManager.class);
3334
public static final String SELF_SINGED_ISSUER_NAME = "self-signed-issuer";
3435

35-
private final NamespaceListVisitFromServerGetDeleteRecreateWaitApplicable<HasMetadata> deployment;
36+
public static final String CERT_MANAGER_SERVICE_NAME = "cert-manager";
37+
public static final String CERT_MANAGER_HELM_REPOSITORY_URL = "https://charts.jetstack.io";
38+
public static final String CERT_MANAGER_HELM_REPOSITORY_NAME = "jetstack";
39+
public static final String CERT_MANAGER_HELM_CHART_NAME = "jetstack/cert-manager";
40+
3641
private boolean deleteCertManager = true;
42+
private final String deploymentNamespace;
3743

3844
/**
3945
* Instantiates a new Cert manager.
4046
*
4147
* @throws IOException the io exception
4248
*/
4349
public CertManager() throws IOException {
44-
deployment = kubeClient().getClient()
45-
.load(DeploymentUtils.getDeploymentFileFromURL(Constants.CERT_MANAGER_URL));
50+
deploymentNamespace = Constants.CERT_MANAGER_NAMESPACE;
4651
}
4752

4853
public IssuerBuilder issuer(String namespace) {
@@ -103,10 +108,15 @@ public void deploy() {
103108
deleteCertManager = false;
104109
return;
105110
}
111+
106112
LOGGER.info("Deploy cert manager in {} namespace", Constants.CERT_MANAGER_NAMESPACE);
107-
deployment.create();
108-
DeploymentUtils.waitForDeploymentReady(Constants.CERT_MANAGER_NAMESPACE, "cert-manager-webhook");
109-
NamespaceUtils.addNamespaceToSet(Constants.CERT_MANAGER_NAMESPACE, ResourceManager.getTestContext().getRequiredTestClass().getName());
113+
NamespaceUtils.createNamespaceAndPrepare(deploymentNamespace);
114+
ResourceManager.helmClient().addRepository(CERT_MANAGER_HELM_REPOSITORY_NAME, CERT_MANAGER_HELM_REPOSITORY_URL);
115+
ResourceManager.helmClient().namespace(deploymentNamespace).install(CERT_MANAGER_HELM_CHART_NAME, CERT_MANAGER_SERVICE_NAME,
116+
Optional.empty(),
117+
Optional.of(Path.of(TestUtils.getResourcesURI("helm_cert_manager_overrides.yaml"))),
118+
Optional.of(Map.of("crds.enabled", "true",
119+
"crds.keep", "false")));
110120
}
111121

112122
/**
@@ -118,8 +128,7 @@ public void delete() {
118128
return;
119129
}
120130
LOGGER.info("Deleting Cert Manager in {} namespace", Constants.CERT_MANAGER_NAMESPACE);
121-
deployment.withGracePeriod(0).delete();
122-
DeploymentUtils.waitForDeploymentDeletion(Constants.CERT_MANAGER_NAMESPACE, "cert-manager-webhook");
131+
ResourceManager.helmClient().delete(deploymentNamespace, CERT_MANAGER_SERVICE_NAME);
123132
NamespaceUtils.deleteNamespaceWithWaitAndRemoveFromSet(Constants.CERT_MANAGER_NAMESPACE, ResourceManager.getTestContext().getRequiredTestClass().getName());
124133
}
125134
}

kroxylicious-systemtests/src/main/java/io/kroxylicious/systemtests/resources/operator/KroxyliciousOperatorOlmBundleInstaller.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636

3737
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
3838

39+
import static io.kroxylicious.systemtests.k8s.KubeClusterResource.kubeClient;
40+
3941
/**
4042
* KroxyliciousOperatorOlmBundleInstaller encapsulates the whole OLM installation process of Kroxylicious Operator. Based on the @code{Environment}
4143
* values, this class installs Kroxylicious Operator using bundle olm.
@@ -167,8 +169,10 @@ private CompletableFuture<Void> install(String operatorName, String operatorName
167169
@SuppressFBWarnings("REC_CATCH_EXCEPTION")
168170
private boolean isOperatorReady(String ns) {
169171
try {
172+
String label = kubeClient().listPodsByPrefixInName(ns, Environment.KROXYLICIOUS_OLM_DEPLOYMENT_NAME).get(0).getMetadata()
173+
.getLabels().get("app.kubernetes.io/instance");
170174
PodUtils.waitForPodsReadyWithRestart(ns, new LabelSelectorBuilder()
171-
.withMatchLabels(Map.of("app.kubernetes.io/instance", Constants.KROXYLICIOUS_OPERATOR_OLM_LABEL)).build(),
175+
.withMatchLabels(Map.of("app.kubernetes.io/instance", label)).build(),
172176
1, true);
173177
LOGGER.info("Kroxylicious operator in namespace {} is ready", ns);
174178
return true;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#
2+
# Copyright Kroxylicious Authors.
3+
#
4+
# Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
5+
#
6+
7+
# Helm Overrides File for cert manager used by the system tests.
8+
image:
9+
tag: v1.18.0

kroxylicious-systemtests/src/test/java/io/kroxylicious/systemtests/OperatorChangeDetectionST.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,8 @@ void shouldUpdateDeploymentWhenVirtualKafkaClusterChanges(String namespace) {
122122
}
123123

124124
@Test
125-
void shouldUpdateDeploymentWhenDownstreamTlsCertUpdated(String namespace) throws IOException {
125+
void shouldUpdateDeploymentWhenDownstreamTlsCertUpdated(String namespace) {
126126
// Given
127-
certManager = new CertManager();
128-
certManager.deploy();
129-
130127
var issuer = certManager.issuer(namespace);
131128
var cert = certManager.certFor(namespace, "my-cluster-cluster-ip." + namespace + ".svc.cluster.local");
132129

@@ -151,11 +148,8 @@ void shouldUpdateDeploymentWhenDownstreamTlsCertUpdated(String namespace) throws
151148
}
152149

153150
@Test
154-
void shouldUpdateDeploymentWhenDownstreamTrustUpdated(String namespace) throws IOException {
151+
void shouldUpdateDeploymentWhenDownstreamTrustUpdated(String namespace) {
155152
// Given
156-
certManager = new CertManager();
157-
certManager.deploy();
158-
159153
var issuer = certManager.issuer(namespace);
160154
var cert = certManager.certFor(namespace, "my-cluster-cluster-ip." + namespace + ".svc.cluster.local");
161155

@@ -285,8 +279,10 @@ private static void assertDeploymentUpdated(String namespace, String originalChe
285279
}
286280

287281
@BeforeEach
288-
void setUp(String namespace) {
282+
void setUp(String namespace) throws IOException {
289283
kroxylicious = new Kroxylicious(namespace);
284+
certManager = new CertManager();
285+
certManager.deploy();
290286
}
291287

292288
@AfterAll
@@ -309,7 +305,7 @@ private String getInitialChecksum(String namespace) {
309305
var kubeClient = kubeClient(namespace);
310306
AtomicReference<String> checksumFromAnnotation = new AtomicReference<>();
311307
await().atMost(Duration.ofSeconds(90))
312-
.untilAsserted(() -> kubeClient.listPods(namespace, "app.kubernetes.io/name", "kroxylicious-proxy"),
308+
.untilAsserted(() -> kubeClient.listPods(namespace, "app.kubernetes.io/name", "kroxylicious"),
313309
proxyPods -> {
314310
assertThat(proxyPods)
315311
.singleElement()

0 commit comments

Comments
 (0)