Introduction
Microk8s, the open-source Kubernetes distribution created by Canonical, has been a game changer for many organizations, including ours. Our team has utilized Microk8s in a wide range of scenarios, from developing simple scripts to deploying complex applications that serve tens of thousands of regular users. In each case, we were amazed by the simplicity and efficiency of Microk8s. The "zero-ops" promise means that it requires minimal effort to manage and maintain, freeing up time for our team to focus on more important tasks.
From setting up development environments to running production-grade applications, Microk8s simplifies the process and enables efficient operations. Its "zero-ops" claim is not just a catchy slogan, but a reality we have experienced firsthand. In this article, we will discuss our experience with Microk8s and highlight one common use case: creating persistent volumes.
We have an article about how to install MicroK8s in your single VM. Check this out!
Creating Persistent Volumes with Ease
One of the most common use cases we have encountered is the need to create persistent volumes. In traditional Kubernetes environments, this can be a complex and time-consuming process. However, with Microk8s, the implementation is surprisingly simple.
To create a persistent volume in Microk8s, all you need to do is define a PersistentVolumeClaim (PVC) in your deployment configuration. Microk8s takes care of the rest, automatically provisioning the storage and binding it to the desired container. This streamlined process reduces the potential for human error and accelerates deployment times, ultimately benefiting the entire organization. Here are the detailed steps:
Activate Hostpath Storage AddOn
The Hostpath storage add-on in MicroK8s provides a straightforward method for provisioning PersistentVolumes supported by a host directory. This is perfect for local development purposes, but users should keep in mind the following considerations for all use cases:
- PersistentVolumeClaims generated by the hostpath storage provisioner are tied to the local node, making it impossible to transfer them to a different node.
- A hostpath volume has the potential to expand beyond the capacity specified in the volume claim manifest.
~$ microk8s enable hostpath-storage
Creating PVC Configuration
We will create 5GB Persistent Volume with ReadWriteMany
access mode
Install it
~$ kubectl apply -f pvc.yml
Verify Installation
~$ kubectl get pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES
app-pvc Bound pvc-xxx 5Gi RWX microk8s-hostpath
About 8grams
We are a small DevOps Consulting Firm that has a mission to empower businesses with modern DevOps practices and technologies, enabling them to achieve digital transformation, improve efficiency, and drive growth.
Ready to transform your IT Operations and Software Development processes? Let's join forces and create innovative solutions that drive your business forward.
Subscribe to our newsletter for cutting-edge DevOps practices, tips, and insights delivered straight to your inbox!