|
| 1 | +PORT ?= 8080 |
| 2 | + |
| 3 | +.PHONY: help deploy cleanup logs update port-forward test |
| 4 | + |
| 5 | +help: ## Show this help |
| 6 | + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}' |
| 7 | + @echo "\nVariables:" |
| 8 | + @echo " PORT=8080 Port for port-forwarding (default: 8080)" |
| 9 | + |
| 10 | +deploy: ## Deploy nginx and nginx-hello server to Kubernetes |
| 11 | + kubectl create configmap nginx-config --from-file=nginx.conf --dry-run=client -o yaml | kubectl apply -f - |
| 12 | + kubectl apply -f nginx.yaml |
| 13 | + @echo "Waiting for pods to be ready..." |
| 14 | + kubectl wait --for=condition=ready pod -l app=nginx-proxy --timeout=60s |
| 15 | + kubectl wait --for=condition=ready pod -l app=nginx-hello --timeout=60s |
| 16 | + |
| 17 | +cleanup: ## Delete everything from Kubernetes |
| 18 | + kubectl delete configmap nginx-config --ignore-not-found=true |
| 19 | + kubectl delete -f nginx.yaml --ignore-not-found=true |
| 20 | + |
| 21 | +logs: ## Show nginx logs |
| 22 | + kubectl logs -l app=nginx-proxy -f |
| 23 | + |
| 24 | +update: ## Update nginx config and restart pods |
| 25 | + kubectl create configmap nginx-config --from-file=nginx.conf --dry-run=client -o yaml | kubectl apply -f - |
| 26 | + kubectl rollout restart deployment/nginx-proxy |
| 27 | + |
| 28 | +port-forward: ## Port forward nginx pod to localhost:PORT (default: 8080) |
| 29 | + kubectl port-forward deployment/nginx-proxy $(PORT):80 |
| 30 | + |
| 31 | +test: ## Test the setup via port-forward (run 'make port-forward' first) |
| 32 | + @echo "Testing nginx health..." |
| 33 | + @curl -s http://localhost:$(PORT)/health |
| 34 | + @echo "\nTesting nginx-hello backend..." |
| 35 | + @curl -s http://localhost:$(PORT)/ | head -5 |
0 commit comments