On November 07, 2016, Microsoft announced support for Kubernetes on Azure Container Service (preview). The integration of Kubernetes with Azure Container Service, consumer will be able to create a fully functional Kubernetes cluster that is integrated with the rest of your Azure resources.
To understand and develop capabilities of Kubernetes with ACS for development, I had to setup Kubernetes on my local windows 10 laptop. In this blog post, I am going to take you through setting up Minikube on your Windows 10 development machine and along the way I will share my experience. I would strongly recommend you go through some basic materials on ACS, Docker for Windows and Kubernetes concepts.
In general, solution like Kubernetes requires bit of efforts to setup the environment locally. Ideally, you need development environment which is like QA/staging and allow you to do your development on your laptop. This was the goal of Minikube project which helps you run Kubernetes on your development machine.
Pre-requisites for Development Machine Environment:
• VT-x/AMD-v virtualization must be enabled in BIOS (requires machine restart)
• Enable Hyper-V – go to Windows features On or Off, you will see dialog box with a list of Windows features as shown below. Navigate to the Hyper-V section and enable it (requires machine restart).
Minikube Installation:
I prefer to use Hyper-V over VirtualBox to setup Kubernetes on my Windows machine because of its native windows support. The first step is to download Beta Channel Docker for Windows from here. Run Setup Default configuration to Install Docker on your machine. Refer here if you need details about how to setup Docker on Windows 10 machine. Once you have successfully installed Docker, confirm deployment by typing “docker info” command in Command window as shown below.
Now, we will setup a new external network switch which will be used by our Hyper-V to setup the Kubernetes on local machine as described below.
o Make sure you have Ethernet connectivity while you are setting this.
o Open the Hyper-V manager.
o Select the Virtual Switch Manager on the left-side Actions panel.
o Set up a new external network switch to use instead of Docker NAT network switch (for Moby), which is set up by default when you install Docker for Windows.
o For this example, we created a virtual switch called “My Virtual Switch”.
I would prefer to create one default Docker machine by using command docker-machine create –driver hyperv default
The next step is to download the latest Minikube binary from here and place that in the root folder of C drive. You may think why do you want to place binary in OS drive. This is because there is a bug in the Minikube which does not allow to install the local cluster if it is place anywhere other than C drive or in OS drive. Refer here for more details about bug. The file name is minikube-windows-amd64.exe. Rename this exe as “minikube” (just for simplicity).
Download the Kubectl command line utility from here and copy this alongside the kubectl.exe file from the previous section. We are all set now to launch a local Kubernetes one node cluster. Launch the PowerShell in Administrator mode and navigate to the drive where you have copied kubectl.exe and minikube.exe.
Let’s do standard testing to validate Minikube deployment by finding the version of Minikube and supported Kubernetes version as shown below. Go to %HOMEPATH%.minikube folder and you will notice several folders are created. Have a look!
There are multiple commands that Minikube supports. You can use ‘–help’ option to see the list of commands.
Start Kubernetes Cluster locally
We are now ready to launch our Kubernetes cluster locally and we use start command for it. Before we start the cluster, we will check available flags/options via the help options and will use few of them. We want to use Kubernetes version v1.5.2 and VM driver is hyperv. If you would like to add more memory to local Kubernetes cluster, I would recommend using memory flag. Make sure you define hyperv-virtual-switch flag which should point to the external network switch you have created previously. We are also going to use couple of global flags like –v=7 and –alsologtostderr to see what is going on under the hood.
Here is the command which we will execute to start the local Kuberenetes cluster.
.minikube.exe start –kubernetes-version=”v1.5.2″ –vm-driver=”hyperv” –memory=1024 –hyperv-virtual-switch=”My Virtual Switch” –v=7 –alsologtostderr
On success, you will get the messaging stating “Kubectl is now configured to use the cluster.”
Let us understand what it is doing behind the scene.
o It generates the certificates and provision local Docker host which creates VM inside the Hyper-V.
o The host is provisioned with the boot2docker.iso and setup it up.
o At the end, it configures the Kubectl to use the local Kubernetes cluster.
You can check the status of the local cluster using status command.
Use the kubectl CLI to get the cluster information. In case you see the error like “.kubectl : error: couldn’t read version from server:”, then you need to probably set the context again. The command for that is .kubectl config set-context minikube
Conclusion
Minikube is a work in progress at this moment and it does not support all the features of Kubernetes. Refer here to know what is supported today. Hope this blog post gets you started with Kubernetes on your Windows development machine by using minikube. Please let me know your experience. In next post, we’ll look at how to deploy container application in Kubernete development machine.
This post first appeared on MSDN Blogs | Get The Latest Information, Insights, Announcements, And News From Microsoft Experts And Developers In The MSDN Blogs., please read the originial post: here