k3d
k3d
makes it very easy to create single- and multi-node k3s
clusters in docker, e.g. for local development on Kubernetes.
- To use
k3d
, you will also need to . - Install the latest version of k3d.
- To interact with the Kubernetes cluster
- (Optional) Helm is the package manager for Kubernetes
Create a cluster and disable
Traefik
with the following command:To see the list of
k3d
clusters, use the following command:$ k3d cluster list
k3s-default
If you run multiple clusters, you need to choose which cluster
kubectl
talks to. You can set a default cluster forkubectl
by setting the current context in the file. Additionally you can run following command to set the current context forkubectl
.$ kubectl config use-context k3d-k3s-default
Switched to context "k3d-k3s-default".
Once you are done setting up a
k3d
cluster, you can proceed to on it.(Optional) Install an ingress gateway:
$ kubectl label namespace istio-system istio-injection=enabled
$ helm install istio-ingressgateway istio/gateway -n istio-system --wait
k3d
does not have a built in Dashboard UI like minikube. But you can still set up Dashboard, a web based Kubernetes UI, to view your cluster. Follow these instructions to set up Dashboard for .
To deploy Dashboard, run the following command:
$ GITHUB_URL=https://github.com/kubernetes/dashboard/releases
$ VERSION_KUBE_DASHBOARD=$(curl -w '%{url_effective}' -I -L -s -S ${GITHUB_URL}/latest -o /dev/null | sed -e 's|.*/||')
-
$ kubectl get pod -n kubernetes-dashboard
NAME READY STATUS RESTARTS AGE
dashboard-metrics-scraper-8c47d4b5d-dd2ks 1/1 Running 0 25s
kubernetes-dashboard-67bd8fc546-4xfmm 1/1 Running 0 25s
Create a
ServiceAccount
andClusterRoleBinding
to provide admin access to the newly created cluster.To log in to your Dashboard, you need a Bearer Token. Use the following command to store the token in a variable.
$ token=$(kubectl -n kubernetes-dashboard create token admin-user)
Display the token using the
echo
command and copy it to use for logging in to your Dashboard.$ echo $token
You can access your Dashboard using the kubectl command-line tool by running the following command:
Starting to serve on 127.0.0.1:8001
Click to view your deployments and services.
When you are done experimenting and you want to delete the existing cluster, use the following command: