From 25211384adba94d57b5b5f0477f687e255a8486d Mon Sep 17 00:00:00 2001 From: Jose Date: Tue, 5 Jul 2022 09:27:46 +0200 Subject: [PATCH] Set service account name only to the generated deployment This change is related to this comment: https://github.com/quarkusio/quarkus/pull/25750#issuecomment-1172592901 --- .../kubernetes/deployment/KubernetesCommonHelper.java | 2 +- .../WithKubernetesClientAndExistingResourcesTest.java | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesCommonHelper.java b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesCommonHelper.java index 71671cbc59c71..d7ad929cfad5c 100644 --- a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesCommonHelper.java +++ b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesCommonHelper.java @@ -183,7 +183,7 @@ public static List createDecorators(Optional projec //Handle RBAC if (!roleBindings.isEmpty()) { - result.add(new DecoratorBuildItem(target, new ApplyServiceAccountNameDecorator(name))); + result.add(new DecoratorBuildItem(target, new ApplyServiceAccountNameDecorator(name, name))); result.add(new DecoratorBuildItem(target, new AddServiceAccountResourceDecorator(name))); roles.forEach(r -> result.add(new DecoratorBuildItem(target, new AddRoleResourceDecorator(name, r)))); roleBindings.forEach(rb -> { diff --git a/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/WithKubernetesClientAndExistingResourcesTest.java b/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/WithKubernetesClientAndExistingResourcesTest.java index 76c9d1f1d12d3..70edcdce96b52 100644 --- a/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/WithKubernetesClientAndExistingResourcesTest.java +++ b/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/WithKubernetesClientAndExistingResourcesTest.java @@ -51,7 +51,12 @@ public void assertGeneratedResources() throws IOException { assertThat(kubernetesList).filteredOn(h -> "Deployment".equals(h.getKind())).allSatisfy(h -> { Deployment deployment = (Deployment) h; - assertThat(deployment.getSpec().getTemplate().getSpec().getServiceAccountName()).isEqualTo(APPLICATION_NAME); + String serviceAccountName = deployment.getSpec().getTemplate().getSpec().getServiceAccountName(); + if (h.getMetadata().getName().equals(APPLICATION_NAME)) { + assertThat(serviceAccountName).isEqualTo(APPLICATION_NAME); + } else { + assertThat(serviceAccountName).isNull(); + } }); assertThat(kubernetesList).filteredOn(h -> "ServiceAccount".equals(h.getKind())).singleElement().satisfies(h -> {