Courseiva
CKAChapter 16 of 16Objective Troubleshooting - 30%

Troubleshooting Cluster Security

What happens when a pod can't connect to the API server or a user gets 'Forbidden' errors even though they have the right credentials? These are security-related issues — RBAC misconfigurations and certificate problems — that make up a significant part of the CKA exam's troubleshooting section. Understanding how to diagnose and fix these two specific areas is essential because they're two of the most common real-world reasons a cluster stops working properly.

12 min read
Advanced
Updated Jul 23, 2026
Reviewed by Johnson Ajibi· Senior Network & Security Engineer · MSc IT Security

A simple way to picture Troubleshooting Cluster Security

The Embassy Security Pass Analogy

Inside a busy embassy, a visitor approaches the front desk.

The visitor shows a pass that says 'VIP Access', but the guard's list only shows them cleared for the ground-floor canteen. The guard denies entry. This is an RBAC (Role-Based Access Control) misconfiguration — the visitor has a role that doesn't match their actual permissions. Elsewhere, a diplomat's biometric card fails because the certificate on the card expired last night. The embassy's system won't accept it, so the diplomat is locked out of the secure meeting room. This is a certificate problem.

In both cases, the root cause isn't a broken door or a malfunctioning scanner — it's a mismatch between what the system thinks is allowed and what is actually happening. The security team must check the pass against the access list (RBAC), verify the card's certificate chain (certificate validation), and confirm the embassy's clock is synchronised (time sync for certificate expiry). They don't tear down the walls — they fix the authorisation rules and renew the digital credentials. That's exactly what troubleshooting cluster security means in Kubernetes: carefully inspecting who has which permissions and whether the digital certificates that prove identity are valid and trusted.

How It Actually Works

Let's start with the foundation: Kubernetes is a system for running containerised applications. To interact with it, you need to authenticate (prove who you are) and then be authorised (be allowed to do what you're trying to do). Two major security components handle this: RBAC (Role-Based Access Control) and certificates.

What is RBAC?

RBAC is a method of restricting system access to authorised users. Think of it like a hotel key card system. A guest might have a key that opens their room door but not the staff-only maintenance closet. A cleaner has a key that opens the maintenance closet but not guest rooms. In Kubernetes, roles are like sets of permissions (e.g., 'can list pods', 'can create deployments'), and role bindings attach those roles to users, groups, or service accounts.

There are two types of roles: Role and ClusterRole. A Role applies permissions within a single namespace (a virtual cluster within the cluster). A ClusterRole applies permissions across the entire cluster (e.g., ability to view nodes, which exist globally). Similarly, RoleBinding binds a Role to a subject within a namespace, and ClusterRoleBinding binds a ClusterRole cluster-wide.

Why RBAC misconfigurations cause trouble

A very common mistake is giving too few permissions (e.g., a developer cannot view logs of their own pod) or too many (e.g., a CI/CD pipeline has cluster-admin access when it only needs to deploy to one namespace). Another is forgetting to create a RoleBinding after creating a Role — the role exists on paper but no one is actually assigned to it. When a user or service account tries an action they aren't permitted to do, Kubernetes returns a 'Forbidden' error. Troubleshooting RBAC means checking: what role exists? What subjects (users, groups, service accounts) are bound to it? Does the role contain the needed verbs ('get', 'list', 'create') on the right resources ('pods', 'deployments', 'services')?

What are certificates?

Certificates are digital ID cards used to prove identity and establish encrypted communication. In Kubernetes, the API server (the brain of the cluster) uses a certificate to prove its identity to clients. Every component (kubelet, scheduler, controller-manager) also uses client certificates to prove their identity to the API server. If any of these certificates are expired, misconfigured, or signed by an untrusted Certificate Authority (CA — the entity that issues certificates), the connection fails.

How certificate problems manifest

A classic sign: 'certificate has expired or is not yet valid'. This happens when the system clock is wrong (certificates have a validity window), or the certificate was not renewed before expiry. Another sign: 'x509: certificate signed by unknown authority'. This means the client doesn't trust the CA that signed the server's certificate — either the CA certificate is missing from the client's trust store, or the server certificate was self-signed and the client doesn't have the self-signed root.

Where certificates live in Kubernetes

The main certificates are stored on the control plane node (the master node that runs the API server). The kubeconfig file (a configuration file used to connect to the cluster) contains the client certificate and key, and the CA certificate used to verify the server. The kubelet (an agent running on each worker node) also has its own certificate.

How they interact in practice

An RBAC configuration often depends on the identity proven by a certificate. For example, a kubelet presents a certificate that identifies it as 'system:node:worker-1'. The API server checks that the certificate is valid, extracts the username, and then checks if that username (or its groups) has RBAC permissions to perform the requested action (e.g., report node status). If the certificate is invalid, the authentication step fails before RBAC is even checked. If the certificate is valid but RBAC denies the action, the user gets a 'Forbidden' error.

Troubleshooting cluster security, therefore, involves a two-step process: first verify that the identity (certificate) is trusted and not expired, then verify that the identity (username/group) has the correct RBAC permissions. Both layers must work for the cluster to function correctly.

This diagram shows the two-step security verification process in Kubernetes: first authentication via certificates, then authorisation via RBAC.

Walk-Through

1

Identify the error type

When a user or pod gets an error, check whether it's a 401 Unauthorized (authentication/certificate problem) or a 403 Forbidden (RBAC problem). This immediately tells you which layer to debug.

2

Check the certificate validity

If it's a 401 error, inspect the certificate used by the client (e.g., from the kubeconfig file) and the server certificate. Use 'kubectl config view --raw' to see the embedded certificates, and decrypt them with 'openssl x509 -in cert.crt -text' to check expiry and issuer.

3

Verify the CA trust

Ensure the client trusts the CA that signed the server certificate. In the kubeconfig, the 'certificate-authority-data' field must match the actual CA certificate on the server. If they differ, update the kubeconfig.

4

Inspect RBAC resources

For a 403 error, use 'kubectl get role,rolebinding -n <namespace>' to list what exists. Then describe the specific role and rolebinding to see the exact permissions and subjects. Look for missing verbs, wrong resources, or wrong namespace.

5

Test permissions

Use 'kubectl auth can-i --as <username> <verb> <resource> -n <namespace>' to simulate the action. This tells you whether the permission is granted according to the current RBAC rules. Adjust the Role if needed.

6

Check service account token in pods

If a pod is failing due to permissions, verify the service account mounted in the pod. 'kubectl describe pod <podname>' shows the service account. Ensure the service account has the correct Role and RoleBinding in the pod's namespace.

7

Renew or regenerate certificates

If certificates are expired or invalid, generate new ones. For the kubelet, you can approve a pending CSR with 'kubectl certificate approve <csr-name>'. For the API server, you may need to regenerate the certificates using 'kubeadm init phase certs' or manually.

What This Looks Like on the Job

A medium-sized e-commerce company runs its production and staging environments on the same Kubernetes cluster, separated by namespaces (production-ns and staging-ns). A new DevOps engineer, Priya, is tasked with setting up a CI/CD pipeline that deploys application updates to the staging namespace only.

Priya creates a service account (a non-human identity used by tools) called 'cicd-bot' in the staging namespace. She then creates a Role called 'deployer' that grants permissions to 'get', 'list', 'create', 'update', and 'delete' on deployments, services, and pods. She creates a RoleBinding binding 'cicd-bot' to the 'deployer' role. Everything seems fine.

However, when the pipeline runs, it fails with a 'Forbidden' error when trying to list pods. Priya checks the YAML files. She sees that the Role correctly lists 'pods' in the resources field, but she forgot to include the verb 'list' — she included 'get' but not 'list'. The pipeline needs to 'list' pods to check the status. She updates the Role to include 'list', applies it, and the pipeline succeeds. This is a classic RBAC troubleshooting scenario.

Later, the company's IT department rotates the cluster certificates as part of a security policy. They generate new certificates for the API server and the kubelets, but the kubeconfig files on the developer laptops still contain the old CA certificate. When developers try to use 'kubectl' commands, they get 'x509: certificate signed by unknown authority'. The fix is to update the kubeconfig files with the new CA certificate. The IT team pushes a script that does this automatically, and the connection is restored.

In another real-world case, a node goes offline because the kubelet certificate expires. The kubelet has a built-in mechanism to auto-renew its certificate, but this relies on the cluster being configured with a controller that handles certificate signing requests (CSRs). If that controller is not running or misconfigured, the kubelet's certificate expires, and the node loses connection to the API server. The fix is to check the CSR state, approve any pending CSRs, and ensure the kubelet controller manager is healthy.

Tools used: - 'kubectl auth can-i' — quickly check whether a user or service account can perform a specific action. - 'kubectl describe role/rolebinding' — inspect the exact permissions and bindings. - 'openssl x509 -in certificate.crt -text -noout' — inspect certificate details (issuer, expiry date). - 'kubectl get csr' — view pending certificate signing requests.

How CKA Actually Tests This

The CKA exam loves to test troubleshooting of RBAC and certificates in two distinct ways: debugging a broken resource (e.g., a pod that won't start because of permission issues) and fixing a misconfiguration that prevents 'kubectl' from connecting to the cluster.

What the exam specifically tests

Given a scenario where a user or service account gets 'Forbidden' errors, you must identify whether the problem is an RBAC misconfiguration (missing Role, missing RoleBinding, wrong verb, wrong resource) or an authentication (certificate) issue.

You will be asked to create a Role and RoleBinding that grants specific permissions to a service account. The exam will explicitly state the namespace, the resources, and the verbs.

You may be asked to troubleshoot a cluster where a node is NotReady because the kubelet certificate is expired or the kubelet cannot authenticate to the API server.

You must know how to check the certificate of the API server: location is typically '/etc/kubernetes/pki/ca.crt' for the CA, and '/etc/kubernetes/pki/apiserver.crt' for the server cert.

You must understand the difference between a Role (namespace-scoped) and a ClusterRole (cluster-scoped). The exam will use both.

You must be able to inspect existing RBAC resources with 'kubectl get role,rolebinding,clusterrole,clusterrolebinding -n <namespace>'.

You must know how to use 'kubectl auth can-i --as <username> --as-group <group> <verb> <resource>' to test permissions without actually running the action.

Common traps the exam sets

The exam gives you a Role that has the correct resource but the wrong verb. For example, it includes 'get' but not 'list', and the scenario requires listing objects. Beginners often check the resource but forget to check the verb.

They give a RoleBinding that binds a Role that exists, but the Role is in the wrong namespace. Remember: a RoleBinding in namespace 'default' cannot bind a Role that exists only in namespace 'production-ns'.

They set up a scenario where the certificate is valid but the cluster's clock is wrong, causing the certificate to appear expired. The fix is to correct the system time, not replace the certificate.

They present a situation where a ClusterRoleBinding exists, but it maps the wrong subject (e.g., a username instead of a group name). The user has a valid certificate identifying them as 'alice' but the ClusterRoleBinding expects 'developers-group'.

Key definitions you must memorise

Role: defines a set of permissions within a namespace.

ClusterRole: defines a set of permissions cluster-wide or for non-namespaced resources (e.g., nodes).

RoleBinding: grants the permissions of a Role to a subject within a specific namespace.

ClusterRoleBinding: grants the permissions of a Role or ClusterRole to a subject cluster-wide.

ServiceAccount: a non-human identity used by pods or external tools.

Subject: a user, group, or ServiceAccount that is being granted permissions.

Certificate Authority (CA): the root of trust that signs all other certificates.

Certificate Signing Request (CSR): a request for a certificate to be signed by the CA.

Key Takeaways

RBAC in Kubernetes uses Roles and RoleBindings to control permissions within a namespace, and ClusterRoles and ClusterRoleBindings for cluster-wide permissions.

The 'kubectl auth can-i' command lets you test whether a specific user or service account can perform an action without actually executing it.

A 'Forbidden' (403) error always points to an RBAC problem, while an 'Unauthorized' (401) error points to an authentication (certificate) issue.

Certificates in Kubernetes are stored on the control plane under /etc/kubernetes/pki/ and must be valid, trusted by the CA, and not expired for secure communication.

When troubleshooting a certificate problem, first check the system clock, then check the certificate expiry date, and finally verify the CA chain.

Service accounts pods use are automatically assigned a token that is mounted as a volume; if RBAC fails for a pod, check the service account's permissions.

A RoleBinding can bind a ClusterRole, scoping its permissions to a specific namespace — this is a common exam pattern.

Always check the resource and verb combination in a Role: a Role that allows 'get' does not allow 'list', and 'create' does not allow 'delete'.

Easy to Mix Up

These come up on the exam all the time. Here's how to tell them apart.

Role

Scoped to a single namespace.

Cannot grant permissions to cluster-wide resources like nodes.

Defined with 'kind: Role' in YAML.

ClusterRole

Scoped to the entire cluster.

Can grant permissions to cluster-scoped resources like nodes and PersistentVolumes.

Defined with 'kind: ClusterRole' in YAML.

401 Unauthorized

Indicates authentication failure.

The client's certificate is invalid, expired, or untrusted.

The server cannot identify who the client is.

403 Forbidden

Indicates authorisation failure.

The client is authenticated but lacks permission.

The server knows who the client is but denies the action.

RoleBinding

Binds a Role or ClusterRole to subjects within a namespace.

Permissions apply only to the namespace where the RoleBinding exists.

Uses 'kind: RoleBinding' in YAML.

ClusterRoleBinding

Binds a ClusterRole to subjects across all namespaces.

Permissions apply to the entire cluster.

Uses 'kind: ClusterRoleBinding' in YAML.

Watch Out for These

Mistake

RBAC misconfigurations always cause a 401 (Unauthorized) error.

Correct

RBAC misconfigurations cause a 403 (Forbidden) error. A 401 error means the authentication (certificate) failed.

The terms 'Unauthorized' and 'Forbidden' sound similar, and beginners often mix up HTTP status codes.

Mistake

If a user has a valid certificate, they automatically have full access to the cluster.

Correct

A valid certificate only proves identity. The user's permissions are then checked by RBAC, which may still deny the action.

People assume that a valid ID card (certificate) equals unlimited access, but in practice, authentication and authorisation are separate steps.

Mistake

Service accounts are like regular user accounts that can log in interactively.

Correct

Service accounts are non-human identities used by pods and automated processes. They don't have passwords you can use to log in with kubectl.

The word 'account' suggests a human-login model, but service accounts are designed for machines, not people.

Mistake

A ClusterRole can only be bound by a ClusterRoleBinding.

Correct

A ClusterRole can be bound by a RoleBinding (which restricts the permissions to one namespace) OR a ClusterRoleBinding (which grants permissions cluster-wide).

Beginners see 'ClusterRole' and assume it must always be used cluster-wide, missing the flexibility of scoping it to a namespace via a RoleBinding.

Mistake

If a certificate is expired, you need to generate a completely new private key.

Correct

You can often renew the certificate using the same private key, especially if the kubelet or API server supports certificate rotation.

People think 'expired' means 'broken beyond repair', but certificates are renewable like a passport — same identity, new expiry date.

Do You Actually Know This?

Reveal each answer, then mark whether you got it right. Score 60%+ to unlock the next chapter.

Frequently Asked Questions

What is the difference between a Role and a ClusterRole in Kubernetes?

A Role grants permissions within a specific namespace, while a ClusterRole grants permissions cluster-wide (e.g., to resources that are not namespaced, like nodes).

Why am I getting 'Forbidden' even though I have the right certificate?

A 'Forbidden' error means you are authenticated (your certificate is valid), but you are not authorised to perform that action. Check the RBAC roles and rolebindings assigned to your user or service account.

Where does Kubernetes store its certificates?

The main certificates are stored on the control plane node under the directory /etc/kubernetes/pki/. This includes the CA certificate (ca.crt), the API server certificate (apiserver.crt), and the kubelet client certificates.

How do I check if a certificate is expired?

Use the openssl command: 'openssl x509 -in /path/to/certificate.crt -text -noout | grep -A2 Validity'. Look at the 'Not Before' and 'Not After' dates.

Can a RoleBinding be used to bind a ClusterRole to a specific namespace?

Yes. A RoleBinding can bind a ClusterRole, but the permissions from that ClusterRole will only apply to the namespace where the RoleBinding exists.

What is a service account in Kubernetes and why is it used?

A service account is a non-human identity used by pods and automated tools (like CI/CD pipelines). It has a token that pods mount as a volume, allowing them to authenticate to the API server.

How do I test if a user has permission to list pods without logging in as them?

Use 'kubectl auth can-i --as <username> list pods -n <namespace>'. This tells you whether the RBAC system would allow that action.

Terms Worth Knowing

Keep going

You've finished Troubleshooting Cluster Security. Continue through the CKA study guide to build a complete picture of the exam.

Done with this chapter?