
Get security briefings from the Threat Research Team
New campaigns, attacker techniques, and detection guidance — straight to your inbox.
Falco Feeds extends the power of Falco by giving open source-focused companies access to expert-written rules that are continuously updated as new threats are discovered.

Updated December 2, 2026: This guide was refreshed for current Kubernetes releases. What changed: a plain-language RBAC definition and a Role vs ClusterRole table; notes on API server flags removed in 1.24; updated ServiceAccount token and kubelet certificate guidance; a current Flask example; security warnings for signing user certificates with the cluster CA and for cluster-admin group bindings; new sections on pod certificates, RBAC privilege escalation, and auditing; and a new FAQ.
Kubernetes RBAC and TLS certificates are two of the basics of Kubernetes security. RBAC (role-based access control) is the authorization model that controls which users, groups, and service accounts can perform which actions on which resources in a cluster. TLS certificates and PKI authentication secure the connections to the Kubernetes API server and between its components.
In this guide, we will cover how to:
-
create users and ServiceAccounts in Kubernetes
-
set access control with RBAC, using Roles, ClusterRoles, and least privilege
-
connect an external identity provider with OIDC
-
set up and rotate TLS certificates and tokens
-
issue certificates to pods, spot RBAC permissions that allow privilege escalation, and audit credentials and certificate expiry
Related posts in this series cover Kubernetes Security Context, Kubernetes Security Policy and Kubernetes Network Policy and Securing Kubernetes components: kubelet, etcd and Docker registry.
Version scope: this guide applies to current Kubernetes releases. The Kubernetes documentation currently describes version 1.37. Notes below say where behavior changed in older versions.
What is Kubernetes role-based access control (RBAC)?
Kubernetes RBAC is an access control model. You define which actions, such as GET, UPDATE, or DELETE, a subject can run on a resource like pods, secrets, or nodes. RBAC uses the rbac.authorization.k8s.io API group.
RBAC building blocks
-
Namespaces: split resources into logical areas. They help keep access narrow.
-
Subjects: users, groups, and serviceAccounts.
-
Resources: pods, deployments, logs, Ingresses, and custom resources.
-
Roles and ClusterRoles: permission sets. A Role stays in one namespace. A ClusterRole is cluster-wide.
-
RoleBindings and ClusterRoleBindings: grant a Role or ClusterRole to a subject or group.
RBAC permissions are additive. There are no deny rules.
Role vs ClusterRole
|
Question |
Role |
ClusterRole |
|
Scope |
One namespace |
Cluster-wide |
|
Granted with |
RoleBinding |
ClusterRoleBinding (or a RoleBinding to limit it to one namespace) |
|
Use it when |
Access only needs to apply in one namespace |
The resource is cluster-wide, such as nodes, or you need the same rules in many namespaces |
Example: read pods in one namespace
A Role can allow one user to read pods in the default namespace only:
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: pod-reader
namespace: default
rules:
- apiGroups: [""]
resources: ["pods"]
verbs: ["get", "watch", "list"]
A RoleBinding gives that Role to jane:
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: read-pods
namespace: default
subjects:
- kind: User
name: jane
apiGroup: rbac.authorization.k8s.io
roleRef:
kind: Role
name: pod-reader
apiGroup: rbac.authorization.k8s.io
This setup lets jane read pods in default, but nowhere else.
RBAC and API server flags
Start with the kube-apiserver manifest in /etc/kubernetes/manifests. Check that RBAC is enabled with --authorization-mode=Node,RBAC.
Review these API server flags when you want a safer cluster:
-
--insecure-port(API server): a legacy flag that opened access to unauthenticated requests. It was removed in Kubernetes 1.24, so you should not see it on current clusters. -
--insecure-bind-address(API server): a legacy flag that could expose the API on a reachable IP. It was also removed in Kubernetes 1.24. -
--anonymous-auth(API server): allows anonymous requests to the secure port. It defaults to true. Anonymous requests still go through authorization. They run assystem:anonymousin the groupsystem:unauthenticated, so RBAC decides what they can do. Instead of turning the flag off entirely, which can break health checks, current API servers can allow anonymous requests only on specific paths, such as/healthz,/livez, and/readyz. You set this in theanonymoussection of theAuthenticationConfigurationfile. Use one or the other: if you set anonymous in that file, you cannot also set--anonymous-auth. -
--anonymous-auth(kubelet): the kubelet has its own setting, and the defaults differ. The kubelet flag defaults to true, but the kubelet configuration file defaults to false. Check which one your nodes use before you assume anonymous requests are blocked.
ServiceAccounts and least privilege
ServiceAccounts give an identity to software inside pods. If you do not set one, Kubernetes uses the namespace default serviceAccount.
Use the least privilege rule:
-
give only the access a pod or user needs
-
prefer Role and RoleBinding over cluster-wide access when you can
-
avoid wildcards like
["*"]unless you truly need them
A service-specific serviceAccount is easier to audit than the default one.
Example: a Flask app
Imagine an app that needs read-only access to pods in one namespace. You can create a namespace, a serviceAccount, a Role, a RoleBinding, and a Deployment that uses that serviceAccount. Swap in your own image name before saving the manifest below as flask.yaml, then apply it with kubectl apply -f flask.yaml.
apiVersion: v1
kind: Namespace
metadata:
name: flask
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: flask-backend
namespace: flask
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: flask-backend-role
namespace: flask
rules:
- apiGroups: [""]
resources: ["pods"]
verbs: ["get", "list", "watch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: flask-backend-role-binding
namespace: flask
subjects:
- kind: ServiceAccount
name: flask-backend
namespace: flask
roleRef:
kind: Role
name: flask-backend-role
apiGroup: rbac.authorization.k8s.io
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: flask
namespace: flask
spec:
replicas: 2
selector:
matchLabels:
app: flask
template:
metadata:
labels:
app: flask
spec:
serviceAccountName: flask-backend
containers:
- name: flask
image: your-registry/your-flask-app:1.0.0
ports:
- containerPort: 5000
Short-lived, automatically refreshed tokens were introduced in Kubernetes 1.20 and became the default in 1.22, replacing the old long-lived, Secret-based tokens. Since 1.24, Kubernetes also no longer creates a long-lived token Secret for each serviceAccount automatically. To request a token yourself, run kubectl create token flask-backend -n flask.
Test the access with kubectl auth can-i:
kubectl auth can-i list pods -n default --as=system:serviceaccount:default:default
# no
kubectl auth can-i list pods -n flask --as=system:serviceaccount:flask:flask-backend
# yes
kubectl auth can-i create pods -n flask --as=system:serviceaccount:flask:flask-backend
# no
The default serviceAccount cannot read pods in default (no). The Flask serviceAccount can list pods in flask (yes), but it cannot create them (no).
How do you create Kubernetes users with client certificates?
Kubernetes users do not have a User API object. Instead, they are part of a config context. The context stores the cluster name, namespace, and user name.
If you have the root CA, you can create a new user with a client certificate:
openssl genrsa -out john.key 2048
openssl req -new -key john.key -out john.csr -subj '/CN=john/O=examplegroup'
openssl x509 -req -in john.csr -CA /etc/kubernetes/pki/ca.crt -CAkey /etc/kubernetes/pki/ca.key -CAcreateserial -out john.crt
The O=examplegroup field maps the user to a group.
Security note: signing user certificates directly with the cluster CA key gives whoever runs these commands the ability to issue trusted credentials. In production, use the Certificates API to issue a CertificateSigningRequest instead. Create the request with the kubernetes.io/kube-apiserver-client signer and an expirationSeconds value, then approve it with kubectl certificate approve. The steps below use openssl so you can see each part of the process.
Inspect the certificate if you need to:
openssl x509 -in john.crt -text
Then register the new user and context:
kubectl config set-credentials john --client-certificate=/home/newusers/john.crt --client-key=/home/newusers/john.key
kubectl config set-context john@kubernetes --cluster=kubernetes --user=john
kubectl config use-context john@kubernetes
kubectl get pods
If you want a config file that works on other hosts, add --embed-certs=true.
Without RBAC access, john gets a forbidden error.
Group-based access
You can give access to a group instead of one user. If you bind examplegroup to cluster-admin, then every user in that group, such as john or any other user whose certificate has O=examplegroup, gets the same access. Use this carefully: cluster-admin gives every member of the group full control of the cluster.
kubectl config use-context kubernetes-admin@kubernetes
kubectl create clusterrolebinding examplegroup-admin-binding --clusterrole=cluster-admin --group=examplegroup
Safer alternative: bind a built-in role in one namespace instead of cluster-admin. For example:
kubectl create rolebinding examplegroup-view-binding --clusterrole=view --group=examplegroup --namespace=default
This lets everyone in examplegroup read most resources in the default namespace and nothing else. Use edit instead of view if the group needs to change resources. This follows the least privilege rule above.
External authentication with OIDC
You can also use an external authentication backend, such as LDAP or a cloud identity service.
A common choice is OpenID Connect, or OIDC. For example, set --oidc-issuer-url and --oidc-client-id on the API server.
OIDC works well when you want central login and simpler user management. The command below registers OIDC credentials in your kubeconfig, using the token and issuer data from your authentication backend. The built-in --auth-provider=oidc flow still works in current kubectl, but exec credential plugins such as kubelogin are the norm on the client, so check what your identity provider recommends. On the server, an AuthenticationConfiguration file can replace the --oidc-* flags. It supports several JWT issuers, CEL claim mappings and validation rules, and it reloads without a restart.
kubectl config set-credentials USER_NAME \
--auth-provider=oidc \
--auth-provider-arg=idp-issuer-url=( issuer url ) \
--auth-provider-arg=client-id=( your client id ) \
--auth-provider-arg=client-secret=( your client secret ) \
--auth-provider-arg=refresh-token=( your refresh token ) \
--auth-provider-arg=idp-certificate-authority=( path to your ca certificate ) \
--auth-provider-arg=id-token=( your id_token )
How do you rotate Kubernetes TLS certificates?
Kubeadm and managed Kubernetes distributions typically configure TLS between the API server and kubelets for you, so this section focuses on maintenance and rotation. Check your provider's documentation for what it rotates automatically.
Plan rotation early. It reduces the risk from leaked or mismanaged keys.
Rotation cases
-
kubelet TLS certificate rotation
-
serviceAccount token rotation
-
user certificate rotation
Kubernetes does not support certificate revocation. That means a lost or exposed certificate can still be used until it expires.
You can reduce the risk by:
-
Using short-lived certificates
-
Removing RBAC access when needed
-
Recreating the CA and reissuing certificates
-
Protecting the CA key
-
Using OIDC when it fits your setup
-
Using unique CNs for each credential
One caveat: the system:masters group is hardwired as a superuser before RBAC runs. Removing RBAC access does nothing for a certificate in that group, so rotating the CA is the only fix. Since kubeadm 1.29, admin.conf uses the kubeadm:cluster-admins group, which RBAC controls and you can revoke. Kubeadm also creates a separate super-admin.conf in system:masters as a break-glass credential that bypasses RBAC. Store it somewhere safe and don't share it.
Kubelet certificate rotation
The kubelet is the link between the node OS and the cluster logic. It is a critical security component.
By default, kubelet certificates live under /var/lib/kubelet/pki, which is the default value of the kubelet --cert-dir setting.
You can renew them by hand with the cluster CA, but Kubernetes also supports automatic rotation.
-
Turn on automatic rotation so the kubelet renews its client certificate as the expiration date approaches:
rotateCertificates: truein the kubelet config file.
The RotateKubeletClientCertificate feature gate was deprecated in Kubernetes 1.21 (see the 1.21 changelog) and no longer exists, because kubelet client certificate rotation is generally available. You no longer need to set it.
The default kubelet certificate lifetime is one year, or 8760h. The --cluster-signing-duration flag on kube-controller-manager caps every certificate request it signs, including the kubelet client certificate. The kubelet serving certificate is signed this way only when serverTLSBootstrap is enabled. Otherwise, the kubelet self-signs its serving certificate, also for one year. A certificate request can ask for a shorter lifetime with spec.expirationSeconds.
serviceAccount token rotation
Since Kubernetes 1.22, pods use short-lived tokens that the kubelet refreshes automatically, so manual rotation mainly applies to long-lived token Secrets that you created yourself.
To rotate one of those Secrets, delete the old one and create a new one. The example below assumes an existing serviceAccount named falco-account in your current namespace. Substitute your own names, including the Secret name in the first command. After that, pods may need a rolling update so they start using the new token.
kubectl delete secret falco-account-token-jvgtz
cat > /tmp/rotate-token.yaml <<EOF
apiVersion: v1
kind: Secret
metadata:
name: falco-account-token
annotations:
kubernetes.io/service-account.name: falco-account
type: kubernetes.io/service-account-token
EOF
kubectl create -f /tmp/rotate-token.yaml
Rotating manually created token Secrets is not automated, so plan it with care. For external consumers, use kubectl create token, because pods get their tokens from the kubelet automatically.
Kubernetes also cleans up old auto-generated legacy token Secrets, the kind it created before 1.24. By default, it marks them invalid after a year without use and deletes them after another unused year. This cleanup has been generally available since 1.30. Token Secrets you create manually are not cleaned up, as long as you don't list them in the ServiceAccount's secrets field, so rotate or delete them yourself.
User certificate rotation
Since Kubernetes can't revoke a client certificate, set an expiry date when you issue it. If you use the CSR API, set expirationSeconds in the request. If you sign with openssl as shown above, use the -days option:
openssl x509 -req -in john.csr -CA /etc/kubernetes/pki/ca.crt -CAkey /etc/kubernetes/pki/ca.key -CAcreateserial -days 365 -out john.crt
Then replace the old certificate with kubectl config set-credentials.
How can pods get their own TLS certificates?
Pod certificates and ClusterTrustBundle are both generally available in Kubernetes 1.37, so you need a 1.37 or later cluster. A pod can request an X.509 certificate through a projected volume (podCertificate, backed by a PodCertificateRequest), and the kubelet keeps it refreshed. Your application needs to reload the files when they change. You can distribute trust anchors to pods with ClusterTrustBundle. Together they give workloads the building blocks for mutual TLS (mTLS). The signer you choose decides which pods get a certificate, and it can refuse a request.
Which RBAC permissions allow privilege escalation?
The escalate and bind verbs let a subject grant permissions it does not hold itself, and the impersonate verb lets a subject act as another user, group, or ServiceAccount. Permission to create pods gives indirect access to Secrets, and access to nodes/proxy is also risky. Where a pod does not call the Kubernetes API, set automountServiceAccountToken: false so it receives no API credentials.
How do you audit credentials and track certificate expiry?
Turn on audit logging to see which credential performed which action. On kubeadm clusters, run kubeadm certs check-expiration to see when certificates expire and kubeadm certs renew to renew them. On managed clouds, workload identity features such as EKS Pod Identity and GKE Workload Identity build on Kubernetes ServiceAccount tokens.
Next steps
You now know how to enable RBAC, use user and serviceAccount credentials, connect an external identity provider, rotate TLS certificates and tokens, issue certificates to pods, and audit credentials. That covers the authentication and access control side of Kubernetes security.
Next, move on to Kubernetes Pod Security, Security Context, Security Policy, and Network Policy.
Note: The linked post on Pod Security Policy covers a feature that Kubernetes removed in version 1.25. On current clusters, use Pod Security Admission instead.
Acknowledgements: Daniel Kerwin contributed to this article.
Further reading
-
Kubernetes documentation, Certificates and Certificate Signing Requests
-
Kubernetes documentation, Certificate management with kubeadm
-
Sysdig, Kubernetes security guide part 2 (security context, security policy, network policy)
-
Sysdig, Kubernetes security guide part 3 (kubelet, etcd, registry)
Frequently asked questions
Why is RBAC a core Kubernetes security practice?
RBAC controls which users, groups, and serviceAccounts can act on Kubernetes resources. (Kubelets with node identities are authorized separately by the Node authorizer, and the NodeRestriction admission plugin limits what they can modify.) It lets admins apply least privilege and avoid broad cluster-wide access when namespace access is enough.
When should I use a Role instead of a ClusterRole?
Use a Role when access only needs to apply in one namespace. Use a ClusterRole when the resource is cluster-wide, such as nodes, or when you need the same rules in many namespaces.
Why should apps use dedicated serviceAccounts instead of the default one?
Dedicated serviceAccounts make access clear and easier to audit. You can give a pod only the access it needs, instead of relying on the default serviceAccount, which can hide broad access.
How are Kubernetes users created if there is no User API object?
Kubernetes users are usually created with credentials such as client certificates. The common name identifies the user, and the organization field can map the user to a group. RBAC then grants access to that user or group.
Why is certificate rotation important in Kubernetes?
Kubernetes does not support certificate revocation, so an exposed certificate can still be used to authenticate until it expires. Rotation and short-lived credentials reduce the risk window if a key or certificate leaks.
