π Embracing Seamless Storage: Mounting NAS storage into Kubernetes π
Table of contents
Introduction:
Back with another exhilarating exploration into the world of Kubernetes. In today's blog, we're delving into the captivating realm of connecting Kubernetes with Network Attached Storage (NAS) using Static Persistent Volume Claims (PVCs) and the Network File System (NFS) protocol. Picture the power of effortlessly bridging your cloud or OS-based storage with your Kubernetes environment. Let's dive in!
Unveiling the Magic: Static PVCs and NFS Protocol:
Imagine a scenario where your Kubernetes applications can seamlessly access storage resources from a different OS or cloud environment. Enter Static PVCs powered by the NFS protocol. In this journey, we're connecting and accessing stored information smoothly and beautifully.
Setting the Stage: Building Your Ubuntu NAS Storage: πΎ
Our adventure commences with an Ubuntu-based NAS storage setup. We'll create a folder, configure NFS sharing, and ensure the NFS server is up and running. By utilizing the systemctl start nfs-server
command, we're ready to share the chosen folder. And with the exportfs -v
command, we ensure our shared resources are visible.
Mounting the Magic: Kubernetes Meets NFS:π
The spotlight then shifts to our Kubernetes environment, where Minikube enters the scene. We'll manually mount the NAS storage to Minikube using the sudo mount
command. A quick check using df -h
confirms our successful mount. This seamless connection is a testament to the orchestration power of Kubernetes.
Automating the Marvel: Harnessing Kubernetes YAML Magic: ππ§
But wait, our goal isn't just manual orchestrationβit's the magic of automation. We'll venture into Kubernetes YAML, where our pv.yml
file comes to life. This YAML masterpiece encapsulates the connection between Kubernetes and the NAS, allowing us to effortlessly provision and manage storage.
apiVersion: v1
kind: PersistentVolume
metadata:
name: mypv
spec:
capacity:
storage: 5Gi
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: ""
nfs: # NFS configuration
server: 192.168.1.9 # Replace with your NFS server IP
path: "/mydata1" # Replace with NFS server path
Unveiling the Marvel: Data in Motion: πͺ
With our pv.yml
ready, we create a pod, attach it to the PVC, and observe the magic unfold. Creating an index.html
file within the pod dynamically connects our NAS storage to Kubernetes. It's as if data flows seamlessly, effortlessly enriching our Kubernetes environment.
π The Grand Finale: Closing the Curtain on Connectivity: ππ
As our journey concludes, we've witnessed the enchantment of connecting Kubernetes with NAS storage. Through Static PVCs and the NFS protocol, we've woven a tapestry of seamless storage access, showcasing the brilliance of Kubernetes orchestration.
Subscribe to my newsletter
Read articles from Rishabh verma directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Rishabh verma
Rishabh verma
Proficient in a variety of DevOps technologies, including AWS, Linux, Python, CI/CD, GitHub Action, Docker, Jenkins , kubernetes .