๐ Part 2 Mastering Kubernetes: Deploying Kind Clusters and Applications with Ease


1๏ธโฃ Overview
This section focuses on deploying a Kind (Kubernetes in Docker) cluster and deploying the EasyShop application along with MongoDB. We'll also cover networking, storage configuration, and troubleshooting.
โ
Set up a Kind Cluster (Lightweight Kubernetes in Docker)
โ
Deploy MongoDB and Persistent Storage
โ
Deploy EasyShop Application (E-Commerce app)
โ
Configure Networking, Services, and Storage
By the end of this section, youโll have a fully functional Kubernetes cluster with a running application. ๐
2๏ธโฃ Setting Up a Kind Cluster
๐น Why Use Kind?
Kind is a lightweight Kubernetes cluster that runs in Docker containers.
It allows for fast testing and local development.
It mimics a real Kubernetes cluster without requiring a cloud provider.
๐น Install Kind & Verify Installation
If you havenโt installed Kind, install it with the following:
bashCopyEditcurl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.20.0/kind-linux-amd64
chmod +x ./kind
sudo mv ./kind /usr/local/bin/kind
Verify installation:
bashCopyEditkind version
โ Sample Output:
bashCopyEditkind v0.20.0 go1.19.4 linux/amd64
๐น Create a Kubernetes Cluster with Kind
We'll use a custom Kind cluster configuration to optimize networking and storage.
Download the Cluster Configuration File
bashCopyEditcurl -o kind-config.yaml https://raw.githubusercontent.com/Vikas-DevOpsPractice/EasyShop/feature/kindcluster/K8s/00-kind-config.yaml
Create the Kind Cluster
bashCopyEditkind create cluster --name easyshop --config kind-config.yaml
โ Sample Output:
bashCopyEditCreating cluster "easyshop" ...
โ Ensuring node image (kindest/node:v1.28.0) ๐ผ
โ Preparing nodes ๐ฆ
โ Configuring nodes ๐
โ Writing configuration ๐
โ Starting control-plane ๐
Cluster "easyshop" created successfully ๐
3๏ธโฃ Configuring Kubernetes Namespace
Namespaces allow logical separation of resources in a cluster.
Download & Apply the Namespace Configuration
bashCopyEditcurl -o namespace.yaml https://raw.githubusercontent.com/Vikas-DevOpsPractice/EasyShop/feature/kindcluster/K8s/01-namespace.yaml
kubectl apply -f namespace.yaml
โ Sample Output:
arduinoCopyEditnamespace/easyshop created
4๏ธโฃ Setting Up Persistent Storage for MongoDB
๐น Why is this important?
Persistent Volumes (PV) ensure MongoDB retains data across pod restarts.
Persistent Volume Claims (PVC) allow MongoDB to dynamically request storage.
๐น Create a Persistent Volume
Download & Apply the PV Configuration
bashCopyEditcurl -o mongodb-pv.yaml https://raw.githubusercontent.com/Vikas-DevOpsPractice/EasyShop/feature/kindcluster/K8s/02-mongodb-pv.yaml
kubectl apply -f mongodb-pv.yaml
โ Sample Output:
bashCopyEditpersistentvolume/mongodb-pv created
๐น Create a Persistent Volume Claim
Download & Apply the PVC Configuration
bashCopyEditcurl -o mongodb-pvc.yaml https://raw.githubusercontent.com/Vikas-DevOpsPractice/EasyShop/feature/kindcluster/K8s/03-mongodb-pvc.yaml
kubectl apply -f mongodb-pvc.yaml
โ Sample Output:
bashCopyEditpersistentvolumeclaim/mongodb-pvc created
5๏ธโฃ Creating ConfigMap and Secrets
๐น Why is this important?
ConfigMaps store non-sensitive configurations like database URIs.
Secrets store sensitive credentials securely.
๐น Create a ConfigMap
Download & Apply the ConfigMap
bashCopyEditcurl -o configmap.yaml https://raw.githubusercontent.com/Vikas-DevOpsPractice/EasyShop/feature/kindcluster/K8s/04-configmap.yaml
kubectl apply -f configmap.yaml
โ Sample Output:
arduinoCopyEditconfigmap/easyshop-config created
๐น Create a Secret
Download & Apply the Secret
bashCopyEditcurl -o secrets.yaml https://raw.githubusercontent.com/Vikas-DevOpsPractice/EasyShop/feature/kindcluster/K8s/05-secrets.yaml
kubectl apply -f secrets.yaml
โ Sample Output:
bashCopyEditsecret/mongodb-secret created
6๏ธโฃ Deploying MongoDB Service & StatefulSet
๐น Why StatefulSet?
MongoDB requires persistent identity & storage.
StatefulSets ensure pods retain their hostname and volume claims.
๐น Create MongoDB Service
Download & Apply the Service Configuration
bashCopyEditcurl -o mongodb-service.yaml https://raw.githubusercontent.com/Vikas-DevOpsPractice/EasyShop/feature/kindcluster/K8s/06-mongodb-service.yaml
kubectl apply -f mongodb-service.yaml
โ Sample Output:
bashCopyEditservice/mongodb created
๐น Deploy MongoDB StatefulSet
Download & Apply the StatefulSet
bashCopyEditcurl -o mongodb-statefulset.yaml https://raw.githubusercontent.com/Vikas-DevOpsPractice/EasyShop/feature/kindcluster/K8s/07-mongodb-statefulset.yaml
kubectl apply -f mongodb-statefulset.yaml
โ Sample Output:
bashCopyEditstatefulset.apps/mongodb created
7๏ธโฃ Deploying the EasyShop Application
๐น Download & Apply the Deployment Configuration
bashCopyEditcurl -o easyshop-deployment.yaml https://raw.githubusercontent.com/Vikas-DevOpsPractice/EasyShop/feature/kindcluster/K8s/08-easyshop-deployment.yaml
kubectl apply -f easyshop-deployment.yaml
โ Sample Output:
bashCopyEditdeployment.apps/easyshop created
๐น Deploy the EasyShop Service
bashCopyEditcurl -o easyshop-service.yaml https://raw.githubusercontent.com/Vikas-DevOpsPractice/EasyShop/feature/kindcluster/K8s/09-easyshop-service.yaml
kubectl apply -f easyshop-service.yaml
โ Sample Output:
bashCopyEditservice/easyshop created
8๏ธโฃ Verifying Deployment
๐น Check MongoDB & EasyShop Pods
bashCopyEditkubectl get pods -n easyshop
โ Expected Output:
sqlCopyEditNAME READY STATUS RESTARTS AGE
mongodb-0 1/1 Running 0 3m
easyshop-58bffd5bcd-xyz12 1/1 Running 0 2m
๐น Check Services
bashCopyEditkubectl get svc -n easyshop
โ Expected Output:
nginxCopyEditNAME TYPE CLUSTER-IP PORT(S) AGE
mongodb ClusterIP 10.96.12.10 27017/TCP 3m
easyshop ClusterIP 10.96.15.20 80/TCP 2m
๐ฏ Conclusion
๐ Kind Cluster & Application Deployment is complete!
โ
Kind Cluster is running inside Docker
โ
MongoDB is deployed with Persistent Storage
โ
EasyShop application is running on Kubernetes
Subscribe to my newsletter
Read articles from Vikas Surve directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Vikas Surve
Vikas Surve
I am an ๐ ๐ฆ ๐๐ฒ๐ฟ๐๐ถ๐ณ๐ถ๐ฒ๐ฑ ๐๐ฒ๐๐ข๐ฝ๐ ๐๐ป๐ด๐ถ๐ป๐ฒ๐ฒ๐ฟ ๐๐ ๐ฝ๐ฒ๐ฟ๐ and ๐๐๐๐ฟ๐ฒ ๐๐ฑ๐บ๐ถ๐ป๐ถ๐๐๐ฟ๐ฎ๐๐ผ๐ฟ ๐๐๐๐ผ๐ฐ๐ถ๐ฎ๐๐ฒ with over ๐ญ๐ฌ ๐๐ฒ๐ฎ๐ฟ๐ ๐ผ๐ณ ๐ฒ๐ ๐ฝ๐ฒ๐ฟ๐ถ๐ฒ๐ป๐ฐ๐ฒ in designing, implementing, and optimizing DevOps solutions. My expertise includes ๐๐/๐๐ ๐ฎ๐๐๐ผ๐บ๐ฎ๐๐ถ๐ผ๐ป ๐๐๐ถ๐ป๐ด ๐๐ถ๐๐๐ฎ๐ฏ, ๐๐ฒ๐ป๐ธ๐ถ๐ป๐, ๐ฎ๐ป๐ฑ ๐๐๐๐ฟ๐ฒ ๐๐ฒ๐๐ข๐ฝ๐, as well as ๐๐ผ๐ป๐๐ฎ๐ถ๐ป๐ฒ๐ฟ ๐ผ๐ฟ๐ฐ๐ต๐ฒ๐๐๐ฟ๐ฎ๐๐ถ๐ผ๐ป ๐๐ถ๐๐ต ๐๐ผ๐ฐ๐ธ๐ฒ๐ฟ ๐ฎ๐ป๐ฑ ๐๐๐ฏ๐ฒ๐ฟ๐ป๐ฒ๐๐ฒ๐. ๐น ๐๐ ๐ฝ๐ฒ๐ฟ๐ ๐ถ๐ป ๐ฑ๐ฒ๐๐ถ๐ด๐ป๐ถ๐ป๐ด ๐ฎ๐ป๐ฑ ๐บ๐ฎ๐ป๐ฎ๐ด๐ถ๐ป๐ด ๐ฒ๐ป๐ฑ-๐๐ผ-๐ฒ๐ป๐ฑ ๐๐/๐๐ ๐ฝ๐ถ๐ฝ๐ฒ๐น๐ถ๐ป๐ฒ๐ ๐น ๐๐ฎ๐ป๐ฑ๐-๐ผ๐ป ๐ฒ๐ ๐ฝ๐ฒ๐ฟ๐ถ๐ฒ๐ป๐ฐ๐ฒ ๐๐ถ๐๐ต ๐๐๐๐ฟ๐ฒ, ๐๐๐ฏ๐ฒ๐ฟ๐ป๐ฒ๐๐ฒ๐ (๐๐๐ฆ), ๐ฎ๐ป๐ฑ ๐ง๐ฒ๐ฟ๐ฟ๐ฎ๐ณ๐ผ๐ฟ๐บ ๐ณ๐ผ๐ฟ ๐๐ฐ๐ฎ๐น๐ฎ๐ฏ๐น๐ฒ ๐ฑ๐ฒ๐ฝ๐น๐ผ๐๐บ๐ฒ๐ป๐๐ ๐น ๐ฃ๐ฎ๐๐๐ถ๐ผ๐ป๐ฎ๐๐ฒ ๐ฎ๐ฏ๐ผ๐๐ ๐ฎ๐๐๐ผ๐บ๐ฎ๐๐ถ๐ผ๐ป, ๐๐ฒ๐ฐ๐๐ฟ๐ถ๐๐, ๐ฎ๐ป๐ฑ ๐ฐ๐น๐ผ๐๐ฑ-๐ป๐ฎ๐๐ถ๐๐ฒ ๐๐ฒ๐ฐ๐ต๐ป๐ผ๐น๐ผ๐ด๐ถ๐ฒ๐ ๐ ๐ฆ๐ธ๐ถ๐น๐น๐ & ๐ง๐ผ๐ผ๐น๐ โ ๐๐ฒ๐๐ข๐ฝ๐ & ๐๐/๐๐: Azure DevOps, GitLab, Jenkins โ ๐๐น๐ผ๐๐ฑ & ๐๐ป๐ณ๐ฟ๐ฎ๐๐๐ฟ๐๐ฐ๐๐๐ฟ๐ฒ: Azure, AWS โ ๐๐ป๐ณ๐ฟ๐ฎ๐๐๐ฟ๐๐ฐ๐๐๐ฟ๐ฒ ๐ฎ๐ ๐๐ผ๐ฑ๐ฒ (๐๐ฎ๐): Terraform, Bicep โ ๐๐ผ๐ป๐๐ฎ๐ถ๐ป๐ฒ๐ฟ๐ & ๐ข๐ฟ๐ฐ๐ต๐ฒ๐๐๐ฟ๐ฎ๐๐ถ๐ผ๐ป: Docker, Kubernetes (AKS) โ ๐๐ผ๐ป๐ณ๐ถ๐ด ๐ ๐ฎ๐ป๐ฎ๐ด๐ฒ๐บ๐ฒ๐ป๐: PowerShell, Shell Scripting โ ๐ ๐ผ๐ป๐ถ๐๐ผ๐ฟ๐ถ๐ป๐ด & ๐ข๐ฏ๐๐ฒ๐ฟ๐๐ฎ๐ฏ๐ถ๐น๐ถ๐๐: Grafana, Prometheus, Azure Monitor โ ๐ฆ๐ฒ๐ฐ๐๐ฟ๐ถ๐๐ & ๐ก๐ฒ๐๐๐ผ๐ฟ๐ธ๐ถ๐ป๐ด: Load Balancers, Firewalls, ClusterIP โ ๐ข๐ฝ๐ฒ๐ฟ๐ฎ๐๐ถ๐ป๐ด ๐ฆ๐๐๐๐ฒ๐บ๐: Linux, Mac ๐ก ๐๐ฒ๐ ๐ฆ๐๐ฟ๐ฒ๐ป๐ด๐๐ต๐ โ ๐๐น๐ผ๐๐ฑ ๐๐ฟ๐ฐ๐ต๐ถ๐๐ฒ๐ฐ๐๐๐ฟ๐ฒ & ๐๐๐๐ผ๐บ๐ฎ๐๐ถ๐ผ๐ป โ Designing and managing scalable cloud solutions โ ๐๐/๐๐ & ๐๐ฒ๐๐ข๐ฝ๐ ๐๐ฒ๐ฎ๐ฑ๐ฒ๐ฟ๐๐ต๐ถ๐ฝ โ Implementing robust and automated software delivery pipelines โ ๐ง๐ฒ๐ฎ๐บ ๐๐ฒ๐ฎ๐ฑ๐ฒ๐ฟ๐๐ต๐ถ๐ฝ & ๐ ๐ฒ๐ป๐๐ผ๐ฟ๐๐ต๐ถ๐ฝ โ Leading a 5-member team, fostering collaboration and growth โ ๐ฆ๐ฒ๐ฐ๐๐ฟ๐ถ๐๐ & ๐๐ผ๐บ๐ฝ๐น๐ถ๐ฎ๐ป๐ฐ๐ฒ โ Ensuring cloud security, compliance, and best practices โ ๐ฃ๐ฟ๐ผ๐ฏ๐น๐ฒ๐บ ๐ฆ๐ผ๐น๐๐ถ๐ป๐ด & ๐ข๐ฝ๐๐ถ๐บ๐ถ๐๐ฎ๐๐ถ๐ผ๐ป โ Driving efficiency through automation and DevOps practices โ ๐๐ผ๐ป๐๐ถ๐ป๐๐ผ๐๐ ๐๐ฒ๐ฎ๐ฟ๐ป๐ถ๐ป๐ด & ๐๐ป๐ป๐ผ๐๐ฎ๐๐ถ๐ผ๐ป โ Exploring emerging technologies and best practices