⚠️ Disclaimer: This tool is under active development. Features are limited, APIs may change, and code may undergo drastic revisions.
The kubectl-tenant plugin extends kubectl with the tenant command group, enabling secure, close-to-native interactions with Stakater's Multi Tenant Operator.
It provides tenant-scoped Kubernetes operations to simplify cluster multi-tenancy and improve security by filtering results according to tenant context.
# Get tenant-scoped resources
kubectl tenant get <resource> <tenant>
# Example: Get storage classes for my-tenant
kubectl tenant get storageclasses my-tenant- Adds a
kubectl tenantsubcommand set. - Functions like
kubectl get <resource>but filters output for the specified tenant. - Ensures tenants can only discover their own resources instead of all resources available in the cluster (limitation of native RBAC on
list).
| Resource | Command Keyword |
|---|---|
| Storage Classes | storageclasses |
| Namespaces | namespaces |
- A running cluster with Multi Tenant Operator installed.
kubectl(orocon OpenShift).
Download the prebuilt binary for your platform from the GitHub Releases, place it somewhere on your system, and make sure that directory is in your $PATH.
# Download for your OS/Arch
curl -L https://github.com/stakater/kubectl-tenant/releases/download/v0.0.1/kubectl-tenant-linux-amd64 -o kubectl-tenant
chmod +x kubectl-tenant
mv kubectl-tenant ~/.local/bin/ # ensure this path is in your $PATHStorage Classes
kubectl tenant get storageclasses my-tenantExample output:
NAME PROVISIONER AGE
my-tenant-sc kubernetes.io/no-provisioner 5dNamespaces
kubectl tenant get namespaces my-tenantExample output:
NAME AGE
my-tenant-prod 5d
my-tenant-sandbox 7dIf you prefer to build the plugin yourself:
# Clone the repository
git clone https://github.com/stakater/kubectl-tenant.git
cd kubectl-tenant
# Build and install the plugin
go build -o kubectl-tenant
mv kubectl-tenant ~/.local/bin/This plugin includes built-in documentation generation using Cobra's doc generator. The generated Markdown files provide a complete CLI reference that is suitable for users, maintainers, and AI/LLM indexing.
Generate documentation:
kubectl-tenant docs # Generates in ./docs/
kubectl-tenant docs -o /custom/path # Custom output directoryThe documentation is automatically generated and updated during releases, and can be found in the docs/ directory.
- Multi Tenant Operator: https://www.stakater.com/multi-tenant-operator
- Tenant Operator Docs: https://docs.stakater.com/mto/latest/index.html
- kubectl Plugin Mechanism: https://kubernetes.io/docs/tasks/extend-kubectl/kubectl-plugins/
- OpenShift
ocPlugin Docs: https://docs.redhat.com/en/documentation/openshift_container_platform/4.18/html/cli_tools/openshift-cli-oc#cli-extend-plugins
- Additional tenant-scoped resources (IngressClasses, etc.).
Apache 2.0