Skip to content
Skills Library
DevOps & cloud · Review & audit

checking-operator-rbac

/checking-operator-rbac

Checks a Go Kubernetes operator or controller for API calls its RBAC doesn't grant. Type-checks the code, maps every controller-runtime and client-go call (Get, List, Create, Update, Patch, Delete, Status().Update, CreateOrUpdate, For/Owns watches, event recorders, typed clientsets, shared informers) to the group, resource and verb it needs, and compares them with +kubebuilder:rbac markers or a Role/ClusterRole YAML file. Use when an operator logs "forbidden" or "cannot list resource", when a cached Get hangs, after adding a new resource or client call, when reviewing a controller PR, or befor

Repository
rbacgap ↗
Licence
MIT
Last repository change
07.11.2026

Assessment and security

90/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content25 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 07.11.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Checks a Go Kubernetes operator or controller for API calls its RBAC doesn't grant. Type-checks the code, maps every controller-runtime and client-go call (Get, List, Create, Update, Patch, Delete, Status().Update, CreateOrUpdate, For/Owns watches, event recorders, typed clientsets, shared informers) to the group, resource and verb it needs, and compares them with +kubebuilder:rbac markers or a Role/ClusterRole YAML file. Use when an operator logs "forbidden" or "cannot list resource", when a cached Get hangs, after adding a new resource or client call, when reviewing a controller PR, or befor

Triggers from the description

forbiddencannot list resource
Original author description

Checks a Go Kubernetes operator or controller for API calls its RBAC doesn't grant. Type-checks the code, maps every controller-runtime and client-go call (Get, List, Create, Update, Patch, Delete, Status().Update, CreateOrUpdate, For/Owns watches, event recorders, typed clientsets, shared informers) to the group, resource and verb it needs, and compares them with +kubebuilder:rbac markers or a Role/ClusterRole YAML file. Use when an operator logs "forbidden" or "cannot list resource", when a cached Get hangs, after adding a new resource or client call, when reviewing a controller PR, or befor

How it works

  1. 1. Find what to check
  2. 2. Run it
  3. Exit codes
  4. Report
Original SKILL.md headings · 32 lines, 607 words
SKILL.md preview
---
name: checking-operator-rbac
description: Checks a Go Kubernetes operator or controller for API calls its RBAC doesn't grant. Type-checks the code, maps every controller-runtime and client-go call (Get, List, Create, Update, Patch, Delete, Status().Update, CreateOrUpdate, For/Owns watches, event recorders, typed clientsets, shared informers) to the group, resource and verb it needs, and compares them with +kubebuilder:rbac markers or a Role/ClusterRole YAML file. Use when an operator logs "forbidden" or "cannot list resource", when a cached Get hangs, after adding a new resource or client call, when reviewing a controller PR, or before releasing an operator.
---

# Checking an operator's RBAC against its code

The bundled tool needs Go 1.22 or newer and the operator's module dependencies (it runs `go list -export`, which compiles packages without linking). It never runs the operator's code, never talks to a cluster, and never edits files.

## 1. Find what to check

- **The binary.** Find the manager's `main` package: `cmd/main.go`, `cmd/manager/main.go` or `main.go` in kubebuilder and Operator SDK projects. Each binary with its own ServiceAccount has its own RBAC, so check each one separately by passing its package. The tool checks that package and every package of the module it imports.
- **The RBAC.** If the code has `// +kubebuilder:rbac:` markers, the tool reads them itself. If the RBAC is a hand-written file, pass it with `--role`, once per file: `config/rbac/role.yaml`, a file under `deploy/`, or `kubectl get clusterrole NAME -o yaml` saved to a file. Helm templates must be rendered first with `helm template`, then split so each file holds plain Role or ClusterRole documents. Leader election RBAC (leases, and configmaps for old versions) usually lives in a separate role that isn't in the markers; that's expected and not checked.

## 2. Run it

Run from the operator's module directory, so the same Go toolchain builds the tool and the code:

    go run "${CLAUDE_PLUGIN_ROOT}/scripts/rbacgap.go" ./cmd

Add `--role config/rbac/role.yaml` for a role file, `--format json` to parse the result, `--calls` to list every call and what it needs, and `--unused` to list granted verbs no call needs. If the project needs a non-default modfile or vendoring, set `GOFLAGS` as its Makefile does.

## Exit codes

0 means every call the tool resolved is granted. It doesn't prove the operator has every permission it needs: read the UNCHECKED and GUESSED lines. 1 means MISSING permissions, or markers and role rules that grant nothing. 2 means the tool couldn't trust its input: a package that doesn't compile, a `go list` failure, a malformed live marker, a role file it can't read, no markers and no `--role`, or no API calls at all. Treat 2 as unknown, never as a pass. `--fail-on unchecked` also exits 1 for UNCHECKED and GUESSED lines, and `--fail-on none` only reports.

## Report

1. For each MISSING line, show the resource, the verbs and the call sites, and the `fix:` marker or rule. Explain the "cached client" reason when it appears: the manager's default client serves Get and List from an informer, which needs list and watch even when the code only calls Get.
2. For each MARKER line, say why it grants nothing: attached to a declaration (controller-gen ignores it, so it needs a blank line after it), an uppercase verb, or a verb that isn't a Kubernetes verb.
3. List UNCHECKED calls as not verified: unstructured objects, dynamic clients, helpers that take `client.Object`, and subresource writers held in variables. Offer to trace a helper's callers by hand if the user wants.
4. Mention PARTIAL lines (granted only in one namespace or for named objects) and MAYBE lines (only needed with some admission plugins, or if a mutate function changes status) as things to confirm, not errors.
5. Calls through a client built for another cluster are checked against this module's RBAC too. If a finding's call site uses such a client, say so instead of suggesting a marker.
6. Permissions granted by other bindings in the cluster (aggregated roles, OpenShift defaults) aren't visible to the tool. Say so if a finding may be covered that way.
7. Don't edit markers or role files unless the user asks. After an edit, rerun the tool, and for markers remind them to run `make manifests`.

Versions

The database has no other skills named checking-operator-rbac.

Database snapshot: 13.11.2026 · package version 1f74373810d6 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 1 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 90kubernetes-operator
    Use when building a Kubernetes Operator — custom controllers that reconcile CRD state. Triggers on "build an operator", "CRD design", "reconcile loop", "controller-runtime", "kubebuilder", "operator-sdk", "custom resource", or "operator capability levels". NOT a generic k8s…
  • 100k8s-rbac-troubleshooting
    Use when a Kubernetes request is refused by RBAC: "Error from server (Forbidden)", "User ... cannot list resource ... in the namespace" or "at the cluster scope", a ServiceAccount, controller, CI job or person getting 403, a RoleBinding that does not seem to apply (wrong…
  • 95cloud-native-k8s-operators
    Use this skill when the user says 'how do operators work', 'reconciliation loop', 'informer', 'work queue', 'controller pattern', 'level-triggered', 'custom resource definition basics', 'should I write an operator', 'operator vs helm'. Explains the controller/operator mechanics…
  • 90devops-kubernetes-operators
    Use when the user asks about Kubernetes operators, custom controllers, operator pattern, Kubebuilder, Operator SDK, custom resource definitions (CRD), reconciliation loops, or extending Kubernetes with custom resources. Covers: Kubebuilder project structure, controller-runtime…
  • 100manage-roles
    Manage Harness RBAC roles, role assignments, permissions, and resource groups via MCP v2 tools. List, create, update, and delete custom roles. View role assignments and permissions for users, groups, and service accounts. Use when asked to manage access control, assign roles,…
  • 90kubernetes-rbac-review
    Use this skill for Kubernetes RBAC, Role, ClusterRole, RoleBinding, ClusterRoleBinding, ServiceAccount, workload identity, or least-privilege review tasks. Trigger when the user asks whether cluster access is too broad, how to grant workload permissions safely, or how to audit RBAC state.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.