Search in sources :

Example 11 with ClusterRoleBindingBuilder

use of io.fabric8.kubernetes.api.model.rbac.ClusterRoleBindingBuilder in project strimzi-kafka-operator 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 12 with ClusterRoleBindingBuilder

use of io.fabric8.kubernetes.api.model.rbac.ClusterRoleBindingBuilder in project strimzi-kafka-operator by strimzi.

the class ClusterRoleBindingResource method clusterRoleBinding.

public static ClusterRoleBinding clusterRoleBinding(ExtensionContext extensionContext, String yamlPath, String namespace) {
    LOGGER.info("Creating ClusterRoleBinding in test case {} from {} in namespace {}", extensionContext.getDisplayName(), yamlPath, namespace);
    ClusterRoleBinding clusterRoleBinding = getClusterRoleBindingFromYaml(yamlPath);
    clusterRoleBinding = new ClusterRoleBindingBuilder(clusterRoleBinding).editFirstSubject().withNamespace(namespace).endSubject().build();
    ResourceManager.getInstance().createResource(extensionContext, clusterRoleBinding);
    return clusterRoleBinding;
}
Also used : ClusterRoleBindingBuilder(io.fabric8.kubernetes.api.model.rbac.ClusterRoleBindingBuilder) ClusterRoleBinding(io.fabric8.kubernetes.api.model.rbac.ClusterRoleBinding)

Aggregations

ClusterRoleBindingBuilder (io.fabric8.kubernetes.api.model.rbac.ClusterRoleBindingBuilder)12 ClusterRoleBinding (io.fabric8.kubernetes.api.model.rbac.ClusterRoleBinding)8 SubjectBuilder (io.fabric8.kubernetes.api.model.rbac.SubjectBuilder)8 RoleRefBuilder (io.fabric8.kubernetes.api.model.rbac.RoleRefBuilder)6 RoleRef (io.fabric8.kubernetes.api.model.rbac.RoleRef)4 Subject (io.fabric8.kubernetes.api.model.rbac.Subject)4 Secret (io.fabric8.kubernetes.api.model.Secret)2 Service (io.fabric8.kubernetes.api.model.Service)2 ServiceAccount (io.fabric8.kubernetes.api.model.ServiceAccount)2 ServiceAccountBuilder (io.fabric8.kubernetes.api.model.ServiceAccountBuilder)2 ValidatingWebhookConfiguration (io.fabric8.kubernetes.api.model.admissionregistration.v1.ValidatingWebhookConfiguration)2 ClusterRole (io.fabric8.kubernetes.api.model.rbac.ClusterRole)2 File (java.io.File)2 ArrayList (java.util.ArrayList)2