🔧 enhance Makefile and Readme with Docker Swarm and Kubernetes support, adding new targets for deployment and management
This commit is contained in:
52
Makefile
52
Makefile
@@ -1,5 +1,15 @@
|
||||
.PHONY: dev up down build test lint install-deps logs logs-api logs-worker logs-all \
|
||||
init-db shell-postgres shell-api shell-worker status clean help
|
||||
init-db shell-postgres shell-api shell-worker status clean help \
|
||||
k8s-apply-local k8s-apply-a k8s-down-local k8s-down-a \
|
||||
swarm-build swarm-deploy swarm-down
|
||||
|
||||
# Docker Swarm
|
||||
SWARM_STACK ?= handheld
|
||||
|
||||
# Kubernetes
|
||||
K8S_CHART := k8s/handheld-devices
|
||||
K8S_NAMESPACE ?= handheld-devices
|
||||
K8S_CONTEXT_A ?= # set to your A env context, e.g. gke_project_region_cluster
|
||||
|
||||
# Default target
|
||||
help:
|
||||
@@ -23,6 +33,15 @@ help:
|
||||
@echo ""
|
||||
@echo " status Show container status"
|
||||
@echo " clean Stop and remove volumes"
|
||||
@echo ""
|
||||
@echo " k8s-apply-local Helm upgrade/install to local cluster (minikube, kind)"
|
||||
@echo " k8s-apply-a Helm upgrade/install to A env (set K8S_CONTEXT_A)"
|
||||
@echo " k8s-down-local Helm uninstall from local cluster"
|
||||
@echo " k8s-down-a Helm uninstall from A env (set K8S_CONTEXT_A)"
|
||||
@echo ""
|
||||
@echo " swarm-build Build and tag images for Swarm (no build in stack)"
|
||||
@echo " swarm-deploy Deploy stack to Swarm (requires: docker swarm init)"
|
||||
@echo " swarm-down Remove stack from Swarm"
|
||||
|
||||
install-deps:
|
||||
luarocks install lua-cjson && luarocks install luasocket && luarocks install pgmoon && \
|
||||
@@ -73,3 +92,34 @@ status:
|
||||
|
||||
clean: down
|
||||
docker-compose down -v
|
||||
|
||||
k8s-apply-local:
|
||||
helm upgrade --install handheld-devices $(K8S_CHART) \
|
||||
-f $(K8S_CHART)/values.yaml \
|
||||
-f $(K8S_CHART)/values-local.yaml \
|
||||
-n $(K8S_NAMESPACE) --create-namespace
|
||||
|
||||
k8s-apply-a:
|
||||
helm upgrade --install handheld-devices $(K8S_CHART) \
|
||||
-f $(K8S_CHART)/values.yaml \
|
||||
-f $(K8S_CHART)/values-a.yaml \
|
||||
-n $(K8S_NAMESPACE) --create-namespace \
|
||||
$(if $(K8S_CONTEXT_A),--kube-context $(K8S_CONTEXT_A))
|
||||
|
||||
k8s-down-local:
|
||||
helm uninstall handheld-devices -n $(K8S_NAMESPACE) --ignore-not-found
|
||||
|
||||
k8s-down-a:
|
||||
helm uninstall handheld-devices -n $(K8S_NAMESPACE) --ignore-not-found \
|
||||
$(if $(K8S_CONTEXT_A),--kube-context $(K8S_CONTEXT_A))
|
||||
|
||||
swarm-build:
|
||||
docker build -t handheld-devices-api:latest ./devices-api
|
||||
docker build -t handheld-devices-worker:latest ./devices-worker
|
||||
docker build -t handheld-devices-frontend:latest ./frontend
|
||||
|
||||
swarm-deploy: swarm-build
|
||||
docker stack deploy -c compose.swarm.yml $(SWARM_STACK)
|
||||
|
||||
swarm-down:
|
||||
docker stack rm $(SWARM_STACK)
|
||||
|
||||
Reference in New Issue
Block a user