liveBook · Manning

Context

As explained in Acing the Certified Kubernetes Administrator Exam, Second Edition

A Kubernetes context is a kubeconfig entry that selects a cluster, user credentials, and optionally a namespace for client operations.

A Kubernetes context is a kubeconfig entry that combines a cluster, user credentials, and optionally a namespace for kubectl operations. It determines which cluster and identity receive your commands, so verify the active context before changing resources. section 3.2 section 9.7

Manage contexts with kubectl:

  • Create or update one with kubectl config set-context, supplying a name, user, cluster, and optionally namespace. section 3.2
  • Inspect available contexts with kubectl config get-contexts; the asterisk marks the current context. section 3.2
  • Switch the active target with kubectl config use-context NAME, then verify the resulting permissions and cluster. section 3.2 section 9.7

Switching to a restricted user

After adding Carol's credentials, create a context with kubectl config set-context carol --user=carol --cluster=kind-kind. Run kubectl config use-context carol. Carol can list the nginx pod, but deleting it returns Forbidden because the configured identity lacks that permission. section 3.2

How Acing the Certified Kubernetes Administrator Exam, Second Edition covers it

How deep it goes
Explains context creation, inspection, switching, and permission verification, but does not detail kubeconfig internals beyond displayed entries.
Examples
Uses a Carol context, an nginx pod, kubectl output, and allowed-versus-forbidden operations to demonstrate context behavior.
What it assumes
Assumes familiarity with kubectl and Kubernetes users, clusters, credentials, and authorization concepts.
What you can do after
Operate kubectl safely by creating, inspecting, switching, and validating contexts before acting on cluster resources.
How it connects
Connects kubeconfig, clusters, user credentials, namespaces, kubectl, RBAC, and role bindings.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Acing the Certified Kubernetes Administrator Exam, Second Edition. The section links point to the parts of the book it draws on.