diff --git a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/AddRoleBindingResourceDecorator.java b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/AddRoleBindingResourceDecorator.java deleted file mode 100644 index 4108bd509859a..0000000000000 --- a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/AddRoleBindingResourceDecorator.java +++ /dev/null @@ -1,62 +0,0 @@ -package io.quarkus.kubernetes.deployment; - -import java.util.Collections; - -import io.dekorate.kubernetes.decorator.ResourceProvidingDecorator; -import io.dekorate.utils.Strings; -import io.fabric8.kubernetes.api.model.KubernetesListBuilder; -import io.fabric8.kubernetes.api.model.ObjectMeta; -import io.fabric8.kubernetes.api.model.rbac.RoleBindingBuilder; - -/** - * Workaround for: https://github.com/dekorateio/dekorate/issues/987 - * Once the issue is fixed in upstream, and we bump the Dekorate version, we should delete this decorator. - */ -public class AddRoleBindingResourceDecorator extends ResourceProvidingDecorator { - - private static final String DEFAULT_RBAC_API_GROUP = "rbac.authorization.k8s.io"; - - public static enum RoleKind { - Role, - ClusterRole - } - - private final String serviceAccount; - private final String name; - private final String role; - private final RoleKind kind; - - public AddRoleBindingResourceDecorator(String name, String serviceAccount, String role, RoleKind kind) { - this.name = name; - this.serviceAccount = serviceAccount; - this.role = role; - this.kind = kind; - } - - public void visit(KubernetesListBuilder list) { - // If name is null, it will get the first deployment resource. - ObjectMeta meta = getMandatoryDeploymentMetadata(list, name); - String roleBindingName = meta.getName() + "-" + this.role; - String serviceAccount = Strings.isNotNullOrEmpty(this.serviceAccount) ? this.serviceAccount : meta.getName(); - - if (contains(list, "rbac.authorization.k8s.io/v1", "RoleBinding", roleBindingName)) { - return; - } - - list.addToItems(new RoleBindingBuilder() - .withNewMetadata() - .withName(roleBindingName) - .withLabels(Strings.isNotNullOrEmpty(name) ? getMandatoryDeploymentMetadata(list, name).getLabels() - : Collections.emptyMap()) - .endMetadata() - .withNewRoleRef() - .withKind(kind.name()) - .withName(role) - .withApiGroup(DEFAULT_RBAC_API_GROUP) - .endRoleRef() - .addNewSubject() - .withKind("ServiceAccount") - .withName(serviceAccount) - .endSubject()); - } -} 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..56daf241011d0 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 @@ -40,6 +40,7 @@ import io.dekorate.kubernetes.decorator.AddMountDecorator; import io.dekorate.kubernetes.decorator.AddPvcVolumeDecorator; import io.dekorate.kubernetes.decorator.AddReadinessProbeDecorator; +import io.dekorate.kubernetes.decorator.AddRoleBindingResourceDecorator; import io.dekorate.kubernetes.decorator.AddSecretVolumeDecorator; import io.dekorate.kubernetes.decorator.AddServiceAccountResourceDecorator; import io.dekorate.kubernetes.decorator.ApplicationContainerDecorator;