Deploying the Expenses Tracker WebApp on Kubernetes


Introduction
Kubernetes is a powerful container orchestration tool that enables efficient deployment, scaling, and management of applications. After learning Docker and containerizing applications, I wanted to take the next step by deploying a real-world project using Kubernetes. In this blog, I’ll walk through the process of deploying the Expenses Tracker WebApp on Kubernetes.
Setting Up the Kubernetes Environment
Before deploying the application, we need to set up a Kubernetes cluster. You can use Minikube, Kind, or a cloud provider like AWS (EKS), GCP (GKE), or Azure (AKS). I used Kind for my local setup.
Prerequisites:
Install kubectl: The command-line tool to interact with Kubernetes.
Set up Kubernetes Cluster:
kind create cluster --name expenses-cluster
Verify the cluster is running:
kubectl get nodes
Deploying the App Using Kubernetes Manifests
To deploy the Expenses Tracker WebApp, I created Kubernetes manifests for the Namespace, Deployment, and Service.
1. Creating a Namespace
The namespace helps isolate the application from other workloads in the cluster.
namespace.yml:
apiVersion: v1
kind: Namespace
metadata:
name: notes-app
labels:
name: notes-app
Apply the namespace:
kubectl apply -f namespace.yml
2. Creating a Deployment
The Deployment ensures the application runs inside a pod and restarts automatically if needed.
deployment.yml:
apiVersion: apps/v1
kind: Deployment
metadata:
name: notes-app-deployment
labels:
app: notes-app
namespace: notes-app
spec:
replicas: 1
selector:
matchLabels:
app: notes-app
template:
metadata:
labels:
app: notes-app
spec:
containers:
- name: notes-app
image: parijain18/notes-app
ports:
- containerPort: 8000
Apply the deployment:
kubectl apply -f document.yml
3. Exposing the App with a Service
A Service exposes the application to other components inside or outside the cluster.
service.yml:
apiVersion: v1
kind: Service
metadata:
name: notes-app
namespace: notes-app
spec:
selector:
app: notes-app
ports:
- protocol: TCP
port: 8000
targetPort: 8000
type: ClusterIP
Apply the service:
kubectl apply -f service.yml
Verifying the Deployment
Once the manifests are applied, check if everything is running correctly.
kubectl get pods -n notes-app
kubectl get svc -n notes-app
To view application logs:
kubectl logs -f deployment/notes-app-deployment -n notes-app
Helm: Packaging and Deploying the App
Since I am also learning Helm, I wanted to explore how Helm charts simplify Kubernetes deployments.
1. Creating a Helm Chart
helm create expenses-tracker-chart
Modify values.yaml
to define image, service, and other configurations.
2. Deploying with Helm
helm install expenses-tracker ./expenses-tracker-chart
Verify the Helm deployment:
helm list
kubectl get all -n notes-app
Conclusion & Next Steps
Deploying the Expenses Tracker WebApp on Kubernetes helped me understand real-world cluster management. Next, I plan to explore scaling, monitoring with Prometheus/Grafana, and setting up CI/CD pipelines.
If you are learning Kubernetes, I highly recommend trying out a project like this. Let’s connect and share our learning experiences! 🚀
Subscribe to my newsletter
Read articles from Pari Jain directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
