-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
214 lines (183 loc) · 7.49 KB
/
Makefile
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
# Global Vars
#############
WORKING_DIR = $(shell pwd)
OS = $(shell uname -s)
ARCH = $(shell uname -m)
NAMESPACE = conduktor
TEST_NAMESPACE = ct
K3D_CONTEXT_NAME = k3d-conduktor-platform
# Helm dependencies specific default variables
##############################################
postgresql_password := conduktor
postgresql_default_database := conduktor
minio_password := conduktor
minio_default_bucket := conduktor
# Main targets you should run
#############################
.DEFAULT_GOAL := help
.PHONY: help
help: ## Prints help for targets with comments
@cat $(MAKEFILE_LIST) | grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: install-githooks
install-githooks: ## Install git hooks
git config --local core.hooksPath .githooks
.PHONY: install-readme-generator
install-readme-generator: ## Install bitnami/readme-generator-for-helm using NMP
@echo "Check that NPM is installed"
command -v npm || echo -e "Missing NPM"; exit 1;
@echo "Install readme-generator"
npm install -g @bitnami/[email protected]
.PHONY: generate-readme
generate-readme: ## Re-generate charts README
@echo "Check that readme-generator is installed"
command -v readme-generator || $(MAKE) install-readme-generator
@echo
@echo "Updating README.md for console chart"
readme-generator --values "./charts/console/values.yaml" --readme "./charts/console/README.md"
@echo
@echo "Updating README.md for gateway chart"
readme-generator --values "./charts/gateway/values.yaml" --readme "./charts/gateway/README.md"
.PHONY: helm-deps
helm-deps: ## Install helm dependencies
@echo "Installing helm dependencies"
helm repo add conduktor https://helm.conduktor.io/ || true
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx || true
helm repo add bitnami https://charts.bitnami.com/bitnami || true
helm repo update
.PHONY: k3d-up
k3d-up: ## Setup k3d cluster
@echo "Creating k3d cluster"
make create-k3d-cluster
@echo "Installing nginx-ingress"
make helm-nginx
@echo "Create Test namespace"
make create-test-ns
.PHONY: k3d-ci-up
k3d-ci-up: ## Setup CI k3d cluster
@echo "Creating k3d cluster"
make create-k3d-cluster
@echo "Installing nginx-ingress"
make helm-nginx
@echo "Create Test namespace"
make create-test-ns
.PHONY: k3d-down
k3d-down: ## Teardown k3d cluster
make delete-k3d-cluster
.PHONY: k3d-ci-down
install-dev-deps: ## Install development dependencies (PostgreSQL, Minio, monitoring stack) not needed for CT tests
kubectl create namespace ${NAMESPACE} || true
@echo "Installing postgresql"
make helm-postgresql
@echo "Installing Minio"
make helm-minio
@echo "Installing Monitoring stack"
make helm-monitoring-stack
# Extended targets
##################
.PHONY: create-k3d-cluster
create-k3d-cluster: ## Create k3d cluster
@echo "Create the test cluster"
k3d cluster create --config $(CURDIR)/k3d/config.yaml
@echo "Current context : $$(kubectl config current-context)"
.PHONY: check-kube-context
check-kube-context: ## Validate that current kube context used is K3D to prevent installing chart on another cluster
@if [ "$$(kubectl config current-context)" != "$(K3D_CONTEXT_NAME)" ]; then \
echo -e "Current context is not K3D cluster ! ($$(kubectl config current-context))"; \
exit 1; \
fi
.PHONY: delete-k3d-cluster
delete-k3d-cluster: ## Delete k3d cluster
make check-kube-context
@echo "Deleting k3d cluster"
k3d cluster delete --config $(CURDIR)/k3d/config.yaml || true
.PHONY: helm-nginx
helm-nginx: ## Install nginx-ingress helm chart from ingress-nginx
make check-kube-context
@echo "Installing nginx-ingress"
helm upgrade --install ingress-nginx ingress-nginx/ingress-nginx \
--namespace ingress-nginx --create-namespace
@echo "Waiting for ingress-nginx to be ready..."
kubectl wait deployment -n ingress-nginx \
ingress-nginx-controller --for condition=Available=True --timeout=90s
.PHONY: helm-postgresql
helm-postgresql: ## Install postgresql helm chart from bitnami
make check-kube-context
kubectl create namespace ${NAMESPACE} || true
@echo "Installing postgresql"
helm upgrade --install postgresql bitnami/postgresql \
--namespace ${NAMESPACE} --create-namespace \
--version 12.5.8 \
--set global.postgresql.auth.database=${postgresql_default_database} \
--set global.postgresql.auth.postgresPassword=${postgresql_password} \
--set auth.postgresPassword=${postgresql_password} \
--set primary.service.type=LoadBalancer
@echo "Waiting for postgresql to be ready..."
kubectl rollout status --watch --timeout=300s statefulset/postgresql -n ${NAMESPACE}
.PHONY: helm-minio
helm-minio: ## Install minio helm chart from bitnami
make check-kube-context
kubectl create namespace ${NAMESPACE} || true
@echo "Installing Minio"
helm upgrade --install minio bitnami/minio \
--namespace ${NAMESPACE} --create-namespace \
--version 12.8.0 \
--set auth.rootPassword=${minio_password} \
--set defaultBuckets=${minio_default_bucket} \
--set disableWebUI=false
@echo "Waiting for minio to be ready..."
kubectl rollout status --watch --timeout=300s deployment/minio -n ${NAMESPACE}
.PHONY: helm-monitoring-stack
.ONESHELL:
helm-monitoring-stack: ## Install monitoring stack prometheus and grafana
make check-kube-context
@echo "Add prometheus helm repo"
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts || true
helm repo update
@echo "Install prometheus stack"
helm upgrade --install prometheus-stack prometheus-community/kube-prometheus-stack \
--namespace prometheus-stack --create-namespace \
--set prometheus.prometheusSpec.podMonitorSelectorNilUsesHelmValues=false \
--set prometheus.prometheusSpec.serviceMonitorSelectorNilUsesHelmValues=false \
--set alertmanager.enabled=false \
--set grafana.enabled=false
@echo "Install grafana operator"
helm upgrade --install grafana-operator bitnami/grafana-operator \
--namespace prometheus-stack --create-namespace \
--set namespaceScope=false \
--set watchNamespaces="" \
--set grafana.enabled=false
@echo "Install grafana"
kubectl apply -f k3d/monitoring-stack-grafana-crd.yaml
.PHONY: helm-monitoring-stack-grafana-alpha
.ONESHELL:
helm-monitoring-stack-grafana-alpha: ## Install monitoring stack prometheus and grafana with alpha api version
make check-kube-context
@echo "Add prometheus helm repo"
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts || true
helm repo update
@echo "Install prometheus stack"
helm upgrade --install prometheus-stack prometheus-community/kube-prometheus-stack \
--namespace prometheus-stack --create-namespace \
--set prometheus.prometheusSpec.podMonitorSelectorNilUsesHelmValues=false \
--set prometheus.prometheusSpec.serviceMonitorSelectorNilUsesHelmValues=false \
--set alertmanager.enabled=false \
--set grafana.enabled=false
@echo "Install grafana operator"
helm upgrade --install grafana-operator bitnami/grafana-operator \
--namespace prometheus-stack --create-namespace \
--set namespaceScope=false \
--set watchNamespaces="" \
--set grafana.enabled=false \
--version 2.9.3
@echo "Install grafana"
kubectl apply -f k3d/monitoring-stack-grafana-crd-alpha.yaml
kubectl apply -f k3d/monitoring-stack-grafana-ds-alpha.yaml
.PHONY: create-test-ns
create-test-ns: ## Create test namespace
make check-kube-context
kubectl create namespace ${TEST_NAMESPACE} || true
.PHONY: test-chart
test-chart: ## Run chart-testing
make check-kube-context
make create-test-ns
ct install --config $(CURDIR)/.github/ct-config.yaml