Configure kubectl

The primary CLI tool used to interact with the Kubernetes API is called kubectl.

The following steps should be done from your local workstation to configure kubectl to work with your new cluster.

First, download the binary using a command-line tool such as wget or curl:

# Replace ${ARCH} with "linux" or "darwin" based on your workstation operating system
$ ARCH=linux; wget${ARCH}/amd64/kubectl

After downloading the binary, ensure it is executable and move it into your PATH:

$ chmod +x kubectl
$ mv kubectl /usr/local/bin/kubectl

Configure your local Kubernetes client using the following commands:

  • Replace ${MASTER_IP}
  • Replace ${CA_CERT} with the path to the ca.pem created in previous steps
  • Replace ${ADMIN_KEY} with the path to the admin-key.pem created in previous steps
  • Replace ${ADMIN_CERT} with the path to the admin.pem created in previous steps
$ kubectl config set-cluster vagrant --server=https://${MASTER_IP}:443 --certificate-authority=${CA_CERT}
$ kubectl config set-credentials vagrant-admin --certificate-authority=${CA_CERT} --client-key=${ADMIN_KEY} --client-certificate=${ADMIN_CERT}
$ kubectl config set-context vagrant --cluster=vagrant --user=vagrant-admin
$ kubectl config use-context vagrant

Check that your client is configured properly by using kubectl to inspect your cluster:

$ kubectl get nodes
NAME          LABELS                               STATUS
X.X.X.X       Ready

Is kubectl working from your local machine? We're going to install an add-on with it next.

Yes, ready to deploy add-ons