liveBook · Manning

Kubectl configuration

As explained in Bootstrapping Microservices, Second Edition: With Docker, Kubernetes, GitHub Actions, and Terraform

A Kubernetes configuration is connection and authentication data that enables kubectl to access a Kubernetes cluster.

A kubectl configuration connects kubectl to a Kubernetes cluster and stores the authentication details required to access it. For continuous deployment, keep the configuration limited to the cluster the workflow must deploy to. section 8.9.5

Prepare and validate a configuration before making it available to automation:

  • Inspect the resulting YAML at ~/.kube/config. On Windows, the file may be under C:\Users\<username>\.kube\config; WSL2 exposes it through /mnt/c/Users/<username>/.kube/config. section 8.9.5
  • Run kubectl config get-contexts and confirm that only the intended cluster is configured before using the file in a deployment workflow. section 8.9.5

Supplying kubectl credentials to GitHub Actions

Encode the configuration and save the value as the KUBE_CONFIG GitHub repository secret. The secret contains the base64-encoded configuration that authenticates kubectl with the target cluster; protect it because its value cannot later be viewed in GitHub. section 8.9.9

How Bootstrapping Microservices, Second Edition: With Docker, Kubernetes, GitHub Actions, and Terraform covers it

How deep it goes
Builds a working kubeconfig, inspects its YAML, and checks contexts without detailing authentication internals.
Examples
Uses az login, az aks get-credentials, kubeconfig inspection, context listing, and base64 encoding.
What it assumes
Assumes prior Azure CLI and cluster authentication, while showing how to obtain and inspect the local configuration.
What you can do after
Operate/configure kubectl by downloading AKS credentials, checking contexts, and storing a base64 value as KUBE_CONFIG.
How it connects
Links kubectl authentication with Azure CLI, Kubernetes clusters, GitHub Actions secrets, and continuous deployment.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Bootstrapping Microservices, Second Edition: With Docker, Kubernetes, GitHub Actions, and Terraform. The section links point to the parts of the book it draws on.