ClusterRole

Default version: rbac.authorization.k8s.io/v1

Example

use RenokiCo\PhpK8s\Kinds\K8sPod;

$rule = K8s::rule()
    ->core()
    ->addResources([K8sPod::class, 'configmaps'])
    ->addResourceNames(['pod-name', 'configmap-name'])
    ->addVerbs(['get', 'list', 'watch']);

$role = $this->cluster
    ->clusterRole()
    ->setName('admin')
    ->setLabels(['tier' => 'backend'])
    ->addRules([$rule])
    ->create();

Getting Rules

You can get the rules as RenokiCo\PhpK8s\Instances\Rule instances:

foreach ($role->getRules() as $role) {
    //
}

Last updated