-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmakefile
More file actions
91 lines (70 loc) · 2.4 KB
/
Copy pathmakefile
File metadata and controls
91 lines (70 loc) · 2.4 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
export ENV
export CHART
export NAMESPACE
setup: # First time setup
pip install -r requirements.txt
yarn
# Renders values.yaml files for the specified environment
render_values: _check_env
@echo "Rendering values for $(ENV)"
ENV=$(ENV) python ./templates/environment.py \
--params "./environments/${ENV}/values.yaml" \
--destination "./environments/${ENV}/rendered" \
--templates "./templates"
@echo "Values rendered for $(ENV)"
$(MAKE) _format_values
# Uses helm-template to render the chart for the specified environment
debug_chart: _check_env
if [ -z "$(CHART)" ]; then \
echo "ERROR: CHART is not set"; \
exit 1; \
fi
if [ -z "$(NAMESPACE)" ]; then \
echo "ERROR: NAMESPACE is not set"; \
exit 1; \
fi
@echo "Debugging chart $(CHART) for $(ENV)"
helm template ./charts/$(CHART) \
--name-template $(CHART) \
--namespace $(NAMESPACE) \
--kube-version 1.31 \
--values ./charts/$(CHART)/values.yaml \
--values ./environments/$(ENV)/rendered/global.yaml \
--values ./environments/$(ENV)/rendered/$(CHART).yaml \
--include-crds \
--debug
# Creates the environment in the cluster
init: _check_env _add_helm_repos
@echo "Creating environment $(ENV)"
$(MAKE) render_values ENV=$(ENV)
helm install argocd argo/argo-cd -n argocd --create-namespace
# wait for argocd to be ready
kubectl wait --for=condition=Ready pod -l app.kubernetes.io/name=argocd-server -n argocd --timeout=300s
kubectl apply -f "./environments/${ENV}/applications.yaml"
# Calls the python ./templates/set_values.py script to set values
set_values:
@echo "Setting values for $(ENV)"
@echo "Before setting values:"
cat "./environments/${ENV}/values.yaml"
python ./templates/set_values.py --file="./environments/${ENV}/values.yaml" --set $(VALUES)
$(MAKE) render_values ENV=$(ENV)
@echo "After setting values:"
cat "./environments/${ENV}/values.yaml"
# Formats the values.yaml files
_format_values:
@echo "Formatting values.yaml files"
yarn prettier:fix
# Checks if the ENV variable is set
_check_env:
@if [ -z "$(ENV)" ]; then \
echo "ERROR: ENV is not set"; \
exit 1; \
fi
@echo "ENV is set to $(ENV)"
# Adds the necessary helm repos
_add_helm_repos:
helm repo add argo https://argoproj.github.io/argo-helm
helm repo add external-secrets https://charts.external-secrets.io
helm repo add external-dns https://charts.bitnami.com/bitnami
helm repo add jetstack https://charts.jetstack.io
helm repo update