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

Vikas SurveVikas Surve
4 min read

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

๐Ÿ“Œ Next Step: Kubernetes Dashboard

0
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