Kubernetes Administration: kubectl, RBAC, Namespaces, and Resource Quotas
Kubernetes administration is the day-to-day management of a cluster through its API: driving it with kubectl, controlling who can do what with RBAC, dividing it into namespaces, and bounding consumption with ResourceQuotas and LimitRanges. Everything an administrator does - creating objects, granting access, inspecting failures - is ultimately an API request to the kube-apiserver, so understanding that single entry point unlocks the whole topic. The KCNA exam tests this at recognition depth: which RBAC object grants permissions cluster-wide, what kubectl apply does differently from kubectl create, which component an administrator checks when Pods stay Pending, and what a ResourceQuota limits versus a LimitRange. This lesson covers kubectl and its path to the API server, the cluster components through an administrator's eyes, declarative versus imperative management, the four RBAC objects with their subjects, verbs, and resources, and the namespace-level guardrails that keep shared clusters fair.
On this page7 sections
- kubectl: the client for the Kubernetes API
- The cluster components through an administrator's eyes
- Declarative kubectl apply vs imperative commands
- RBAC: Roles, ClusterRoles, and their bindings
- Subjects, ServiceAccounts, verbs, and resources
- Namespaces as scope and isolation boundaries
- ResourceQuotas and LimitRanges: keeping shared clusters fair
- Explain how kubectl communicates with the kube-apiserver and what a kubeconfig context holds
- Recognize what each cluster component does from an administrator's point of view
- Distinguish declarative kubectl apply from imperative commands such as create, run, and scale
- Identify the four RBAC objects and match Roles and ClusterRoles to the correct binding
- Describe how subjects, verbs, and resources combine into an RBAC permission
- Explain how namespaces, ResourceQuotas, and LimitRanges bound what teams can create and consume
kubectl: the client for the Kubernetes API
kubectl is the command-line client for the Kubernetes API. Every command you type - kubectl get pods, kubectl apply, kubectl delete - is translated into an HTTPS request to the kube-apiserver. kubectl never connects to nodes, the kubelet, or etcd directly; the API server authenticates the request, checks authorization (RBAC), validates it, and acts on the cluster state. This single-entry-point design is why access control, auditing, and validation can all live in one place.
kubectl finds the cluster through a kubeconfig file, by default at ~/.kube/config. A kubeconfig holds three kinds of entries: clusters (API server addresses and certificate data), users (credentials), and contexts, which pair a cluster with a user and optionally a default namespace. Switching contexts with kubectl config use-context is how one workstation manages several clusters, and it is the answer the exam expects when a question mentions working with multiple clusters from one machine.
The everyday verbs are worth recognizing on sight: kubectl get lists objects, kubectl describe shows detailed state plus recent events (the first stop when debugging), kubectl logs prints a container's output, kubectl exec runs a command inside a running container, and kubectl explain documents the fields of any resource type. Flags follow a consistent pattern: -n selects a namespace, -A spans all namespaces, -l filters by label selector, and -o yaml or -o wide change the output format. You will not be asked to compose complex commands on the KCNA, but you will be asked what a given command does.
The cluster components through an administrator's eyes
You have met the components as architecture; an administrator meets them as failure domains. Each component owns one job, so each has a characteristic symptom when it is unhealthy, and exam questions often describe the symptom and ask for the component.
| Component | Admin-lens job | Typical symptom when unhealthy |
|---|---|---|
| kube-apiserver | Serves the API; the door every request passes through | kubectl commands fail entirely; nothing can be changed |
| etcd | Persists all cluster state | API reads and writes fail or the cluster loses its memory of desired state |
| kube-scheduler | Assigns new Pods to nodes | New Pods stay Pending with no node assigned |
| kube-controller-manager | Runs the reconciliation controllers | Desired state stops being enforced; failed Pods are not replaced |
| kubelet | Node agent that starts and monitors Pods on its node | The node goes NotReady; its Pods stop being managed |
| kube-proxy | Programs Service routing rules on each node | Pods run but Service traffic does not reach them |
Two administrative facts round this out. First, cluster state lives in etcd, so backing up etcd is the canonical way to back up a cluster, and etcd should run with an odd number of members so it can keep quorum. Second, in managed clusters (EKS, AKS, GKE) the provider runs the control plane, so an administrator's hands-on scope narrows to worker nodes, workloads, and the API - one reason the exam favors conceptual questions over operational ones.
A quick health picture comes from commands like kubectl get nodes, kubectl get pods -n kube-system, and kubectl describe node NODE_NAME - reading conditions and events rather than logging into machines.
Declarative kubectl apply vs imperative commands
There are two styles of driving the API, and KCNA expects you to tell them apart. Imperative commands state an action: kubectl create deployment web --image=nginx, kubectl run tmp --image=busybox, kubectl scale deployment web --replicas=5, kubectl expose deployment web --port=80. They are quick for experiments, but the resulting configuration exists only in the live cluster - there is no file to review, version, or reapply.
Declarative management states a destination: you keep manifests in files and run kubectl apply -f manifest.yaml (or -f a whole directory). Apply creates the object if it is missing and updates it if it drifted, so the same command is safe to run repeatedly - it is idempotent. Because the manifests are plain files, they can live in Git, go through code review, and be applied by automation; this is the foundation of the GitOps pattern of cluster management.
| Imperative (create, run, scale, expose) | Declarative (apply -f) | |
|---|---|---|
| You specify | An action to perform now | The desired end state |
| Repeat the command | Errors or duplicates (already exists) | Converges; safe to re-run |
| Source of truth | The live cluster only | Versioned manifest files |
| Best for | Experiments, quick debugging | Production, teams, automation |
A common exam stem describes a team storing YAML in a repository and asks which command keeps the cluster matching it: the answer is kubectl apply. Another gives kubectl create failing with an already-exists error and asks why apply would not: because apply computes and patches the difference instead of insisting on creating something new. Imperative commands still have one declarative trick worth knowing: --dry-run=client -o yaml prints the manifest an imperative command would create, which is a fast way to scaffold a file you then manage with apply.
RBAC: Roles, ClusterRoles, and their bindings
Role-Based Access Control (RBAC) is how Kubernetes decides who may do what. It is built from exactly four API objects, in two pairs. A Role is a named list of permissions that applies within a single namespace. A ClusterRole is the same idea without the namespace boundary: it can grant access across all namespaces, or to cluster-scoped resources such as nodes and PersistentVolumes that no namespaced Role could ever cover. Neither object names any people - roles define what can be done, not who can do it.
Bindings supply the who. A RoleBinding grants the permissions of a role to a set of subjects within one namespace; a ClusterRoleBinding grants a ClusterRole's permissions across the entire cluster. One combination surprises people and is beloved by exam writers: a RoleBinding may reference a ClusterRole, which grants that ClusterRole's permissions only inside the binding's namespace. This lets administrators define a permission set once (say, a generic developer ClusterRole) and bind it per namespace, instead of copying identical Roles everywhere.
| Object | Scope | What it does |
|---|---|---|
| Role | One namespace | Defines permissions on namespaced resources |
| ClusterRole | Cluster-wide | Defines permissions cluster-wide or on cluster-scoped resources |
| RoleBinding | One namespace | Grants a Role or ClusterRole to subjects in that namespace |
| ClusterRoleBinding | Cluster-wide | Grants a ClusterRole to subjects across all namespaces |
Two properties define RBAC's character. It is additive and allow-only: there are no deny rules, permissions accumulate across bindings, and anything not explicitly granted is forbidden. And it defaults closed, which makes least privilege the natural practice: start from nothing and grant only the verbs and resources a subject genuinely needs.
Subjects, ServiceAccounts, verbs, and resources
Every RBAC rule answers three questions: who (the subject), may do what (the verbs), to which objects (the resources). Subjects come in three kinds: Users and Groups, which represent humans and are not Kubernetes API objects (they come from certificates or an external identity provider - there is no kubectl create user), and ServiceAccounts, which are API objects and represent workloads. Every namespace has a default ServiceAccount, every Pod runs as some ServiceAccount, and a Pod that needs to call the API should get its own ServiceAccount bound to a narrowly scoped Role.
Verbs are the actions the API server recognizes: get, list, and watch for reading; create, update, patch, and delete for writing. Resources are the object types the verbs act on - pods, deployments, services, secrets - optionally narrowed by API group. A Role that lets its holder read Pods in the dev namespace looks like this:
apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: namespace: dev name: pod-reader rules: - apiGroups: [""] resources: ["pods"] verbs: ["get", "list", "watch"]
A RoleBinding then attaches it to a subject - a user, a group, or a ServiceAccount such as system:serviceaccount:dev:ci-bot. To check the outcome, administrators use kubectl auth can-i, for example kubectl auth can-i list pods -n dev, or with --as to test another subject's permissions. For the exam, be ready to read a Role like the one above and state what it permits, and remember the human/workload split: ServiceAccounts for Pods, users and groups for people.
Namespaces as scope and isolation boundaries
For an administrator, a namespace is the unit of tenancy: the boundary at which access is granted, quotas are enforced, and blast radius is contained. Object names must be unique only within their namespace, so multiple teams can use the same conventional names side by side. Policy objects attach at the same seam - a RoleBinding grants access within its namespace, and a ResourceQuota caps consumption within its namespace - so putting each team or environment in its own namespace gives each a private naming scope with tailored permissions and limits.
Not everything lives inside a namespace. Namespaced resources include Pods, Deployments, Services, ConfigMaps, Secrets, Roles, and RoleBindings. Cluster-scoped resources include Nodes, PersistentVolumes, ClusterRoles, ClusterRoleBindings, and namespaces themselves. You can ask the API which is which: kubectl api-resources --namespaced=true and --namespaced=false. This split is exactly why ClusterRoles exist - no namespaced Role could grant access to a Node.
Day to day, you select a namespace per command with -n, span all of them with -A, or set a default in your kubeconfig context with kubectl config set-context --current --namespace=dev. Deleting a namespace deletes everything in it, which makes namespaces convenient for disposable environments and dangerous to delete casually.
Know the limits of the boundary. Namespaces isolate names, access, and quota accounting - they do not isolate the network. By default any Pod can reach any Pod in any namespace; restricting that requires NetworkPolicies. Nor do namespaces isolate node resources: workloads from every namespace share the same machines, which is precisely the problem quotas address next.
Tip. Administration questions on KCNA are matching exercises: pair the RBAC object with its scope (Role and RoleBinding to one namespace, ClusterRole and ClusterRoleBinding to the whole cluster), pair kubectl apply with declarative and create, run, and scale with imperative, and pair ResourceQuota with namespace totals versus LimitRange with per-container bounds. Trigger words to watch: across all namespaces or on nodes signals a ClusterRole, identity used by a Pod signals a ServiceAccount, and safe to run repeatedly or stored in Git signals kubectl apply. Remember that kubectl only ever talks to the kube-apiserver, and that RBAC has no deny rules - options describing an explicit deny are distractors.
- Every kubectl command is an HTTPS request to the kube-apiserver; kubectl never talks to nodes or etcd directly.
- kubectl apply is declarative and idempotent; create, run, scale, and expose are imperative one-off commands with no file as source of truth.
- A Role grants permissions inside one namespace; a ClusterRole grants them cluster-wide or on cluster-scoped resources like nodes.
- RoleBindings and ClusterRoleBindings attach a Role or ClusterRole to subjects: users, groups, or ServiceAccounts.
- RBAC is additive and allow-only: there are no deny rules, and anything not explicitly granted is forbidden.
- ServiceAccounts are the API identities of workloads; users and groups represent humans and are not Kubernetes API objects.
- A ResourceQuota caps a namespace's total consumption; a LimitRange sets per-container defaults, minimums, and maximums.
- Namespaces scope names, access, and quotas, but they do not isolate the network - that requires NetworkPolicies.
Frequently asked questions
What is the difference between a Role and a ClusterRole?
A Role defines permissions within a single namespace and can only cover namespaced resources there. A ClusterRole is not bound to a namespace: it can grant permissions across all namespaces or on cluster-scoped resources such as nodes and PersistentVolumes. A ClusterRole can also be referenced by a RoleBinding, which applies its permissions inside just that binding's namespace - a common pattern for reusing one permission set across many namespaces.
What is the difference between kubectl apply and kubectl create?
kubectl create is imperative: it makes a new object and fails if the object already exists. kubectl apply is declarative: it reads a manifest describing desired state, creates the object if it is missing, and patches it if it exists, so the same command can be run repeatedly and safely. Apply is the standard for production because the manifest files become a reviewable, version-controlled source of truth.
What is a ServiceAccount in Kubernetes?
A ServiceAccount is the identity a workload uses when it calls the Kubernetes API. Unlike users and groups, which represent humans and are managed outside Kubernetes, ServiceAccounts are real API objects that live in a namespace. Every namespace has a default ServiceAccount, every Pod runs as one, and a Pod that needs API access should get a dedicated ServiceAccount bound to a narrowly scoped Role via a RoleBinding.
What is the difference between a ResourceQuota and a LimitRange?
A ResourceQuota caps the total resource consumption of a whole namespace - the sum of CPU and memory requests and limits, and counts of objects like Pods or Services. A LimitRange constrains individual containers or Pods in that namespace: it sets default requests and limits for containers that omit them, and minimum and maximum bounds for those that declare them. Quota is the namespace budget; LimitRange is the per-container guardrail.
Does kubectl talk directly to etcd or to the nodes?
No. kubectl only communicates with the kube-apiserver over HTTPS. The API server authenticates and authorizes the request, then reads or writes cluster state in etcd itself; it is the only component with direct access to etcd. Even commands that appear node-level, such as kubectl logs or kubectl exec, are served through the API server, which relays to the kubelet on the target node.
Do namespaces isolate network traffic between teams?
Not by default. Namespaces isolate names, RBAC scope, and quota accounting, but any Pod can reach any Pod in another namespace unless you restrict traffic with NetworkPolicies. They also do not partition the underlying machines - Pods from all namespaces share the same nodes, which is why ResourceQuotas exist to keep consumption fair.
Sign up free to mark lessons complete, bookmark topics and track your exam readiness.