This project demonstrates the deployment of a Dockerized application on a local Kubernetes cluster using Minikube. The setup includes deployments, services, a load balancer, and an optional Ingress controller for routing traffic. This project is designed to showcase Kubernetes skills with various ways to access the application.
- Docker: To build and run the app.
- Minikube: Local Kubernetes cluster tool.
- kubectl: Command-line tool for Kubernetes.
- NGINX Ingress Controller: Optional, for Ingress setup with Minikube.
Using Homebrew:
brew install minikube
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube
- Download the Minikube installer from Minikube’s official site.
- Follow the instructions to complete the installation.
brew install kubectl
sudo apt update
sudo apt install -y apt-transport-https
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee -a /etc/apt/sources.list.d/kubernetes.list
sudo apt update
sudo apt install -y kubectl
Download kubectl
from Kubernetes’ official site and follow the installation instructions.
-
Start Minikube:
minikube start
-
Verify Minikube Status:
minikube status
This command will start a local Kubernetes cluster and give you access to it via kubectl
.
kubernetes-showcase/
├── app/
│ ├── Dockerfile # Dockerfile for building the app
│ ├── app.js # Node.js app code
│ ├── package.json # Node.js dependencies
├── k8s-manifests/
│ ├── deployment.yaml # Kubernetes Deployment for the app
│ ├── service.yaml # Kubernetes Service to expose the app
│ ├── loadbalancer.yaml # LoadBalancer Service (optional for local testing)
│ ├── ingress.yaml # Ingress resource for NGINX routing
│ ├── configmap.yaml # Optional ConfigMap for environment variables
│ └── secret.yaml # Optional Secret for sensitive data
└── README.md
-
Build the Docker Image:
docker build -t kubernetes-showcase-app:1.0 ./app
-
For Minikube Users: Load the image directly into Minikube’s Docker environment:
eval $(minikube docker-env) docker build -t kubernetes-showcase-app:1.0 ./app
-
Optional: If using Docker Hub, tag and push the image:
docker tag kubernetes-showcase-app:1.0 <your-dockerhub-username>/kubernetes-showcase-app:1.0 docker push <your-dockerhub-username>/kubernetes-showcase-app:1.0
-
Deployment and Service:
kubectl apply -f k8s-manifests/deployment.yaml kubectl apply -f k8s-manifests/service.yaml
-
LoadBalancer Service (Optional):
To expose the application via LoadBalancer, apply the load balancer manifest:
kubectl apply -f k8s-manifests/loadbalancer.yaml
-
Ingress (Optional):
To access the application using Ingress, first enable Ingress on Minikube:
minikube addons enable ingress
Then apply the Ingress manifest:
kubectl apply -f k8s-manifests/ingress.yaml
-
If you applied the
loadbalancer.yaml
manifest, you can access the application by port-forwarding:kubectl port-forward svc/kubernetes-showcase-lb 8080:80
-
Now, open your browser and visit
http://localhost:8080
.
-
Ensure that the Ingress addon is enabled for Minikube and that the Ingress manifest is applied.
-
Add an entry to your
/etc/hosts
file to route traffic to the Ingress IP:echo "$(minikube ip) kubernetes-showcase.local" | sudo tee -a /etc/hosts
-
Access the application by visiting
http://kubernetes-showcase.local
in your browser.
Use the following commands to check the status of your deployments and services:
kubectl get pods # Check pod status
kubectl get svc # Check service status
kubectl get deployments # Check deployment status
kubectl get ingress # Check ingress status (if using Ingress)
To delete the resources created by this project, run:
kubectl delete -f k8s-manifests/