Schedule an appointment

Kubernetes Simplified: Setting Up Microk8s on Windows, A Step-by-Step Guide

Kubernetes has become the go-to solution for container orchestration, but its complexity can be daunting, especially for on-premises environments.

Introduction:

Kubernetes has become the go-to solution for container orchestration, but its complexity can be daunting, especially for on-premises environments. However, MicroK8s offers a lightweight alternative, simplifying Kubernetes deployment and management. This article will explore why MicroK8s is an excellent choice, providing a streamlined experience without compromising essential functionalities. Whether you are an individual developer or an organization, MicroK8s offers a compelling solution for your on-premises Kubernetes needs.

What is MicroK8s?

MicroK8s is a CNCF-certified Kubernetes distribution designed for developers and project deployments in edge, IoT, and small environments. Developed and maintained by Canonical (the company behind Ubuntu), MicroK8s is robust yet light, offering a fully-conformant Kubernetes experience in a package small enough to be called "micro."

Comparing MicroK8s with Traditional Kubernetes

Microk8s offers several advantages over traditional Kubernetes.

Simplicity and Speed

MicroK8s significantly simplifies the Kubernetes setup process. Traditional Kubernetes setup can be complex and time-consuming, often requiring specialized skills. On the other hand, MicroK8s comes with a single command installation, making it much faster and simpler to get up and running.

Low-Resource Consumption

MicroK8s is a lightweight Kubernetes distribution that uses less CPU and memory than traditional Kubernetes. This makes it an ideal solution for smaller environments or lower-power devices where resource efficiency is a priority.

Robustness and Reliability

Despite its small size, MicroK8s packs all Kubernetes features, providing a robust and reliable platform. It ensures high availability, even in network outages or hardware failures.

MicroK8s Vs. Other Lightweight Kubernetes

MicroK8s is a great alternative to traditional Kubernetes; it also holds its own compared to lightweight Kubernetes alternatives like K3s and Minikube. Despite its small size, MicroK8s does not compromise on features. It includes the full Kubernetes APIs and can enable additional services like DNS, dashboard, ingress, and more, making it a capable solution even for production environments.

All-In-One Package

MicroK8s bundles all the components of a Kubernetes cluster into a single package, which makes it easy to install and update. This design simplifies the setup process, making it ideal for developers and small-scale deployments.

Secure and Up-to-Date

MicroK8s releases follow the Kubernetes release cycle, ensuring users always have the latest version. In addition, MicroK8s employs automatic updates and built-in security features that help maintain the integrity of your deployments. 

Cross-platform Support

MicroK8s boasts excellent cross-platform support. Whether you're running Linux, Windows, or macOS, MicroK8s has you covered.

Support for High Availability (HA) Clusters:

With MicroK8s, you can easily set up an HA cluster by adding additional nodes, a rare feature among lightweight Kubernetes solutions.

Great for Edge Computing:

Due to its lightweight nature and ability to run on various architectures, MicroK8s is an excellent choice for edge computing scenarios where resources may be limited and deployments must be as lightweight as possible.

Microk8s Windows Setup

In this blog post, we walk you through setting up MicroK8s on a Windows machine, enabling you to explore Kubernetes without the overhead of a full-scale cluster.

Prerequisites:

1. A Windows machine with Hyper-V enabled.

2. An active internet connection.

3. Basic familiarity with Docker and containerization concepts.

Download and run the Installer.

Download the MicroK8s Installer: Obtain the latest installer by visiting the MicroK8s website or using the following link: Download the latest installer here

Run the Installer:  

Run the downloaded installer file to begin the installation. The installer checks if Hyper-V is available and enabled. If Hyper-V is unavailable (e.g., on Windows Home edition), you can use VirtualBox as an alternative.

Configure MicroK8s:

Configure Microk8s after the installation. The installer provides minimum recommendations by default, but you can customize the configuration to meet your application requirements. You can change the configuration later by rerunning the installer. Remember that initial memory and disk limits are set to minimum values, so adjust them accordingly if you plan to run large workloads (e.g., kubeflow).

Check MicroK8s Status:

Open a command line interface and verify the MicroK8s status by executing the command:

microk8s status --wait-ready

This command provides information on the readiness of MicroK8s and its services.

Enable Desired Services:

MicroK8s offers a variety of add-ons and services that can be enabled at any time based on your needs. For example, to enable DNS, storage, ingress, and the dashboard, use the following commands:

microk8s enable dns
microk8s enable storage
microk8s enable ingress
microk8s enable dashboard

Use the microk8s disable <addon> command to turn off any specific add-on.

Start Using Kubernetes:

MicroK8s provides the familiar kubectl command for interacting with Kubernetes. You can perform any Kubernetes operation using MicroK8s. To get started, try running:

microk8s kubectl get all --all-namespaces

Enable Kubernetes Dashboard.

Enable Dashboard in Microk8s

microk8s enable dashboard

Change the type from ClusterIP to NodePort. Change the last line from type: ClusterIp to NodePort. Run the below in cmd. 

microk8s kubectl -n kube-system edit service kubernetes-dashboard

Save and close.

Check for the Port on which the dashboard is listening. Add the Windows firewall rule. Access it using https://url

microk8s kubectl -n kube-system svc

for Token Enter into the microk8s Shell and enter the command line using the root user

multipass shell microk8s-vm sudo su microk8s kubectl -n kube-system describe secret $(microk8s kubectl -n kube-system get secret | grep default-token | cut -d " " -f1)

copy and paste the token into the browser to access the Kubernetes Dashboard.

Deploy nginx webserver.

Create a deployment for the nginx webserver. Run the below command.

microk8s kubectl create deployment nginx --image=nginx

Expose service for nginx webserver as clusterip.

microk8s kubectl create service load balancer nginx --tcp=80:80

Windows port forwarding commands (Run as admin using PowerShell)

netsh interface portproxy add v4tov4 listenport=80 listenaddress=192.168.1.1 connectport=30789 connectaddress=

Go to your Web-browser to access http://192.168.1.1. You will see the nginx welcome page.

Netsh detailed information: https://learn.microsoft.com/en-us/windows-server/networking/technologies/netsh/netsh

Great! You have now successfully installed MicroK8s on your Windows system. We have deployed the nginx webserver and exposed it via Windows using the netsh command.

Conclusion:

MicroK8s is a compelling choice offering a simplified, low-resource, and robust solution for running Kubernetes. Its ease of use, impressive feature set, and cross-platform support setit apart from traditional Kubernetes and other lightweight alternatives.

Tags

Arystech Logo

We Love to Talk Tech

Whether you need advice or are ready to get started, we're here to help. We go the extra mile to empower your digital transformation.

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

accreditations

AWS - Lambda Delivery PartnerAWS - Well-Architected PartnerMicrosoft Partner