Kubernetes RBAC Generator
{{ summaryTitle }}
{{ summaryLine }}
{{ resultsReady ? 'Draft artifacts updated.' : summaryLine }}
{{ status }}
{{ values.yaml_text }}
{{ status }}
| Rule | API group | Resources | Verbs | Resource names | Review cue | Copy |
|---|---|---|---|---|---|---|
| {{ cell }} |
{{ status }}
Matrix unavailable. The grant ledger retains every permission.
Similar tools
- Kubernetes Deployment Generator Build Kubernetes Deployment YAML with optional Service and policy resources, plus checks for rollout, probes, resources, and security choices.
- Kubernetes NetworkPolicy Generator Build Kubernetes NetworkPolicy YAML from pod labels and allow rules with selector checks, rollout guidance, and security review warnings.
- Kubernetes Pod Security Context Checker Check Kubernetes workload YAML for inherited security contexts, Pod Security gaps, weighted findings, and a hardening fragment for manual review.
- Kubernetes Resource Requests Checker Check Kubernetes manifests for missing resource requests and invalid limits, with QoS clues and scheduler-footprint evidence before rollout.
A dashboard that watches Pods needs different Kubernetes permissions from a deployment service that changes them. Giving both broad access can let an observing application change live resources. Kubernetes role-based access control (RBAC) expresses the API operations an identity may perform, so access can follow the work an application actually does.
Authentication establishes the identity making a request. Authorization decides whether that identity may perform the requested action. An application commonly authenticates as a ServiceAccount, while its RBAC rules determine which Kubernetes resources it can read or change. Possessing credentials and having permission are separate requirements.
- Namespace
- A named scope that separates resources such as Pods and ConfigMaps. A Pod named
webin one namespace is separate from a Pod with the same name in another. - ServiceAccount
- A named identity for workloads or automation. Its namespace is part of its identity.
- Role
- A set of permission rules within one namespace. Each rule identifies resources and the operations allowed on them.
- RoleBinding
- The object that grants a Role's permissions to a subject, such as a ServiceAccount. Creating a Role alone does not assign its permissions to an application.
For an application that observes Pods, the usual object-reading verbs are get, list, and watch. They cover reading an individual Pod, listing Pods, and following changes. Access to Pod logs or command execution is expressed separately through subresources such as pods/log and pods/exec. Permission to read a Pod does not automatically include those capabilities.
The resource, operation, namespace, and sometimes the object name all affect the grant. Reading one ConfigMap may require a narrower rule than watching every Pod in a namespace. Resources from different API groups also need the correct group identity, such as the core group for Pods and apps for Deployments. A Role cannot grant access to cluster-scoped objects such as Nodes. ClusterRole-based arrangements serve broader or reusable permission requirements.
Permissions from applicable RBAC rules and bindings accumulate. Adding a narrow Role does not cancel a broader grant elsewhere, and leaving an operation out of one rule does not create a deny rule. Least privilege therefore requires reviewing the account's existing access as well as the new permissions, then checking which operations the application actually needs.
Small grants can still have substantial consequences. Reading Secrets may reveal credentials, and permission to create workloads can allow access to mounted Secrets and other ServiceAccount identities. Restricting the namespace helps define the API scope, but the effect of a permission also depends on the resources and workloads reachable within it.
How to Use This Tool:
Prepare one Role and a matching RoleBinding for an existing ServiceAccount in one namespace. Results update as you edit. The starting demo example is synthetic, and the generator does not create the namespace or account.
- Enter the Namespace, Role name, and ServiceAccount name for the intended workload. The same namespace is used throughout. Under Advanced, leave Binding name override blank to use the Role name followed by
-binding, or enter a separate binding name. - Choose an API group and enter the supported plural tokens in Resources, separated by spaces or commas. Use Core (empty group) for resources such as
podsandconfigmaps. The supported resource list changes with the group. - Select the required Verbs and, when appropriate, enter exact names in Resource names (optional). Every selected verb applies to every resource in that rule. Use Add rule when another group, verb set, or name restriction needs a separate grant. Rules can also be duplicated or removed.
- Review the Grant ledger and its capability-specific cues when the summary reads Namespaced draft ready for review.
If the summary reads Permission inputs need attention, correct the identified field or rule. Successful outputs disappear while the input is invalid, and your entries remain editable. Changing an API group keeps the existing resource text, so it may need correction too.
- Copy or download the reviewed RBAC YAML and the Authorization checks text for your own review process. YAML and TXT downloads preserve those respective outputs. The commands remain text until you choose to run them in your own environment.
Interpreting Results:
The ready summary confirms that the inputs satisfy the generator's supported syntax and rule restrictions. It does not prove least privilege or live authorization. The ServiceAccount's existence and the operations supported by the cluster still need verification.
The Grant ledger records each rule's exact API group, resources, verbs, and name restrictions. All names means that the rule has no object-name restriction. Review cues identify specific capabilities that deserve attention. They are not a security score or certification, and a general reminder does not establish that a grant is low risk. The ledger can accompany a review as CSV or DOCX, and individual rows can be copied.
In the Verb matrix, Included means a verb appears in that draft rule. A dash, or Not in this rule in the backing data, means it is absent from that rule. Neither is a measurement of live access, and an absent cell is not a global deny. PNG, WebP, and JPEG exports preserve the visual comparison; the backing CSV preserves the exact membership labels with the rule's group, resources, and names. If the matrix cannot display, the ledger still contains every grant.
Authorization checks contains kubectl auth can-i commands for the specified ServiceAccount. Running them requires access to the intended cluster, the correct kubeconfig context, and permission to impersonate that account with --as. They query current authorization, including other applicable bindings. An unapplied YAML draft does not change their answers, and the generator promises no particular yes or no result.
Because an authorization check asks about permission without performing the requested operation, a positive answer does not establish that the object exists, the endpoint supports that operation, or admission controls will accept a real request. Verify the application's actual requests in the intended environment as well as reviewing its existing bindings.
Technical Details:
RBAC authorization matches a request against permission rules available to its identity. A matching rule must cover the request's API group, resource or subresource, verb, and any required object name within the applicable namespace. Any applicable rule matching all these conditions supplies an RBAC grant.
Rule Core
A RoleBinding makes its referenced Role available to the listed subject. Within that Role, the following fields describe which requests each rule permits.
| Rule field | Matching requirement | Practical consequence |
|---|---|---|
apiGroups |
The request belongs to a listed API group. | [""] identifies the core group. ["apps"] identifies the apps group. API versions such as v1 do not go here. |
resources |
The plural resource token, including any subresource, matches. | pods and pods/log are separate permission targets. A parent resource grant does not automatically cover its subresources. |
verbs |
The requested operation appears in the rule. | Every listed verb applies to every listed resource in that rule. |
resourceNames |
When present, the request identifies an allowed object name. | The restriction applies throughout the rule. Omitting it leaves names unrestricted, subject to the rule's other conditions. |
Combining pods and configmaps with get and patch permits both verbs on both resources. To allow Pod reads and ConfigMap changes separately, use separate rules. Rule order does not create priorities or exceptions, and an overlapping unrestricted grant can make a narrower name restriction ineffective for the account's overall RBAC access.
Role, binding, and subject consistency
The generated YAML contains exactly two documents separated by ---, a Role and a RoleBinding, both using rbac.authorization.k8s.io/v1. Names and rule values are quoted strings. The selected namespace appears in both objects' metadata and in the ServiceAccount subject.
The binding's roleRef uses apiGroup: rbac.authorization.k8s.io, kind: Role, and the emitted Role's exact name. The subject uses kind: ServiceAccount with its name and namespace, and omits apiGroup. Changing the binding-name override affects only the binding's metadata name, leaving its reference, subject, and grants unchanged.
A RoleBinding that references a Role must use a Role in its own namespace. Kubernetes also permits ServiceAccount subjects from other namespaces, but this generator deliberately keeps the Role, RoleBinding, and ServiceAccount subject in one namespace. Existing bindings have an immutable roleRef, so reusing a binding name does not permit an in-place switch to a different Role.
Verbs and object-name restrictions
The eight supported verbs describe API operations. For ordinary object requests, their meanings and name-restriction behavior are as follows. Connection subresources, such as command execution, need separate attention because the verb alone does not describe the capability's impact.
| Verb | Typical operation | With resourceNames |
|---|---|---|
get |
Read one object. | The requested object name must match an allowed name. |
list |
Read a collection of objects. | The request needs a matching metadata.name field selector. |
watch |
Receive object changes over time. | The request needs a matching metadata.name field selector. |
create |
Create a top-level object or make a creation request on a subresource. | Rejected for top-level resources. Accepted for supported named subresources such as pods/exec. |
update |
Update an existing object through a replacement request. | The requested object name must match an allowed name. |
patch |
Submit changes to an existing object. | The requested object name must match an allowed name. |
delete |
Delete one object. | The requested object name must match an allowed name. |
deletecollection |
Delete a collection of objects. | Rejected whenever resource names are supplied. |
Top-level creation cannot be restricted through resourceNames, because the new object's name is not available as the required authorization attribute. A named subresource request already identifies its parent object. This allows a rule for create on pods/exec to restrict the parent Pod by name. A rule mixing pods and pods/exec with create and a name restriction is rejected because it also includes top-level creation.
For named list and watch, the client must request one allowed name through a field selector such as metadata.name=app-config. RBAC does not turn a broad collection request into a filtered response. A can-i check containing an object name does not exercise the application's field selector. Object-name restrictions also do not select labels or restrict individual fields or keys inside an object.
The resource catalog and verb list are checked independently. A permitted combination in the draft does not establish that a corresponding operation exists on the cluster. Subresource support and the requests made by a particular client still require verification.
Capabilities that need closer review
Review cues follow the selected resources and operations. Their purpose is to draw attention to concrete consequences, including the following.
- Access to
secretscan expose credentials or change trusted data. Collection reads and watches can reveal Secret contents as well as individual reads. pods/exec,pods/attach, andpods/portforwardprovide sensitive access to running workloads. A name restriction narrows the targets without making that access harmless.- Creation on
serviceaccounts/tokencan request credentials for a ServiceAccount. The account being targeted matters as much as the verb. - Creating, updating, or patching workloads can enable code to run with mounted Secrets or namespace ServiceAccount identities. Changes involving
pods/ephemeralcontainersalso deserve this review. - Changes to
serviceaccountscan affect workload identity configuration. Deletion permissions can remove live resources. - The
defaultServiceAccount is used by Pods without an explicitly assigned account. A binding to that identity may affect several workloads.
Supported API groups and resources
Each rule accepts one of the following groups and only the tokens listed for it. Subresources must be written in full with their slash. This is the generator's explicit catalog, not a complete inventory of every Kubernetes API.
| API group | Resources | Subresources |
|---|---|---|
Core, "" |
pods, services, endpoints, configmaps, secrets, serviceaccounts, persistentvolumeclaims, events, replicationcontrollers, resourcequotas, limitranges |
pods/log, pods/exec, pods/attach, pods/portforward, pods/status, pods/eviction, pods/ephemeralcontainers, services/status, serviceaccounts/token, persistentvolumeclaims/status, replicationcontrollers/scale |
apps |
deployments, replicasets, statefulsets, daemonsets, controllerrevisions |
deployments/scale, deployments/status, replicasets/scale, replicasets/status, statefulsets/scale, statefulsets/status, daemonsets/status |
batch |
jobs, cronjobs |
jobs/status, cronjobs/status |
networking.k8s.io |
ingresses, networkpolicies |
ingresses/status |
autoscaling |
horizontalpodautoscalers |
horizontalpodautoscalers/status |
policy |
poddisruptionbudgets |
poddisruptionbudgets/status |
coordination.k8s.io |
leases |
None. |
Wildcards, unknown or custom groups, unlisted resources and subresources, and cluster-scoped resources are excluded. The generator does not produce ClusterRoles, ClusterRoleBindings, aggregated roles, non-resource URL rules, or grants to administer RBAC policy. The verbs impersonate, bind, and escalate are also excluded. These exclusions do not remove the need to review the sensitive supported capabilities above.
Identifier and rule bounds
The accepted names use a deliberately restricted lowercase DNS-style form. These are the generator's input limits. Kubernetes naming requirements vary by object type and must also be checked before use.
| Input | Accepted bound | Additional restriction |
|---|---|---|
| Namespace | 1 to 63 characters | Lowercase letters, digits, and hyphens. Must start and end with a letter or digit. Dots are not accepted. |
| Role name and ServiceAccount name | 1 to 63 characters each | The same characters, with dots permitted between nonempty parts. Each part must start and end with a letter or digit. |
| Binding name override | 1 to 253 characters, or blank | Uses the dotted name form. Blank derives the name from the Role. |
| Individual resource name | 1 to 253 characters | Uses the dotted name form and must be distinct within its rule. |
| Permission rules | 1 to 10 | Exactly one supported API group per rule. The last rule cannot be removed. |
| Resources per rule | 1 to 10 | Distinct supported tokens from the selected group. |
| Verbs per rule | 1 to 8 | Distinct verbs from the supported list. |
| Resource names per rule | 0 to 20 | No names means no name restriction. Commas or whitespace separate names. |
Identifiers are not silently lowercased or repaired. Spaces around identity names, uppercase letters, underscores, and unsupported punctuation are rejected. Resource and name lists allow commas or whitespace as separators, but duplicate entries within a rule are rejected. Duplicating a whole rule keeps it as a separate rule rather than combining it with an existing one.
The Resources field allows up to 1,000 characters and the Resource names field up to 5,080 characters per rule. The complete rule configuration is limited to 30,000 characters, and generated YAML is limited to 65,536 UTF-8 bytes, or 64 KiB. Unsupported configuration produces no successful manifest.
How authorization targets are represented
In kubectl auth can-i, a non-core resource includes its group, such as deployments.apps. A restricted object name follows a slash, while a subresource uses the separate --subresource option. Each generated check includes the namespace and the ServiceAccount identity, such as system:serviceaccount:demo:app-reader, with quoted arguments. Checks cover every selected resource, verb, and supplied name, or an unnamed target when names are unrestricted.
Privacy Notes:
Generation and input validation run in your browser. No cluster credentials are requested, and there is no remote cluster validation. The tool provides no saved draft history and does not execute kubectl or apply the YAML.
A shared page URL can contain the namespace, Role and ServiceAccount names, permission rules, resource names, and binding-name override. The address updates as you edit, so a configured URL may remain in browser history. Sharing or reopening it discloses the configuration to its recipient or to the server handling that page request. Browser-local generation does not make URL-carried data confidential. The matrix may also need an additional network download when first opened.
Worked Examples:
Observe Pods in the demo namespace
The default example uses namespace demo, Role and ServiceAccount app-reader, and one core-group rule for pods with get, list, and watch. Leaving resource names blank emits an unrestricted Pod-name grant and the binding app-reader-binding. The ledger shows All names, and only those three verbs are included in the matrix. The draft grants Pod observation in demo when bound and applied, with no grant for Pod logs or execution. The named ServiceAccount must already exist for the workload to use it.
Read and watch one named ConfigMap
For the existing config-reader ServiceAccount in review, use Role config-reader, binding override named-reader, core resource configmaps, verbs get list watch, and resource name app-config. The YAML includes resourceNames: ["app-config"]. Generated checks use the target configmaps/app-config, and the ledger calls out the required metadata.name=app-config selector. The application's real collection and watch requests need that selector; a successful named authorization check does not add it to those requests.
Restrict an execution subresource to one Pod
With namespace demo and ServiceAccount app-reader, a core-group rule containing only pods/exec, verb create, and resource name pod-1 is accepted. Its authorization check uses 'create' 'pods/pod-1' --subresource='exec'. The name refers to the existing parent Pod, so this is distinct from permission to create a Pod named pod-1. The ledger flags sensitive container access. Whether an execution client also needs other requests or permissions depends on that client and cluster, so the accepted rule does not certify that a complete execution session will succeed.
References:
- Using RBAC Authorization, Kubernetes.
- Authorization, Kubernetes.
- kubectl auth can-i, Kubernetes.
- Role Based Access Control Good Practices, Kubernetes.
- Service Accounts, Kubernetes.
- Object Names and IDs, Kubernetes.
- How to grant Kubernetes namespace access with RBAC, Simplified Guide.
- How to assign a Kubernetes ServiceAccount to a pod, Simplified Guide.