How to connect to a Kubernetes cluster hosted on DigitalOcean

Tagged digitalocean, kubernetes  Languages bash

Tested April, 2019.

  1. Download the Kubernetes configuration from the DigitalOcean dashboard

  2. Move the Kubernetes configuration file to ~/.kube folder
$ mkdir $HOME/.kube/projectx/
$ mv ~/Downloads/projectx-staging-kubeconfig.yaml $HOME/.kube/projectx/staging-kubeconfig.yaml
  1. List all contexts in the KUBECONFIG variable
$ export KUBECONFIG=$HOME/.kube/projectx/staging-kubeconfig.yaml:$HOME/.kube/projectx/production-kubeconfig.yaml
  1. Install kubectl
$ brew install kubectl
  1. List context and nodes
$ kubectl config get-contexts
$ kubectl get nodes
$ kubectl config use-context