This repository provides a complete Kubernetes setup with three separate environments: Testing, Staging, and Production. It includes Ingress rules, RBAC, deployments, autoscaling, TLS certificates, and persistent storage using Minikube and kubectl.
- Three namespaces:
testing
,staging
, andproduction
- RBAC setup: Admin user (full permissions) and Dev user (no permissions initially)
- Ingress controller: NGINX Ingress with routing rules
- Deployments: One node running three pods, each with a single container
- Autoscaling: Horizontal Pod Autoscaler enabled
- TLS security: Certificates configured with cert-manager
- Persistent Storage: Local PersistentVolumes (PVs) and PersistentVolumeClaims (PVCs)
minikube start --memory=4g --cpus=2
Check status:
minikube status
kubectl create namespace testing
kubectl create namespace staging
kubectl create namespace production
kubectl apply -f rbac-admin.yaml
kubectl apply -f rbac-dev.yaml
minikube addons enable ingress
Create an Ingress rule:
kubectl apply -f ingress.yaml
Update /etc/hosts
:
echo "$(minikube ip) myapp.local" | sudo tee -a /etc/hosts
kubectl apply -f deployment.yaml
kubectl autoscale deployment myapp --cpu-percent=50 --min=1 --max=5 -n staging
Check autoscaler:
kubectl get hpa -n staging
kubectl apply -f pv.yaml
kubectl apply -f pvc.yaml -n staging
Install cert-manager:
kubectl apply -f https://github.com/jetstack/cert-manager/releases/latest/download/cert-manager.yaml
Create a self-signed certificate:
kubectl apply -f tls-secret.yaml -n staging
Check pods and deployments:
kubectl get pods -n staging -w
kubectl get deployments -n staging
Check logs:
kubectl logs -f deployment/myapp -n staging
Forward ports:
kubectl port-forward svc/myapp-service 8080:80 -n staging
- Expand configurations for production and testing environments.
- Integrate Helm charts for better management.
- Add CI/CD automation.
This setup provides a solid Kubernetes infrastructure for multi-environment development. 🚀