kubernetes kubernetes/kcna

Core Idea

The kubeconfig file is kubectl’s control panel: it stores clusters, users, and contexts so one command switches between environments instead of repeating flags.

  • The note starts from the pain of running without a kubeconfig, where every call needs server, credentials, and certificates spelled out.
  • Namespaces: how to set them inside kubeconfig.
  • Certificates in kubeconfig: the trust material each context carries.

Without kubeconfig

kubeconfig file

The clusters section defines one or more Kubernetes clusters. Each has a friendly name, an API server endpoint, and the public key of its certificate authority (CA).

The users section defines one or more users. Each user requires a name and token. The token is often an X.509 certificate signed by the cluster’s CA (or a CA trusted by the cluster).

The contexts section combines users and clusters.

The current-context is the cluster and user that kubectl will use for all commands.

Namespaces

Namespace in kubeconfig

certificates in kubeconfig