-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
104 lines (91 loc) · 5.79 KB
/
Makefile
File metadata and controls
104 lines (91 loc) · 5.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
.PHONY: deploy-cluster-dev deploy-cluster-prod deploy-apps-dev-platform deploy-apps-dev-ppp deploy-apps-prod-platform deploy-apps-prod-ppp port-forward-prometheus
help:
@echo "Available make targets:"
@echo " deploy-cluster-dev - TF — Deploy a development GKE cluster"
@echo " destroy-cluster-dev - TF — Destroy the development GKE cluster"
@echo " deploy-cluster-prod - TF — Deploy a production GKE cluster"
@echo " deploy-apps-dev-platform - HELM — Deploy services with platform flavor on the dev cluster"
@echo " deploy-apps-dev-ppp - HELM — Deploy services with PPP flavor on the dev cluster"
@echo " deploy-apps-prod-platform - HELM — Deploy services with platform flavor on the production cluster"
@echo " deploy-apps-prod-ppp - HELM — Deploy services with PPP flavor on the production cluster"
@echo " deploy-observability-dev-platform - HELM — Deploy observability stack to the development cluster using Helm"
@echo " deploy-observability-prod-platform - HELM — Deploy observability stack to the production cluster using Helm"
@echo " port-forward-prometheus - Port-forward to Prometheus in the currently active cluster"
@echo " port-forward-grafana - Port-forward to Grafana in the currently active cluster and display the admin password"
deploy-cluster-dev:
@terraform -chdir=./terraform init -backend-config="prefix=terraform/devcluster" && \
terraform -chdir=./terraform apply -var-file="../profiles/devcluster.tfvars"
destroy-cluster-dev:
@terraform -chdir=./terraform init -backend-config="prefix=terraform/devcluster" && \
terraform -chdir=./terraform destroy -var-file="../profiles/devcluster.tfvars"
deploy-cluster-prod:
@terraform -chdir=./terraform init -backend-config="prefix=terraform/production" && \
terraform -chdir=./terraform apply -var-file="../profiles/production.tfvars"
deploy-apps-dev-platform:
@helm diff upgrade --allow-unreleased devcluster-platform ./helm/platform -f ./profiles/devcluster-platform.yaml; \
read -p "press enter to continue..." nothing; \
helm upgrade --install devcluster-platform ./helm/platform -f ./profiles/devcluster-platform.yaml
deploy-apps-dev-ppp:
@helm diff upgrade --allow-unreleased devcluster-ppp ./helm/platform -f ./profiles/devcluster-ppp.yaml; \
read -p "press enter to continue..." nothing; \
helm upgrade --install devcluster-ppp ./helm/platform -f ./profiles/devcluster-ppp.yaml
deploy-apps-prod-platform:
@helm lint ./helm/platform && \
helm diff upgrade --allow-unreleased production-platform ./helm/platform -f ./profiles/production-platform.yaml; \
read -p "confirm production platform apps deploy: " confirm; \
if [ "$$confirm" = "confirm" ]; then \
helm upgrade --install production-platform ./helm/platform -f ./profiles/production-platform.yaml; \
else \
echo "deploy cancelled"; \
fi
deploy-apps-prod-ppp:
@helm lint ./helm/platform && \
helm diff upgrade --allow-unreleased production-ppp ./helm/platform -f ./profiles/production-ppp.yaml; \
read -p "confirm production ppp apps deploy: " confirm; \
if [ "$$confirm" = "confirm" ]; then \
helm upgrade --install production-ppp ./helm/platform -f ./profiles/production-ppp.yaml; \
else \
echo "deploy cancelled"; \
fi
define OBSERVABILITY_HELM_REPO_CHECK
@echo "Checking for prometheus-community helm repo..."; \
PROMETHEUS_REPO=$$(helm repo list | grep prometheus-community.github.io/helm-charts | awk '{print $$1}'); \
if [ -z "$$PROMETHEUS_REPO" ]; then \
echo "Adding the prometheus-community helm repo."; \
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts; \
helm repo update; \
fi;
GRAFANA_REPO=$$(helm repo list | grep grafana.com | awk '{print $$1}'); \
if [ -z "$$GRAFANA_REPO" ]; then \
echo "Adding the grafana helm repo."; \
helm repo add grafana https://grafana.github.io/helm-charts; \
helm repo update; \
fi;
if [ ! -d "helm/observability/charts" ]; then \
helm dependency build ./helm/observability; \
fi
endef
deploy-observability-dev-platform:
$(call OBSERVABILITY_HELM_REPO_CHECK)
@helm diff upgrade observability ./helm/observability --allow-unreleased --namespace observability -f ./profiles/observability-devcluster-platform.yaml; \
read -p "press enter to continue..." nothing; \
helm upgrade observability ./helm/observability --namespace observability --install --create-namespace -f ./profiles/observability-devcluster-platform.yaml
deploy-observability-prod-platform:
$(call OBSERVABILITY_HELM_REPO_CHECK)
@helm diff upgrade observability ./helm/observability --allow-unreleased --namespace observability -f ./profiles/observability-production-platform.yaml; \
read -p "confirm production observability deploy: " confirm; \
if [ "$$confirm" = "confirm" ]; then \
helm upgrade observability ./helm/observability --namespace observability --install -f ./profiles/observability-production-platform.yaml; \
else \
echo "deploy cancelled"; \
fi
port-forward-prometheus:
@PROMETHEUS_POD=$$(kubectl get pods --namespace observability -l "app.kubernetes.io/name=prometheus,app.kubernetes.io/instance=observability" -o jsonpath="{.items[0].metadata.name}"); \
echo "Port-forwarding to Prometheus pod: $$PROMETHEUS_POD"; \
kubectl port-forward --namespace observability $$PROMETHEUS_POD 9090:9090
port-forward-grafana:
echo "Grafana admin password:"
@kubectl get secret --namespace observability observability-grafana -o jsonpath="{.data.admin-password}" | base64 --decode ; echo
@GRAFANA_POD=$$(kubectl get pods --namespace observability -l "app.kubernetes.io/name=grafana,app.kubernetes.io/instance=observability" -o jsonpath="{.items[0].metadata.name}"); \
echo "Port-forwarding to Grafana pod: $$GRAFANA_POD"; \
kubectl port-forward --namespace observability $$GRAFANA_POD 3000:3000