forked from VictoriaMetrics/helm-charts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
164 lines (145 loc) · 6.13 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
URL=https://victoriametrics.github.io/helm-charts/
HELM_IMAGE = alpine/helm:3.12.3
HELM_DOCS_IMAGE = jnorwood/helm-docs:v1.11.0
PYTHON_IMAGE = python:3.11.5-alpine3.18
CT_IMAGE = quay.io/helmpack/chart-testing:v3.7.1
KNOWN_TARGETS=helm
HELM?=helm-docker
CT?=ct-docker
CONTAINER ?= docker
ifeq ($(CONTAINER),docker)
CONTAINER_USER_OPTION = --user $(shell id -u):$(shell id -g)
CONTAINER_VOLUME_OPTION_SUFFIX =
else
ifeq ($(CONTAINER),podman)
CONTAINER_USER_OPTION =
CONTAINER_VOLUME_OPTION_SUFFIX = :z
else
$(error CONTAINER values currently supported are: docker, podman)
endif
endif
helm-docker:
mkdir -p .helm/cache
$(CONTAINER) run --rm --name helm-exec \
$(CONTAINER_USER_OPTION) \
--volume "$(shell pwd):/helm-charts$(CONTAINER_VOLUME_OPTION_SUFFIX)" \
--volume "$(shell pwd)/.github/ci/helm-repos.yaml:/helm-charts/.helm/config/repositories.yaml$(CONTAINER_VOLUME_OPTION_SUFFIX)" \
-w /helm-charts \
-e HELM_CACHE_HOME=/helm-charts/.helm/cache \
-e HELM_CONFIG_HOME=/helm-charts/.helm/config \
-e HELM_DATA_HOME=/helm-charts/.helm/data \
$(HELM_IMAGE) \
$(CMD)
helm-local:
helm \
$(CMD)
ct-docker:
mkdir -p .helm/cache
$(CONTAINER) run --rm --name helm-exec \
$(CONTAINER_USER_OPTION) \
--volume "$(shell pwd):/helm-charts$(CONTAINER_VOLUME_OPTION_SUFFIX)" \
--volume "$(shell pwd)/.github/ci/helm-repos.yaml:/helm-charts/.helm/config/repositories.yaml$(CONTAINER_VOLUME_OPTION_SUFFIX)" \
-w /helm-charts \
-e HELM_CACHE_HOME=/helm-charts/.helm/cache \
-e HELM_CONFIG_HOME=/helm-charts/.helm/config \
-e HELM_DATA_HOME=/helm-charts/.helm/data \
--entrypoint 'ct' \
$(CT_IMAGE) \
$(CMD)
ct-local:
ct \
$(CMD)
helm-repo-update:
CMD="repo update" $(MAKE) $(HELM)
# Run linter for helm chart
lint: helm-repo-update
CMD="lint charts/victoria-metrics-cluster -f hack/vmcluster-template-hack.yaml" $(MAKE) $(HELM)
CMD="lint charts/victoria-metrics-single -f hack/vmsingle-lint-hack.yaml" $(MAKE) $(HELM)
CMD="lint charts/victoria-metrics-agent -f hack/vmagent-lint-hack.yaml" $(MAKE) $(HELM)
CMD="lint charts/victoria-metrics-alert -f hack/vmalert-lint-hack.yaml" $(MAKE) $(HELM)
CMD="lint charts/victoria-metrics-gateway -f hack/vmgateway-cluster-ratelimiting-minimum.yaml" $(MAKE) $(HELM)
CMD="lint charts/victoria-metrics-auth -f hack/vmauth-lint-hack.yaml" $(MAKE) $(HELM)
CMD="lint charts/victoria-metrics-anomaly -f hack/vmanomaly-lint-hack.yaml" $(MAKE) $(HELM)
CMD="dependency build charts/victoria-logs-single" $(MAKE) $(HELM)
CMD="lint charts/victoria-logs-single -f hack/vlsingle-lint-hack.yaml" $(MAKE) $(HELM)
# Run template for helm charts
template: helm-repo-update
CMD="template charts/victoria-metrics-cluster -f hack/vmcluster-template-hack.yaml" $(MAKE) $(HELM)
CMD="template charts/victoria-metrics-single -f hack/vmsingle-lint-hack.yaml" $(MAKE) $(HELM)
CMD="template charts/victoria-metrics-agent -f hack/vmagent-lint-hack.yaml" $(MAKE) $(HELM)
CMD="template charts/victoria-metrics-alert -f hack/vmalert-lint-hack.yaml" $(MAKE) $(HELM)
CMD="template charts/victoria-metrics-gateway -f hack/vmgateway-cluster-ratelimiting-minimum.yaml" $(MAKE) $(HELM)
CMD="template charts/victoria-metrics-auth -f hack/vmauth-lint-hack.yaml" $(MAKE) $(HELM)
CMD="template charts/victoria-metrics-anomaly -f hack/vmanomaly-lint-hack.yaml" $(MAKE) $(HELM)
CMD="dependency build charts/victoria-logs-single" $(MAKE) $(HELM)
CMD="template charts/victoria-logs-single -f hack/vlsingle-lint-hack.yaml" $(MAKE) $(HELM)
lint-ct:
CMD="lint --config .github/ci/ct.yaml --all" $(MAKE) $(CT)
lint-ct-local:
CT="ct-local" $(MAKE) lint-ct
lint-local:
HELM="helm-local" $(MAKE) lint
template-local:
HELM="helm-local" $(MAKE) template
# DEPRECATED: use release action instead
#package-chart:
# if [ "$(CHART)" = "victoria-metrics-k8s-stack" ]; then \
# CMD="dependency update charts/victoria-metrics-k8s-stack" $(MAKE) $(HELM); \
# fi; \
# if [ "$(CHART)" = "victoria-logs-single" ]; then \
# CMD="dependency update charts/victoria-logs-single" $(MAKE) $(HELM); \
# fi; \
# CMD="package charts/$(CHART) -d packages" $(MAKE) $(HELM); \
#
# DEPRECATED: use release action instead
#package-new-chart-version:
# @VERSION=$$(grep -m 1 -o 'version: .*' charts/"$$CHART"/Chart.yaml | cut -d ' ' -f 2); \
# FILENAME="packages/$$CHART-$$VERSION.tgz"; \
# if ! test -f "$$FILENAME"; then \
# $(MAKE) package-chart CHART=$$CHART; \
# else \
# echo "No need to package $$FILENAME already exists"; \
# fi
#
# DEPRECATED: use release action instead
# Package chart into zip file
#package:
# @for CHART in $$(ls charts/); do \
# $(MAKE) package-new-chart-version CHART=$$CHART; \
# done
# Create index file (use only for initial setup)
#index:
# CMD="repo index --url ${URL} ." $(MAKE) $(HELM)
init:
CMD="repo add prometheus-community https://prometheus-community.github.io/helm-charts" $(MAKE) $(HELM)
CMD="repo add grafana https://grafana.github.io/helm-charts" $(MAKE) $(HELM)
CMD="repo update" $(MAKE) $(HELM)
# DEPRECATED: use release action instead
# Update index file add new version of package into it
#merge:
# CMD="repo index --url ${URL} --merge index.yaml ." $(MAKE) $(HELM)
gen-docs:
$(CONTAINER) run --rm \
$(CONTAINER_USER_OPTION) \
--volume "$(shell pwd):/helm-charts$(CONTAINER_VOLUME_OPTION_SUFFIX)" \
-w /helm-charts \
$(HELM_DOCS_IMAGE) \
helm-docs
# Synchronize alerting rules in charts/victoria-metrics-k8s-stack/templates/rules
sync-rules:
$(CONTAINER) run --rm \
$(CONTAINER_USER_OPTION) \
--volume "$(shell pwd)/charts/victoria-metrics-k8s-stack:/k8s-stack$(CONTAINER_VOLUME_OPTION_SUFFIX)" \
-w /k8s-stack/hack/ \
$(PYTHON_IMAGE) sh -c "\
pip3 install --no-cache-dir --no-build-isolation -r requirements.txt --user && python3 sync_rules.py \
"
# Synchronize grafana dashboards in charts/victoria-metrics-k8s-stack/templates/grafana/dashboards
sync-dashboards:
$(CONTAINER) run --rm \
$(CONTAINER_USER_OPTION) \
--volume "$(shell pwd)/charts/victoria-metrics-k8s-stack:/k8s-stack$(CONTAINER_VOLUME_OPTION_SUFFIX)" \
-w /k8s-stack/hack/ \
$(PYTHON_IMAGE) sh -c "\
pip3 install --no-cache-dir --no-build-isolation -r requirements.txt --user && python3 sync_grafana_dashboards.py \
"