Configuring a local Kubernetes Cluster using Docker Desktop on Windows
Tags: docker, kubernetes, beginners
Published: 2021-02-24 23:14:05

>This article is focused on Windows, but a similar experience is expected on Docker Desktop for Macs.



So you want to try out, experiment with Kubernetes but you don't have a cluster, yet. The good news is that Docker Desktop has a solution for you.

After downloading Docker Desktop [here](https://www.docker.com/products/docker-desktop) follow the [installation instructions](https://docs.docker.com/docker-for-windows/install/) and you should have Docker installed and configured.  

After that, open the Docker Desktop application, click on the small gear on the right corner of the app screen, a.k.a settings and you should find something similar to the image below. All you need to do now is to click on "Enable Kubernetes" option then "Apply and Restart" and you should have a workable one node cluster to test your deployments.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gn4152ob5bb5q0494phg.png)

I suggest that between your test cycles, use the option "Reset Kubernetes Cluster" to ensure your environment has a fresh start for your new tests.

Now try out accessing the cluster from a command prompt using kubectl (Kubernetes CLI) that was already installed as part of Docker Desktop. You should see something similar to the lines below.

`kubectl describe nodes`

```
Name:               docker-desktop
Roles:              master
Labels:             beta.kubernetes.io/arch=amd64
                    beta.kubernetes.io/os=linux
                    kubernetes.io/arch=amd64
                    kubernetes.io/hostname=docker-desktop
                    kubernetes.io/os=linux
                    node-role.kubernetes.io/master=
Annotations:        kubeadm.alpha.kubernetes.io/cri-socket: /var/run/dockershim.sock
                    node.alpha.kubernetes.io/ttl: 0
                    volumes.kubernetes.io/controller-managed-attach-detach: true
CreationTimestamp:  Wed, 24 Feb 2021 22:57:16 +0100
Taints:             <none>
Unschedulable:      false
Lease:
  HolderIdentity:  docker-desktop
  AcquireTime:     <unset>
  RenewTime:       Wed, 24 Feb 2021 23:00:06 +0100
Conditions:
  Type             Status  LastHeartbeatTime                 LastTransitionTime                Reason                       Message
  ----             ------  -----------------                 ------------------                ------                       -------
  MemoryPressure   False   Wed, 24 Feb 2021 22:59:47 +0100   Wed, 24 Feb 2021 22:57:13 +0100   KubeletHasSufficientMemory   kubelet has sufficient memory available
  DiskPressure     False   Wed, 24 Feb 2021 22:59:47 +0100   Wed, 24 Feb 2021 22:57:13 +0100   KubeletHasNoDiskPressure     kubelet has no disk pressure
  PIDPressure      False   Wed, 24 Feb 2021 22:59:47 +0100   Wed, 24 Feb 2021 22:57:13 +0100   KubeletHasSufficientPID      kubelet has sufficient PID available
  Ready            True    Wed, 24 Feb 2021 22:59:47 +0100   Wed, 24 Feb 2021 22:57:47 +0100   KubeletReady                 kubelet is posting ready status
Addresses:
  InternalIP:  192.168.65.3
  Hostname:    docker-desktop
Capacity:
  cpu:                16
  ephemeral-storage:  263174212Ki
  hugepages-2Mi:      0
  memory:             13020552Ki
  pods:               110
Allocatable:
  cpu:                16
  ephemeral-storage:  242541353378
  hugepages-2Mi:      0
  memory:             12918152Ki
  pods:               110
System Info:
  Machine ID:                 2d9be7ee-9db8-4724-8b48-c3017de7c8f7
  System UUID:                2d9be7ee-9db8-4724-8b48-c3017de7c8f7
  Boot ID:                    ffa2e5e8-8525-43fa-9a11-136d213cd56d
  Kernel Version:             5.4.72-microsoft-standard-WSL2
  OS Image:                   Docker Desktop
  Operating System:           linux
  Architecture:               amd64
  Container Runtime Version:  docker://20.10.2
  Kubelet Version:            v1.19.3
  Kube-Proxy Version:         v1.19.3
Non-terminated Pods:          (9 in total)
  Namespace                   Name                                      CPU Requests  CPU Limits  Memory Requests  Memory Limits  AGE
  ---------                   ----                                      ------------  ----------  ---------------  -------------  ---
  kube-system                 coredns-f9fd979d6-d4z9r                   100m (0%)     0 (0%)      70Mi (0%)        170Mi (1%)     2m42s
  kube-system                 coredns-f9fd979d6-w5spm                   100m (0%)     0 (0%)      70Mi (0%)        170Mi (1%)     2m42s
  kube-system                 etcd-docker-desktop                       0 (0%)        0 (0%)      0 (0%)           0 (0%)         110s
  kube-system                 kube-apiserver-docker-desktop             250m (1%)     0 (0%)      0 (0%)           0 (0%)         100s
  kube-system                 kube-controller-manager-docker-desktop    200m (1%)     0 (0%)      0 (0%)           0 (0%)         86s
  kube-system                 kube-proxy-6hj7l                          0 (0%)        0 (0%)      0 (0%)           0 (0%)         2m42s
  kube-system                 kube-scheduler-docker-desktop             100m (0%)     0 (0%)      0 (0%)           0 (0%)         98s
  kube-system                 storage-provisioner                       0 (0%)        0 (0%)      0 (0%)           0 (0%)         86s
  kube-system                 vpnkit-controller                         0 (0%)        0 (0%)      0 (0%)           0 (0%)         86s
Allocated resources:
  (Total limits may be over 100 percent, i.e., overcommitted.)
  Resource           Requests    Limits
  --------           --------    ------
  cpu                750m (4%)   0 (0%)
  memory             140Mi (1%)  340Mi (2%)
  ephemeral-storage  0 (0%)      0 (0%)
  hugepages-2Mi      0 (0%)      0 (0%)
Events:
  Type    Reason                   Age                    From        Message
  ----    ------                   ----                   ----        -------
  Normal  NodeHasSufficientMemory  2m56s (x8 over 2m56s)  kubelet     Node docker-desktop status is now: NodeHasSufficientMemory
  Normal  NodeHasNoDiskPressure    2m56s (x8 over 2m56s)  kubelet     Node docker-desktop status is now: NodeHasNoDiskPressure
  Normal  NodeHasSufficientPID     2m56s (x7 over 2m56s)  kubelet     Node docker-desktop status is now: NodeHasSufficientPID
  Normal  Starting                 2m41s                  kube-proxy  Starting kube-proxy.
```

`kubectl get pods -o wide --all-namespaces`
```
NAMESPACE     NAME                                     READY   STATUS    RESTARTS   AGE     IP             NODE             NOMINATED NODE   READINESS GATES
kube-system   coredns-f9fd979d6-d4z9r                  1/1     Running   0          4m16s   10.1.0.2       docker-desktop   <none>           <none>
kube-system   coredns-f9fd979d6-w5spm                  1/1     Running   0          4m16s   10.1.0.3       docker-desktop   <none>           <none>
kube-system   etcd-docker-desktop                      1/1     Running   0          3m24s   192.168.65.3   docker-desktop   <none>           <none>
kube-system   kube-apiserver-docker-desktop            1/1     Running   0          3m14s   192.168.65.3   docker-desktop   <none>           <none>
kube-system   kube-controller-manager-docker-desktop   1/1     Running   0          3m      192.168.65.3   docker-desktop   <none>           <none>
kube-system   kube-proxy-6hj7l                         1/1     Running   0          4m16s   192.168.65.3   docker-desktop   <none>           <none>
kube-system   kube-scheduler-docker-desktop            1/1     Running   0          3m12s   192.168.65.3   docker-desktop   <none>           <none>
kube-system   storage-provisioner                      1/1     Running   0          3m      10.1.0.4       docker-desktop   <none>           <none>
kube-system   vpnkit-controller                        1/1     Running   0          3m      10.1.0.5       docker-desktop   <none>           <none>
```
Alternatively you can also use Minikube to set up a cluster on your local machine, using [this] (https://minikube.sigs.k8s.io/docs/start/) tutorial.

For the latest information always check the Kubernetes [official documentation](https://kubernetes.io/docs/home/). 

Last but not least, some pieces of training on Docker and Kubernetes that might help on your container journey:

**Docker**
https://www.youtube.com/watch?v=3c-iBn73dDE
**Kubernetes**
https://www.youtube.com/watch?v=X48VuDVv0do
**Kubernetes Services**
https://www.youtube.com/watch?v=T4Z7visMM4E
**Kubernetes Pods and Containers - Networking**
https://www.youtube.com/watch?v=5cNrTU6o3Fw
 
Videos are from **Techworld with Nana** check out [her page]( https://dev.to/techworld_with_nana) for more interesting stuff.