Search in sources :

Example 1 with RoleRefBuilder

use of io.fabric8.kubernetes.api.model.rbac.RoleRefBuilder in project elastest-torm by elastest.

the class K8sService method deleteClusterRoleBindingAdmin.

public void deleteClusterRoleBindingAdmin(String name, String namespace) throws Exception {
    if (namespace != null && !"default".equals(namespace) && name != null && !"cluster-admin".equals("name")) {
        String role = "cluster-admin";
        logger.debug("Deleting Cluster Role Binding with name {} in the namespace {} with role {}", name, namespace, role);
        ClusterRoleBinding clusterRoleBinding = new ClusterRoleBindingBuilder().withNewMetadata().withName(name).endMetadata().withRoleRef(new RoleRefBuilder().withName(role).withKind("ClusterRole").withApiGroup("rbac.authorization.k8s.io").build()).withSubjects(new SubjectBuilder().withKind("ServiceAccount").withNamespace(namespace).withName("default").build()).build();
        client.rbac().clusterRoleBindings().delete(clusterRoleBinding);
        logger.debug("Cluster Role Binding with name {} deleted successfully from namespace {}", name, namespace);
    }
}
Also used : ClusterRoleBindingBuilder(io.fabric8.kubernetes.api.model.rbac.ClusterRoleBindingBuilder) ClusterRoleBinding(io.fabric8.kubernetes.api.model.rbac.ClusterRoleBinding) SubjectBuilder(io.fabric8.kubernetes.api.model.rbac.SubjectBuilder) RoleRefBuilder(io.fabric8.kubernetes.api.model.rbac.RoleRefBuilder)

Example 2 with RoleRefBuilder

use of io.fabric8.kubernetes.api.model.rbac.RoleRefBuilder in project elastest-torm by elastest.

the class K8sService method createClusterRoleBindingAdmin.

public void createClusterRoleBindingAdmin(String name, String namespace) throws Exception {
    String role = "cluster-admin";
    logger.debug("Creating Cluster Role Binding with name {} in the namespace {} with role {}", name, namespace, role);
    ClusterRoleBinding clusterRoleBinding = new ClusterRoleBindingBuilder().withNewMetadata().withName(name).endMetadata().withRoleRef(new RoleRefBuilder().withName(role).withKind("ClusterRole").withApiGroup("rbac.authorization.k8s.io").build()).withSubjects(new SubjectBuilder().withKind("ServiceAccount").withNamespace(namespace).withName("default").build()).build();
    client.rbac().clusterRoleBindings().create(clusterRoleBinding);
    logger.debug("Cluster Role Binding with name {} created successfully in the namespace {}", name, namespace);
}
Also used : ClusterRoleBindingBuilder(io.fabric8.kubernetes.api.model.rbac.ClusterRoleBindingBuilder) ClusterRoleBinding(io.fabric8.kubernetes.api.model.rbac.ClusterRoleBinding) SubjectBuilder(io.fabric8.kubernetes.api.model.rbac.SubjectBuilder) RoleRefBuilder(io.fabric8.kubernetes.api.model.rbac.RoleRefBuilder)

Example 3 with RoleRefBuilder

use of io.fabric8.kubernetes.api.model.rbac.RoleRefBuilder in project strimzi by strimzi.

the class ClusterRoleBindingOperatorIT method getOriginal.

@Override
protected ClusterRoleBinding getOriginal() {
    Subject ks = new SubjectBuilder().withKind("ServiceAccount").withName("my-service-account").withNamespace("my-namespace").build();
    RoleRef roleRef = new RoleRefBuilder().withName("my-cluster-role").withApiGroup("rbac.authorization.k8s.io").withKind("ClusterRole").build();
    return new ClusterRoleBindingBuilder().withNewMetadata().withName(resourceName).withLabels(singletonMap("state", "new")).endMetadata().withSubjects(ks).withRoleRef(roleRef).build();
}
Also used : RoleRef(io.fabric8.kubernetes.api.model.rbac.RoleRef) ClusterRoleBindingBuilder(io.fabric8.kubernetes.api.model.rbac.ClusterRoleBindingBuilder) SubjectBuilder(io.fabric8.kubernetes.api.model.rbac.SubjectBuilder) Subject(io.fabric8.kubernetes.api.model.rbac.Subject) RoleRefBuilder(io.fabric8.kubernetes.api.model.rbac.RoleRefBuilder)

Example 4 with RoleRefBuilder

use of io.fabric8.kubernetes.api.model.rbac.RoleRefBuilder in project strimzi by strimzi.

the class ClusterRoleBindingOperatorIT method getModified.

@Override
protected ClusterRoleBinding getModified() {
    Subject ks = new SubjectBuilder().withKind("ServiceAccount").withName("my-service-account2").withNamespace("my-namespace2").build();
    // RoleRef cannot be changed
    RoleRef roleRef = new RoleRefBuilder().withName("my-cluster-role").withApiGroup("rbac.authorization.k8s.io").withKind("ClusterRole").build();
    return new ClusterRoleBindingBuilder().withNewMetadata().withName(resourceName).withLabels(singletonMap("state", "modified")).endMetadata().withSubjects(ks).withRoleRef(roleRef).build();
}
Also used : RoleRef(io.fabric8.kubernetes.api.model.rbac.RoleRef) ClusterRoleBindingBuilder(io.fabric8.kubernetes.api.model.rbac.ClusterRoleBindingBuilder) SubjectBuilder(io.fabric8.kubernetes.api.model.rbac.SubjectBuilder) Subject(io.fabric8.kubernetes.api.model.rbac.Subject) RoleRefBuilder(io.fabric8.kubernetes.api.model.rbac.RoleRefBuilder)

Example 5 with RoleRefBuilder

use of io.fabric8.kubernetes.api.model.rbac.RoleRefBuilder in project strimzi by strimzi.

the class RoleBindingOperatorIT method getModified.

@Override
protected RoleBinding getModified() {
    Subject ks = new SubjectBuilder().withKind("ServiceAccount").withName("my-service-account2").withNamespace("my-namespace2").build();
    // RoleRef cannot be changed
    RoleRef roleRef = new RoleRefBuilder().withName("my-cluster-role").withApiGroup("rbac.authorization.k8s.io").withKind("ClusterRole").build();
    return new RoleBindingBuilder().withNewMetadata().withName(resourceName).withNamespace(namespace).withLabels(singletonMap("state", "modified")).endMetadata().withSubjects(ks).withRoleRef(roleRef).build();
}
Also used : RoleBindingBuilder(io.fabric8.kubernetes.api.model.rbac.RoleBindingBuilder) RoleRef(io.fabric8.kubernetes.api.model.rbac.RoleRef) SubjectBuilder(io.fabric8.kubernetes.api.model.rbac.SubjectBuilder) Subject(io.fabric8.kubernetes.api.model.rbac.Subject) RoleRefBuilder(io.fabric8.kubernetes.api.model.rbac.RoleRefBuilder)

Aggregations

RoleRefBuilder (io.fabric8.kubernetes.api.model.rbac.RoleRefBuilder)28 RoleRef (io.fabric8.kubernetes.api.model.rbac.RoleRef)24 SubjectBuilder (io.fabric8.kubernetes.api.model.rbac.SubjectBuilder)22 Subject (io.fabric8.kubernetes.api.model.rbac.Subject)18 RoleBinding (io.fabric8.kubernetes.api.model.rbac.RoleBinding)10 Role (io.fabric8.kubernetes.api.model.rbac.Role)8 RoleBindingBuilder (io.fabric8.kubernetes.api.model.rbac.RoleBindingBuilder)8 Kafka (io.strimzi.api.kafka.model.Kafka)6 KafkaBuilder (io.strimzi.api.kafka.model.KafkaBuilder)6 CertManager (io.strimzi.certs.CertManager)6 KubernetesVersion (io.strimzi.operator.KubernetesVersion)6 PlatformFeaturesAvailability (io.strimzi.operator.PlatformFeaturesAvailability)6 ClusterOperatorConfig (io.strimzi.operator.cluster.ClusterOperatorConfig)6 KafkaVersionTestUtils (io.strimzi.operator.cluster.KafkaVersionTestUtils)6 ResourceUtils (io.strimzi.operator.cluster.ResourceUtils)6 EntityOperator (io.strimzi.operator.cluster.model.EntityOperator)6 KafkaVersion (io.strimzi.operator.cluster.model.KafkaVersion)6 ResourceOperatorSupplier (io.strimzi.operator.cluster.operator.resource.ResourceOperatorSupplier)6 PasswordGenerator (io.strimzi.operator.common.PasswordGenerator)6 Reconciliation (io.strimzi.operator.common.Reconciliation)6