Kubernetes at the command line: Up and running with kubectl

Kubernetes provides a command-line interface (CLI) called kubectl to deploy, troubleshoot, and manage applications. Before you can use kubectl, you must ensure you can authenticate with the cluster's API server. Your credentials are distributed in a file called a kubeconfig, which is read by kubectl.

Download the kubeconfig

To obtain a kubeconfig customized to your cluster, navigate to the Platform9 clusters page and click the kubeconfig link.
Cluster UI Detail

Make kubeconfig discoverable by kubectl

kubectl will by default read the file


We recommend placing your kubeconfig there. Otherwise, you can pass kubectl the option

--kubeconfig /path/to/config

Download kubectl

kubectl is an executable binary build specifically for combinations of OS and CPU architectures. Choose from the following to download kubectl, make it executable, and move it to /usr/local/bin:

# linux/amd64
curl -Lo kubectl http://storage.googleapis.com/kubernetes-release/release/v1.7.7/bin/linux/amd64/kubectl
chmod +x kubectl && sudo mv kubectl /usr/local/bin/
# OS X/amd64
curl -Lo kubectl http://storage.googleapis.com/kubernetes-release/release/v1.7.7/bin/darwin/amd64/kubectl
chmod +x kubectl && sudo mv kubectl /usr/local/bin/

Using kubectl

To see the nodes in your cluster

kubectl get nodes

Let's make a Deployment with one nginx Pod:

kubectl run nginx-example --image=nginx --port=80

And watch the Pods as they are created (Ctrl-C to stop):

kubectl get pods --watch

Finally, delete the Deployment. The Pod will be deleted automatically.

kubectl delete deployment nginx-example

For more details, see the Kubernetes overview for kubectl.

September 29, 2016