Bitzu

KCNA ยท Cluster administration and scheduling

kubeconfig, contexts and cluster access

kubeconfig structure (clusters, users, contexts), switching contexts, how clients authenticate to the API server.

Key points

  • A kubeconfig file lists clusters (API server address and CA), users (credentials such as client certificates, tokens or credential plugins) and contexts.
  • A context pairs one cluster, one user and a namespace; current-context says which one kubectl uses.
  • The default file is $HOME/.kube/config, and the KUBECONFIG variable can point to several files that are merged.

Source: https://kubernetes.io/docs/tasks/access-application-cluster/configure-access-multiple-clusters/

Practice questions

Single choice

Which three lists make up the body of a kubeconfig file?

  1. nodes, pods, services
  2. clusters, users, contexts
  3. roles, bindings, accounts
  4. masters, workers, proxies
Show answer

Answer: B. clusters, users, contexts

Clusters hold server endpoints, users hold credentials, contexts tie them together. Nodes, Pods and Services are cluster objects, not kubeconfig sections.

Select all that apply

A context in kubeconfig combines which elements?

  1. A cluster entry
  2. A node name
  3. A user entry
  4. A namespace
  5. A container image
Show answer

Answer: A. A cluster entry, C. A user entry, D. A namespace

A context is a triple of cluster, user and namespace. Nodes and container images are not part of it.

True or false

A context stores the client certificate or token itself.

Show answer

Answer: False

False. Credentials live in the users section; a context only references a user by name, along with a cluster and namespace.

Practice 8 questions on this topic in Bitzu

Short lessons, instant explanations and spaced review of what you get wrong. Free on iOS and Android.

Download on the App StoreGet it on Google Play

More KCNA topics in this module