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 842648b23ae8a..ebec5a4e4e6ac 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 @@ -182,7 +182,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 -> {