Managing Kubernetes in the CLI with kubectl

Michael Delzer Updated by Michael Delzer

Managing Kubernetes using the CLI

The traditional way to interact with a K8s cluster is using kubectl. This requires a kubeconfig to be made available to it. If you have deployed a cluster using the the ControlPlane, you can easily download the admin kubeconfig file for your cluster.

Fetching the Kubeconfig

  1. Navigate to Stacks -> List and select the cluster you desire.
  2. Halfway down, there is a series of tabs, the second tab is Kubernetes, click that, and you should see something like:

  1. Simply click the "Download Kubeconfig file" button, and save it someplace special.

Installing the Kubeconfig and testing kubectl

The easiest way to use your kubeconfig with kubectl is run:

export KUBECONFIG=/path/to/your/kubeconfig.yaml

This will override the default location behavior of kubectl and force it to look only at your kubeconfig file.

You can test it by running:

kubectl get nodes -o wide

This should return a result similar to:

NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
ip-10-0-21-131.ec2.internal Ready master 10d v1.14.8 10.0.21.131 23.211.151.189 Debian GNU/Linux 9 (stretch) 4.19.84-coreos docker://18.6.3
ip-10-0-22-127.ec2.internal Ready master 10d v1.14.8 10.0.22.127 23.254.146.28 Debian GNU/Linux 9 (stretch) 4.19.84-coreos docker://18.6.3
ip-10-0-22-199.ec2.internal Ready master 10d v1.14.8 10.0.22.199 23.245.180.33 Debian GNU/Linux 9 (stretch) 4.19.84-coreos docker://18.6.3
ip-10-0-32-242.ec2.internal Ready node 156m v1.14.8 10.0.32.242 14.236.63.25 Debian GNU/Linux 9 (stretch) 4.19.84-coreos docker://18.6.3
ip-10-0-34-220.ec2.internal Ready node 6d6h v1.14.8 10.0.34.220 25.169.107.47 Debian GNU/Linux 9 (stretch) 4.19.86-coreos docker://18.6.3
ip-10-0-36-70.ec2.internal Ready node 126m v1.14.8 10.0.36.70 23.219.231.18 Debian GNU/Linux 9 (stretch) 4.19.84-coreos docker://18.6.3
ip-10-0-39-164.ec2.internal Ready node 156m v1.14.8 10.0.39.164 34.221.30.19 Debian GNU/Linux 9 (stretch) 4.19.84-coreos docker://18.6.3
ip-10-0-39-3.ec2.internal Ready node 6d6h v1.14.8 10.0.39.3 23.228.149.31 Debian GNU/Linux 9 (stretch) 4.19.86-coreos docker://18.6.3

How did we do?

Templating

Contact