Kubernetes on docker for Windows and few crocodiles…
I am a linux guy, but one of my work boxes is Intel NUC under windows with quite good memory specs. So far I was using it to offload docker builds and use some VMs on a hyperV. Latest docker update has made things even more interesting — Docker for windows now is capable to run single node Kubernetes 1.1x cluster, which you can use for your experiments as well.
Even if Windows has WSL, it still does not behave in a way how my usual linux workplace do, thus on my local lab first (note: insecure) step I do — is exposing my windows kubernetes and docker ports to my linux notebook
Expose docker tcp daemon on 2375
Expose kubernetes management port
Accessing your cluster with kubectl from your linux machine:
by default docker patches your windows kube config with changes similar to below:
What you need — is to replicate config on your linux box, and tune server address to external interface address of your box.
After that, you can see the context on your linux box
and control it using native kubectl tool
Lets test install kubernetes dashboard, because docker for windows provides no specific UI for that part
New release of dashboard comes with RBAC as a default, but for that specific case we can go on a simplier setup, and get admin rights from the start : kubectl create -f k8s/dashboard-admin.yaml
where dashboard-admin.yaml is
Now you can run kubectl proxy
in some console, and also some better control over kubernetes cluster, accessible on http://localhost:8001/api/v1/namespaces/kube-system/services/http:kubernetes-dashboard:/proxy/#!/overview?namespace=default
Prof of concept deployment
Now lets test deploy CrocoHunter application. It’s a funny demo used often on kubecon conferences.
kubectl create -f croc-hunter.yaml --save-config
and ingress to it
Now we can check, if application was deployed correctly:
Definitely works. We can also access the application via kube proxy http://localhost:8001/api/v1/namespaces/default/services/http:croc-hunter:/proxy/
Exposing deployment externally
As usual application has at least one endpoint that can be accessed externally, we would like to emulate also that functionality (note: redhat minishift does this out of the box).
We might to it dirty the console, like
note tcp port 30815 above.
How can you access exposed ports?
Option (a), on the same windows box you can just navigate to http://127.0.0.1:30815/
We can achieve the same effect from the yaml definition
note tcp port as well 30688
.
Option(b) — basically I am also able to access port exposed on a box from my external linux box as well:
Which is kind of cool.
Summary: you can use built-in single node kubernetes node for small playground with your kubernetes experiments not only locally, but also on remote using set of tools you. This might be alternative to minikube / minishift if you do not need specific functionality from those.
Thanks!
Code in action:
Repository with code snippets above: https://github.com/Voronenko/win-k8s-croco
Croco game image: https://github.com/voronenko-p/docker-sample-image which is slightly modified https://github.com/lachie83/croc-hunter (fixed absolute references to resources to allow proper run under proxy)
Using for the first time
for subsequent…
Debugging access — requires running kubectl proxy
in background...
Launch kubernetes dashboard from url http://localhost:8001/api/v1/namespaces/kube-system/services/http:kubernetes-dashboard:/proxy/#!/overview?namespace=default
if you have installed one
Launch deployed micro service http://localhost:8001/api/v1/namespaces/default/services/http:croc-hunter:/proxy/