From 6265906ab087f1551deba6a1254714ff5c60e3f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Attila=20M=C3=A9sz=C3=A1ros?= Date: Mon, 3 Feb 2025 10:12:32 +0100 Subject: [PATCH 1/5] update to fabric8 7.1 and quarkus 3.18.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Attila Mészáros --- .../webhook/admission/AdmissionUtils.java | 4 ++-- pom.xml | 2 +- samples/quarkus/pom.xml | 16 +++++++++------- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/core/src/main/java/io/javaoperatorsdk/webhook/admission/AdmissionUtils.java b/core/src/main/java/io/javaoperatorsdk/webhook/admission/AdmissionUtils.java index 5ae7cb1f..80085c5f 100644 --- a/core/src/main/java/io/javaoperatorsdk/webhook/admission/AdmissionUtils.java +++ b/core/src/main/java/io/javaoperatorsdk/webhook/admission/AdmissionUtils.java @@ -33,8 +33,8 @@ public static AdmissionResponse notAllowedExceptionToAdmissionResponse( public static KubernetesResource getTargetResource(AdmissionRequest admissionRequest, Operation operation) { - return operation == Operation.DELETE ? admissionRequest.getOldObject() - : admissionRequest.getObject(); + return (KubernetesResource) (operation == Operation.DELETE ? admissionRequest.getOldObject() + : admissionRequest.getObject()); } public static AdmissionResponse admissionResponseFromMutation(KubernetesResource originalResource, diff --git a/pom.xml b/pom.xml index 588a73de..2c32fc49 100644 --- a/pom.xml +++ b/pom.xml @@ -51,7 +51,7 @@ https://sonarcloud.io 5.10.2 - 6.13.4 + 7.1.0 1.7.36 2.24.3 5.14.2 diff --git a/samples/quarkus/pom.xml b/samples/quarkus/pom.xml index 4ec07e21..ad81f97e 100644 --- a/samples/quarkus/pom.xml +++ b/samples/quarkus/pom.xml @@ -15,7 +15,7 @@ UTF-8 quarkus-bom io.quarkus.platform - 3.11.0 + 3.18.1 true 3.5.2 @@ -43,6 +43,14 @@ io.quarkus quarkus-arc + + io.quarkus + quarkus-rest + + + io.quarkus + quarkus-rest-jackson + io.quarkus quarkus-junit5 @@ -53,15 +61,10 @@ quarkus-certmanager 1.0.3 - - io.quarkus - quarkus-resteasy-reactive-jackson - io.quarkus quarkus-minikube - io.quarkus quarkus-container-image-jib @@ -71,7 +74,6 @@ rest-assured test - org.assertj assertj-core From 65e08cb561cb103a4cca21536a4846cfc90252c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Attila=20M=C3=A9sz=C3=A1ros?= Date: Mon, 3 Feb 2025 10:17:14 +0100 Subject: [PATCH 2/5] format MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Attila Mészáros --- .../io/javaoperatorsdk/webhook/admission/AdmissionUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/io/javaoperatorsdk/webhook/admission/AdmissionUtils.java b/core/src/main/java/io/javaoperatorsdk/webhook/admission/AdmissionUtils.java index 80085c5f..cdf044fb 100644 --- a/core/src/main/java/io/javaoperatorsdk/webhook/admission/AdmissionUtils.java +++ b/core/src/main/java/io/javaoperatorsdk/webhook/admission/AdmissionUtils.java @@ -34,7 +34,7 @@ public static AdmissionResponse notAllowedExceptionToAdmissionResponse( public static KubernetesResource getTargetResource(AdmissionRequest admissionRequest, Operation operation) { return (KubernetesResource) (operation == Operation.DELETE ? admissionRequest.getOldObject() - : admissionRequest.getObject()); + : admissionRequest.getObject()); } public static AdmissionResponse admissionResponseFromMutation(KubernetesResource originalResource, From e1dd7dfd25e019afad25de50c20af9529475bf31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Attila=20M=C3=A9sz=C3=A1ros?= Date: Mon, 3 Feb 2025 10:41:25 +0100 Subject: [PATCH 3/5] fabric8 bom MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Attila Mészáros --- samples/spring-boot/pom.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/samples/spring-boot/pom.xml b/samples/spring-boot/pom.xml index 2762ac96..3715c8d6 100644 --- a/samples/spring-boot/pom.xml +++ b/samples/spring-boot/pom.xml @@ -26,6 +26,13 @@ pom import + + io.fabric8 + kubernetes-client-bom + ${fabric8-client.version} + pom + import + From 8c45da29d6deab978178971090d61f4520a07645 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Attila=20M=C3=A9sz=C3=A1ros?= Date: Mon, 3 Feb 2025 11:23:24 +0100 Subject: [PATCH 4/5] improve MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Attila Mészáros --- pom.xml | 2 +- samples/commons/pom.xml | 1 - samples/spring-boot/k8s/kubernetes.yml | 131 ++++++++++++++++++ samples/spring-boot/pom.xml | 28 ---- .../springboot/SpringBootWebhooksE2E.java | 7 +- 5 files changed, 137 insertions(+), 32 deletions(-) create mode 100644 samples/spring-boot/k8s/kubernetes.yml diff --git a/pom.xml b/pom.xml index 2c32fc49..02b5e9f7 100644 --- a/pom.xml +++ b/pom.xml @@ -73,7 +73,7 @@ 3.2.7 3.3.1 2.43.0 - 3.4.1 + 3.4.2 diff --git a/samples/commons/pom.xml b/samples/commons/pom.xml index edaf133e..fd8d3eb0 100644 --- a/samples/commons/pom.xml +++ b/samples/commons/pom.xml @@ -47,7 +47,6 @@ org.junit.jupiter junit-jupiter-api - test diff --git a/samples/spring-boot/k8s/kubernetes.yml b/samples/spring-boot/k8s/kubernetes.yml new file mode 100644 index 00000000..75654b39 --- /dev/null +++ b/samples/spring-boot/k8s/kubernetes.yml @@ -0,0 +1,131 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + annotations: + app.dekorate.io/vcs-url: <> + labels: + app.kubernetes.io/name: spring-boot-sample + app.kubernetes.io/version: 1.1.7-SNAPSHOT + name: spring-boot-sample +spec: + replicas: 1 + selector: + matchLabels: + app.kubernetes.io/name: spring-boot-sample + app.kubernetes.io/version: 1.1.7-SNAPSHOT + template: + metadata: + annotations: + app.dekorate.io/vcs-url: <> + labels: + app.kubernetes.io/name: spring-boot-sample + app.kubernetes.io/version: 1.1.7-SNAPSHOT + spec: + containers: + - env: + - name: KUBERNETES_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + - name: SERVER_SSL_KEY_STORE + value: /etc/certs/keystore.p12 + - name: SERVER_SSL_KEY_STORE_PASSWORD + valueFrom: + secretKeyRef: + key: password + name: pkcs12-pass + image: test/spring-boot-sample:1.1.7-SNAPSHOT + imagePullPolicy: IfNotPresent + name: spring-boot-sample + ports: + - containerPort: 443 + name: http + protocol: TCP + volumeMounts: + - mountPath: /etc/certs + name: volume-certs + readOnly: true + volumes: + - name: volume-certs + secret: + optional: false + secretName: tls-secret +--- +apiVersion: v1 +kind: Secret +metadata: + name: pkcs12-pass +data: + password: c3VwZXJzZWNyZXQ= +type: Opaque +--- +apiVersion: cert-manager.io/v1 +kind: Issuer +metadata: + annotations: + app.dekorate.io/vcs-url: <> + labels: + app.kubernetes.io/name: spring-boot-sample + app.kubernetes.io/version: 1.1.7-SNAPSHOT + name: spring-boot-sample +spec: + selfSigned: {} +--- +apiVersion: v1 +kind: Service +metadata: + annotations: + app.dekorate.io/vcs-url: <> + labels: + app.kubernetes.io/name: spring-boot-sample + app.kubernetes.io/version: 1.1.7-SNAPSHOT + name: spring-boot-sample +spec: + ports: + - name: http + port: 443 + protocol: TCP + targetPort: 443 + selector: + app.kubernetes.io/name: spring-boot-sample + app.kubernetes.io/version: 1.1.7-SNAPSHOT + type: ClusterIP +--- +apiVersion: cert-manager.io/v1 +kind: Certificate +metadata: + annotations: + app.dekorate.io/vcs-url: <> + labels: + app.kubernetes.io/name: spring-boot-sample + app.kubernetes.io/version: 1.1.7-SNAPSHOT + name: spring-boot-sample +spec: + dnsNames: + - spring-boot-sample.default.svc + - localhost + duration: 7776000000000000ns + encodeUsagesInRequest: false + isCA: false + issuerRef: + name: spring-boot-sample + keystores: + pkcs12: + create: true + passwordSecretRef: + key: password + name: pkcs12-pass + privateKey: + algorithm: RSA + encoding: PKCS8 + size: 2048 + renewBefore: 1296000000000000ns + secretName: tls-secret + subject: + organizations: + - Dekorate + - Community + usages: + - server auth + - client auth diff --git a/samples/spring-boot/pom.xml b/samples/spring-boot/pom.xml index 3715c8d6..f7143965 100644 --- a/samples/spring-boot/pom.xml +++ b/samples/spring-boot/pom.xml @@ -12,7 +12,6 @@ Kubernetes Webhooks Framework - Samples - Spring Boot - 17 3.4.4 4.1.4 @@ -26,13 +25,6 @@ pom import - - io.fabric8 - kubernetes-client-bom - ${fabric8-client.version} - pom - import - @@ -87,26 +79,6 @@ test-jar test - - io.dekorate - kubernetes-spring-starter - ${dekorate.version} - - - io.dekorate - certmanager-annotations - ${dekorate.version} - - - io.dekorate - kubernetes-annotations - ${dekorate.version} - - - io.dekorate - jib-annotations - ${dekorate.version} - diff --git a/samples/spring-boot/src/test/java/io/javaoperatorsdk/webhook/sample/springboot/SpringBootWebhooksE2E.java b/samples/spring-boot/src/test/java/io/javaoperatorsdk/webhook/sample/springboot/SpringBootWebhooksE2E.java index ad944a3d..44e5b9e1 100644 --- a/samples/spring-boot/src/test/java/io/javaoperatorsdk/webhook/sample/springboot/SpringBootWebhooksE2E.java +++ b/samples/spring-boot/src/test/java/io/javaoperatorsdk/webhook/sample/springboot/SpringBootWebhooksE2E.java @@ -5,6 +5,7 @@ import org.junit.jupiter.api.BeforeAll; +import io.fabric8.kubernetes.client.ConfigBuilder; import io.fabric8.kubernetes.client.KubernetesClientBuilder; import io.javaoperatorsdk.webhook.sample.AbstractEndToEndTest; @@ -15,12 +16,14 @@ class SpringBootWebhooksE2E extends AbstractEndToEndTest { @BeforeAll static void deployService() throws IOException { - try (var client = new KubernetesClientBuilder().build(); + try (var client = new KubernetesClientBuilder().withConfig(new ConfigBuilder() + .withNamespace("default") + .build()).build(); var certManager = new URL( "https://github.com/cert-manager/cert-manager/releases/download/v1.10.1/cert-manager.yaml") .openStream()) { applyAndWait(client, certManager); - applyAndWait(client, "target/classes/META-INF/dekorate/kubernetes.yml"); + applyAndWait(client, "k8s/kubernetes.yml"); applyAndWait(client, "k8s/validating-webhook-configuration.yml"); applyAndWait(client, "k8s/mutating-webhook-configuration.yml"); applyAndWait(client, From 0974131c554e4c1fddaaa6652fcb7d01d4191463 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Attila=20M=C3=A9sz=C3=A1ros?= Date: Mon, 3 Feb 2025 13:15:02 +0100 Subject: [PATCH 5/5] sb build image base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Attila Mészáros --- samples/spring-boot/pom.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/samples/spring-boot/pom.xml b/samples/spring-boot/pom.xml index f7143965..b634159e 100644 --- a/samples/spring-boot/pom.xml +++ b/samples/spring-boot/pom.xml @@ -88,6 +88,9 @@ jib-maven-plugin ${jib-maven-plugin.version} + + eclipse-temurin:17-jre + test/spring-boot-sample:${project.version}