There are several ways to setup a local development environment for Kubernetes, the two most common ones are Minikube
(docs) and docker-desktop
.
Minikube
provisions a local Kubernetes cluster on several Virtual Machines (via VirtualBox or something similar). docker-desktop
on the other hand, sets up Kubernetes cluster in docker containers.
In this tutorial, we'll use the latter approach, which is simpler and lightweight.
Download and install Docker-Desktop on your laptop. Latest version has an embedded version of Kubernetes so no additional install is needed. Just simply follow the instruction here to get Kubernetes up and running within docker-desktop.
Once Kubernetes is started in docker desktop, you should see something similar below:
This means that:
- Kubernetes is running.
- The command line tool
kubctl
is installed in the/usr/local/bin
directory. - The kubernetes context is set to
docker-desktop
.
After setting up the local kubernetes you need to deploy the dashboard using the following steps:
- Follow the instructions in Kubernetes dashboard doc to deploy the dashboard.
- Start the kubernetes proxy in the background from a terminal to get access on the dashboard on the local host:
kubectl proxy &
- Access the dashboard at the following URL: clickable link
The dashboard as deployed in the previous step requires a token or config to sign in. Here we use the token to sign in. The token is generated automatically and can be retrieved from the system.
- Retrieve the name of the dashboard token:
kubectl -n kube-system get secret | grep kubernetes-dashboard-token
- Retrieve the content of the token, note that the token name ends with a random 5 character code and needs to be replaced with the result of step 1. As an example:
kubectl -n kube-system describe secret kubernetes-dashboard-token-tf6n8
- Copy the token value which is part of the
Data
section with the tagtoken
. - Select the Token option in the dashboard web UI:
- Paste the token value into the input box and sign in:
This setup assumes you have already installed a remote Kubernetes cluster.
- Get kube
config
file from remote cluster, copy to the laptop - Properly set kubectl context with the new config (Detail step to be added...)
- Switch context using
kubectl config use-context kubernetes-admin@kubernetes
kubectl config get-contexts
CURRENT NAME CLUSTER AUTHINFO NAMESPACE
docker-for-desktop docker-for-desktop-cluster docker-for-desktop
* kubernetes-admin@kubernetes kubernetes kubernetes-admin
More docs can be found here