From 424b3ce24c8be2f0c1c183ee63aebd4d2700ddfc Mon Sep 17 00:00:00 2001 From: Matheus Cruz Date: Sun, 29 Sep 2024 13:12:44 -0300 Subject: [PATCH] Remove namespace from cluster resources --- .../kubernetes/deployment/AddNamespaceDecorator.java | 6 ++++++ .../quarkus/it/kubernetes/KubernetesWithRbacFullTest.java | 2 ++ 2 files changed, 8 insertions(+) diff --git a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/AddNamespaceDecorator.java b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/AddNamespaceDecorator.java index 3e04125891e8e..64f7c71e7a4ce 100644 --- a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/AddNamespaceDecorator.java +++ b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/AddNamespaceDecorator.java @@ -43,4 +43,10 @@ public boolean equals(Object o) { public int hashCode() { return Objects.hash(namespace); } + + @Override + public Class[] before() { + // this is necessary because cluster resources does not have namespace. + return new Class[] { AddClusterRoleBindingResourceDecorator.class, AddClusterRoleResourceDecorator.class }; + } } diff --git a/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithRbacFullTest.java b/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithRbacFullTest.java index 83be5e5411d86..88da309588f08 100644 --- a/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithRbacFullTest.java +++ b/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/KubernetesWithRbacFullTest.java @@ -84,6 +84,7 @@ public void assertGeneratedResources() throws IOException { // secret-reader assertions ClusterRole secretReaderRole = getClusterRoleByName(kubernetesList, "secret-reader"); + assertThat(secretReaderRole.getMetadata().getNamespace()).isNull(); assertThat(secretReaderRole.getRules()).satisfiesOnlyOnce(r -> { assertThat(r.getApiGroups()).containsExactly(""); assertThat(r.getResources()).containsExactly("secrets"); @@ -111,6 +112,7 @@ public void assertGeneratedResources() throws IOException { assertEquals("Group", clusterSubject.getKind()); assertEquals("manager", clusterSubject.getName()); assertEquals("rbac.authorization.k8s.io", clusterSubject.getApiGroup()); + assertThat(clusterRoleBinding.getMetadata().getNamespace()).isNull(); } private int lastIndexOfKind(String content, String... kinds) {