Professional Documents
Culture Documents
Install A MicroK8s Single Node Cluster of Kubernetes On Windows 10
Install A MicroK8s Single Node Cluster of Kubernetes On Windows 10
Windows 10
By Philippe Beraud, Microsoft France
This walkthrough guides you through all the steps required to create and configure a MicroK8s
cluster on Windows 10.
Kubernetes1 runs on Linux. As such, MicroK8s2 provides a single command installation of the latest
Kubernetes release on a Linux machine for development and testing. MicroK8s is easy to install and
use on Ubuntu or any other Linux distro which supports snaps, i.e. pre-packaged applications (similar
to Docker containers).
Although Windows 10 now has some very useful features, such as the ability to install Ubuntu as an
app, the integration of Windows Subsystem for Linux 2 (WSL2) doesn’t provide (yet) all the Ubuntu
functionalities required to make MicroK8s run smoothly right out-of-the-box (OOB) and thus use the
snap daemon. If you wish to experiment with running MicroK8s semi-natively, see:
• Discourse post Using snapd in WSL2
• Post Running Snaps on WSL2 (Insiders only for now) along with the short YouTube video Use
this ONE trick to run Linux Snap packages in Windows Subsystem for Linux 2 (WSL2)
For now, and for the sake of simplicity for anyone looking to try out Kubernetes on Windows 10, let’s
run MicroK8s on Windows 10 with virtualization. MicroK8s will install without problems on Ubuntu on
a virtual machine (VM). The Canonical way to get a Linux VM on Windows 10 and to run MicroK8s in it
is with multipass.
Multipass gives you an easy to use interface to manage VMs on Windows 10 – Same is true on MacOS
and Linux -. On Windows platforms, multipass defaults to using Microsoft Hyper-V as it’s virtualization
provider. So, Microsoft Hyper-V is a prerequisite. (You can also take advantage of a local installation of
VirtualBox if you want to.)
Enabling Hyper-V
The Windows 10 Hyper-V System requires:
• Windows 10 Enterprise, Pro, or Education
• 64-bit Processor with Second Level Address Translation (SLAT).
• CPU support for VM Monitor Mode Extension (VT-c on Intel CPUs).
• Minimum of 4 GB memory.
Note For more information and troubleshooting, see Windows 10 Hyper-V System Requirements.
1
https://kubernetes.io/
2
https://github.com/ubuntu/microk8s
2. Check if virtualization is supported:
PS C:> systeminfo
If you see the following output, virtualization is supported. You can proceed with the next
steps.
If you see the following output, your system already has a Hypervisor installed and you can
skip the next steps below.
Hyper-V Requirements: A hypervisor has been detected. Features required for Hyper-V
will not be displayed.
Otherwise, virtualization is unfortunately not supported on your machine, and you can not
continue with this walkthrough.
3. Run the following command:
Note If the command couldn't be found, make sure you're running PowerShell as Administrator.
It’s most likely going to be the latest cloud image of the newest Ubuntu LTS (Long
Term Support) release, at the time of this writing a 18.04 LTS release.
Note You can also choose another image, you can use the find command to see what’s available.
Note For a complete listing of the available commands and their options in multipass, see the
Command-line reference.
When the command completes, a new VM named microk8s-vm is running. You can
see it from the Hyper-V Manager.
One should note that multipass uses the “Default Switch” network interface on Hyper-V, that,
in turn, uses the “Internet Sharing” functionality, providing DHCP (IP addresses) and DNS
(domain name resolution) to the instances.
3. Find the IP address which has been allocated to the VM:
Take a note of this IP as services will become available there when accessed from the Windows
10 host machine, see below. For example ,172.22.82.139 in our configuration.
4. To work within the VM environment more easily, get a shell inside the VM:
From within the VM shell, you can now follow along the rest of the quick start instructions for installing
MicroK8s on multipass.
Note Microk8s is a snap deploying Kubernetes. The MicroK8s snap closely follows upstream
Kubernetes, so understanding a bit about the Kubernetes release cycle is helpful for more insight into
MicroK8s releases. Upstream Kubernetes ships a new release series (e.g. 1.16.x) approximately every three
months. For more information, see Snap channel overview.
That’s all it takes for the installation, which is quick and painless! ;-)
2. MicroK8s has a built-in command to display its status (see hereafter). During installation you
can use the --wait-ready flag to wait for the Kubernetes services to initialize. Check the
status:
apiVersion: v1
clusters:
- cluster:
server: https://172.17.18.79:16443
name: microk8s-cluster
contexts:
- context:
cluster: microk8s-cluster
user: admin
name: microk8s
current-context: microk8s
kind: Config
preferences: {}
users:
- name: admin
user:
username: admin
password: UFpWSGlHZDJuSkxpcCtJZ0JTU1dDK2d0eWk3NTdhZEg0TjVQcWVDc3Ywdz0K
To feed this client config to microk8s.kubectl, you can for example write it to
~/.kube/config, i.e. the default configuration location.
$ sudo microk8s.config > $HOME/.kube/config
4. MicroK8s creates a group to enable seamless usage of commands which require admin
privilege. Add your current user to the group:
You will also need to re-enter the session for the group update to take place.
5. As mentioned above, MicroK8s bundles its own version of kubectl for accessing Kubernetes.
Use it to run commands to monitor and control your Kubernetes. For example, view your
node:
7. MicroK8s uses a namespaced kubectl command to prevent conflicts with any existing installs
of the Kubernetes command-line tool, kubectl. kubectl allows you to run commands against
Kubernetes clusters. You can use kubectl to deploy applications, inspect and manage cluster
resources, and view logs. See Overview of kubectl.
If you don't have an existing install, it is easier to add an alias (append to ~/.bash_aliases) like
this:
Otherwise, from the Bash terminal console, to install the latest version of kubectl, run the
following command:
2. It may take a minute or two to install, but you can check the status. Once NGINX has been
deployed, expose the application:
You now have a deployed an application to a fully functional Kubernetes cluster using Microk8s
Note that the & at the end of this command string will run the command in the
background.
b. You now should be able to access the Kubernetes dashboard by entering the
following URL:
http://<IP_address>:8001/api/v1/namespaces/kube-system/services/https:kubernetes-
dashboard:/proxy/
Since you are running a MicroK8s cluster in a VM, <IP_address> should be the IP
address of the microk8s-vm VM so that the Kubernetes dashboard can be accessed
from your local Windows 10 machine. For example, 172.22.82.139 in our configuration.
http://172.22.82.139:8001/api/v1/namespaces/kube-system/services/https:kubernetes-
dashboard:/proxy/
From your Windows 10 host machine, open a browser session and navigate to the
above URL and you will see the Kubernetes dashboard UI.
c. At this point, the Kubernetes dashboard requires a token for gaining access. Create a
list of all the service names, with their secret name attached:
Type: kubernetes.io/service-account-token
Data
====
ca.crt: 1103 bytes
namespace: 11 bytes
token:
eyJhbGciOiJSUzI1NiIsImtpZCI6Im9YZlF6c0pzNjlESmRUYXkzSlp3cjVYZkpwZDlidmNIUGdITG5CWUt5REUifQ.
eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1
lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJrdW
Jlcm5ldGVzLWRhc2hib2FyZC10b2tlbi04YnQ5MiIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZ
S1hY2NvdW50Lm5hbWUiOiJrdWJlcm5ldGVzLWRhc2hib2FyZCIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQv
c2VydmljZS1hY2NvdW50LnVpZCI6ImZjYWZiNTI3LWIyNDYtNGEzOS04YTllLThlOGQ3YzZjNTIyNSIsInN1YiI6InN
5c3RlbTpzZXJ2aWNlYWNjb3VudDprdWJlLXN5c3RlbTprdWJlcm5ldGVzLWRhc2hib2FyZCJ9.iYtoRdb4Qq9c4JL1n
SlFec631agfa-iV69shGoYhOWsBJCSuYCEal5Z5QxBC1lmuMp8fA-
vlXqm4vGboPIRHcrBZMHjzuNzWi0AsOdWQNWMqjoOsPA4NEYYsHN8embQBo5n3GNBYEMXNcTmZ5YY7qblHfzzZnje2S
S33ETQI_NuO4-cGVWk1mydUtnGhQkOLsYiDmkJKYt5CUIsgbTZvkynUmFHUZmjMSIAz1K2gdU1MqhGI2-
n9BpmdWQWHlpWH27_yTmvCivYznX6KPIsjG6jHHv4PFyw3PEFIXhkuOPL2MTwuKCx8Bcw7cEYSPd0uay8zVpvcipdeC
JORKUxTfw
The above command displays a long string of characters after token :. Copy that
string and then go back to your browser session.
e. In the above Kubernetes Dashboard dialog, select Token and then paste the copied
token into the Enter token* text field. Click Sign in and the Kubernetes dashboard
should open up.
Alternatively, you can allow accessing the Kubernetes dashboard without requiring such a
token. To do so:
a. Edit the deployment file for the dashboard service:
b. Add the –enable-skip-login flag to the deployment’s specs. Scroll down to the line
after - --namespace=kube-system, press i, type “- --enable-skip-login”, press ESC,
and then type “:w”.
spec:
progressDeadlineSeconds: 600
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
k8s-app: kubernetes-dashboard
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
creationTimestamp: null
labels:
k8s-app: kubernetes-dashboard
spec:
containers:
- args:
- --auto-generate-certificates
- --namespace=kube-system
- --enable-skip-login
$ kubectl cluster-info
Kubernetes master is running at https://127.0.0.1:16443
Heapster is running at https://127.0.0.1:16443/api/v1/namespaces/kube-
system/services/heapster/proxy
CoreDNS is running at https://127.0.0.1:16443/api/v1/namespaces/kube-system/services/kube-
dns:dns/proxy
Grafana is running at https://127.0.0.1:16443/api/v1/namespaces/kube-
system/services/monitoring-grafana/proxy
InfluxDB is running at https://127.0.0.1:16443/api/v1/namespaces/kube-
system/services/monitoring-influxdb:http/proxy
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
Grafana is running at https://127.0.0.1:16443/api/v1/namespaces/kube-
system/services/monitoring-grafana/proxy/.
5. Open a browser on your Windows 10 host machine and navigate to the following URL:
http://<IP_address>:8001/api/v1/namespaces/kube-system/services/https:kubernetes-
dashboard:/proxy/
As before, since you are running a MicroK8s cluster in a VM, <IP_address> should be
the IP address of the microk8s-vm VM so that the Kubernetes dashboard can be
accessed from your local Windows 10 machine. For example, 172.22.82.139 in our
configuration.
http://172.22.82.139:8001/api/v1/namespaces/kube-system/services/monitoring-grafana/proxy
The Grafana dashboard should open up.
So, let’s remove the service and pods you have previously deployed:
At this stage, your MicroK8s cluster will continue running until you decide to stop it. You can stop
MicroK8s with this simple command:
$ microk8s.stop
You can start again any time by running:
$ microk8s.start
This concludes this walkthrough. You can now start using your MicroK8s single node cluster the
way you expect on your Windows 10 machine. This is great for technical ram-up on Kubernetes,
local development, and CI/CD.