You will learn:

  • Create a simple Kubernetes cluster from a single node using Docker Desktop
  • Use this procedure if you have WSL2 and Docker Desktop installed. New Windows 10 required

Installing Kubernetes

The Docker Desktop package also includes a single-node Kubernetes cluster. If you have Docker Desktop, the situation is simple - tap "Settings - Kubernetes - Enable Kubernetes" and wait a moment.

If the Kubernetes installation gets stuck on the message "Kubernetes startning ..." and nothing happens for a long time, apply the procedure in [this manual](https://stackoverflow.com/questions/57711639/docker-for-windows -stuck-at-kubernetes-is-starting-after-updating-to-version-2).

In short:

  • Stop the Kubernetes installation.
  • Enter Docker Desktop in "Factory Settings".
  • Delete the c:/ProgramData/DockerDesktop and c:/Users/user/.kube folders.
  • Restart DockerDesktop.
  • Restore the Kubernetes installation.

Installing kubectl

You will communicate with the cluster using the kubectl command. Working with kubectl is somewhat similar to working with thedocker client. The similarities are summarized in this guide.

Kubectl uses the network protocol to communicate with the application interface of the selected Kubernetes cluster, so it must have credentials to control the cluster.

The login details can be found in the file ~/.kube/config. The kubectl command accordingly retrieves information about the access data and the address of the cluster with which it communicates. The ~/.kube/config file should modify WSL2 and write the necessary information.

Probably the easiest is to download and copy the binary distribution kubectl:

curl -LO https://dl.k8s.io/release/v1.20.0/bin/linux/amd64/kubectl
sudo mv ./kubectl /usr/local/bin

This procedure is possible due to the fact that kubectl is programmed in GO language. GO programs are compiled with all dependencies linked and are not dependent on system libraries.

If the kubectl command cannot connect to a running cluster in the WSL2 environment, even though its installation was successful, try the following:

# Make a backup of the original configuration
# There may be other credentials in the old configuration
mv ~/.kube ./oldkube
Replace # user with the login name you use in Windows
# Copy data from Windows - These have been set up using Docker Desktop integration
cp -r /mnt/c/Users/user/.kube ~

Previous Post Next Post

Installing Kubernetes using Docker Desktop