Kategorien
Allgemein

docker desktop 1-node cluster

It’s useful to have a simple, single node kubernetes cluster under your control – to try out commands, check help, deploy simple apps…

In an earlier post, CRC was used, which starts a VM.

Another way to achieve this is using docker desktop. It has options to run that single node cluster you look for.

docker deskopt Kubernetes option

On my MacPro, BigSur 11.2.1, once I restarted my docker desktop 3.1.0, I am able to access the cluster – under my user id, using kubectl commands.

I’ve connected to several kubernetes k8s cluster in the past, so my $HOME/.kube/config file contains a bunch of connection infos. With the help of kubectl config I make my docker desktop k8s cluster the default.

Both the cluster docker-desktop and the user-context were written automatically into .kube/config... Now I am just making this my default:

kubectl config use-context docker-desktop
Switched to context „docker-desktop“.

You may find useful to look at all your clusters and use-contexts:

kubectl config get-clusters

kubectl config get-contexts

Hint: A context in Kubernetes is a group of access parameters. Each context contains a Kubernetes cluster, a user, and a namespace.

Update 2024: you may get certificat warnings. The following command helps to the the trustchain of docker.io and extract the intermediate and the root CA cert. (or use –insecure-skip-tls-verify)

#failed to verify certificate: x509: certificate signed by unknown authority (possibly because of "crypto/rsa: verification error" while trying to verify candidate authority certificate "kubernetes")

openssl s_client -showcerts -verify 5 -connect docker.io:443 < /dev/null

Some (system) pods do already run:

kubectl get pods –all-namespaces
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system coredns-f9fd979d6-mnf4q 1/1 Running 0 29m
kube-system coredns-f9fd979d6-rdhgw 1/1 Running 0 29m
kube-system etcd-docker-desktop 1/1 Running 0 28m
kube-system kube-apiserver-docker-desktop 1/1 Running 0 28m
kube-system kube-controller-manager-docker-desktop 1/1 Running 0 28m
kube-system kube-proxy-kjv54 1/1 Running 0 29m
kube-system kube-scheduler-docker-desktop 1/1 Running 0 28m
kube-system storage-provisioner 1/1 Running 0 28m
kube-system vpnkit-controller 1/1 Running 0 28m

It’s a simple one node cluster…

kubctl get nodes
NAME STATUS ROLES AGE VERSION
docker-desktop Ready master 35m v1.19.3

Hint: instead of using one big kubectl/config file, you can use multiple config files and just set an environment variabe, KUBECONFIG. An alias can help to list your known config files:

luftichris:.kube christianhofig$ alias eK
alias eK='echo KUBECONFIG=$KUBECONFIG; cat $HOME/bin/exports | egrep -v -e "^#"'
luftichris:.kube christianhofig$ cat ../bin/exports
export KUBECONFIG=~/.kube/rise/devopssandboxc3-rz01.yaml
export KUBECONFIG=~/.kube/rise/devopssandboxc2-rz01.yaml
export KUBECONFIG=~/.kube/rise/osc1.yaml
export KUBECONFIG=~/.kube/docker-desktop.yaml
export KUBECONFIG=~/.kube/hetzner.yaml