Running Kubernetes Cluster in Docker for Windows


In the latest Edge version (18.02 CE Edge) of Docker for Windows support for Kubernetes is added.

If you want to start playing with Kubernetes you need to do the following:

  1. Download the latest (18.02 CE Edge) Docker for Windows Edge version from here.
  2. Install the Docker for Windows 18.02 CE Edge version you downloaded in step 1.
  3. Enable Kubernetes in the settings of the Docker for Windows Edge version.

Here are some screenshots made during the configuration of Kubernetes in the Docker for Windows Edge Client.

Wait till the Kubernetes cluster is deployed.

The Kubernetes cluster is now running.

The Kubernetes client command, kubectl, is included and configured to connect to the local Kubernetes server. If you have kubectl already installed and pointing to some other environment, such as minikube or a GKE cluster, be sure to change context so that kubectl is pointing to docker-for-desktop:

kubectl config get-contexts
kubectl config use-context docker-for-desktop

Let's check our Kubernetes Cluster.

NGINX Deployment

Let's deploy NGINX using the following deployment yaml file:

apiVersion: apps/v1beta2 # for versions before 1.9.0 use apps/v1beta2
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.7.9
        ports:
        - containerPort: 80

We see that NGINX is now running.

You can easily parse the kubectl JSON output using the following PowerShell Code:

#region get k8s pods info
(kubectl get pods --all-namespaces -o=json | convertfrom-json).items | select @{L='nodeName';E={$_.spec.nodeName}}, @{L='podIP';E={$_.status.podIP}}, @{L='hostIP';E={$_.status.hostIP}}, @{L='podName';E={$_.metadata.name}}, @{L='states';E={$_.status.containerStatuses.state}} | format-Table *
#endregion

Interested in Kubernetes Nodes info?

#region get k8s nodes info
(kubectl get nodes --all-namespaces -o=json | convertfrom-json).items | select @{L='IPAddress';E={$_.status.Addresses[0].address}}, @{L='Name';E={$_.metadata.name}}, @{L='Role';E={$_.metadata.labels.'kubernetes.io/role'}} | Format-Table *
#endregion

Expose Deployment NGINX

Retrieve Deployment(s)

kubectl get deployments

Expose NGINX deployment:

kubectl expose deployment nginx-deployment --type=NodePort

Have fun playing with Kubernetes in Docker for Windows.

References:

Comments (0)

Skip to main content