Hints about installation of Kubernates on Windows and deploying to cluster

Install https://chocolatey.org/

1. Install and CLI

choco install docker-desktop
choco install kubernetes-cli

Now you can check the installation by checking their versions.

docker -v

The kubectl command may return the following error for the 2nd connection:

Unable to connect to the server: dial tcp [::1]:6445: connectex: No connection could be made because the target machine actively refused it. 

This means you don't have Kubernetes yet.

2. Installing Kubernetes cluster

Install Kubernetes as it suggested by Docker in the client app.

In order to configure Kubernetes you need to configure network switch in Hyper-V and network adapter (sharing option). Read here.


The alternative way of installing a Kubernetes cluster is the using of of Minikube.

It also requires configuration of Hyper-V switch. On Windows system it's less preferable because its own image registry and it's very complicated to deploy an image created with Docker on Minikube cluster.

Deleting Minikube and cluster

If you installed with choco run the following commands:

minikube stop
minikube delete
choco uninstall minikube
choco uninstall kubernetes-cli

After that delete the following folders:

  • C:\users{user}.minikube
  • C:\users{user}.kube

3. Deploying to Docker

Create a docker image from the folder with your appplication:

docker build -t mydockerimage .

The . (dot) in the end refers to the current catalog. The very simple deployment is just running a command:

docker run -p 3001:3000 mydockerimage

The option -p maps internal port which the application listens to an external one. Using the command above you'll be able to see your deployed application using localhost:3001.

4. Using of

The easiest way of deploying several application to docker is using docker-compose. The command below performs the same deployment as we you did before with docker.

version: '3'
    image: "mydockerimage"
      context: .
      dockerfile: ./dockerfiles/Dockerfile.server
      - "3001:3000"

In contrast the deployment with docker-compose may be done with just only one command:

docker-compose up -d

The option -d stands for detached. This means the app will run in background.

In order to stop your deployment just run the following:

docker-compose stop

Using docker-compose you can deploy several apps and define number of replicas for each of them. Ream more here.

5. Cleaning Resources

After creating a new image you may want to remove previous and not used resources. In order to remove docker images use the following commands:

# to clear all
$ docker system prune
# to clear images
$ docker image prune -a --filter "until=12h"

For docker-compose use the following command when composing a new version (with option --remove-orphans):

docker-compose up -d --remove-orphans

See Also

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Related Post

%d bloggers like this: