-
Notifications
You must be signed in to change notification settings - Fork 94
215 lines (181 loc) · 9.22 KB
/
test-v1.yml
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
215
---
name: Test V1
# yamllint disable-line rule:truthy
on:
push:
branches: ["main"]
paths:
- 'charts/k8s-monitoring-v1/**'
pull_request:
paths:
- 'charts/k8s-monitoring-v1/**'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
env:
CT_CONFIGFILE: "${{ github.workspace }}/.github/configs/ct.yaml"
LINT_CONFIGFILE: "${{ github.workspace }}/.configs/lintconf.yaml"
GRAFANA_ALLOY_VALUES: "${{ github.workspace }}/.github/configs/alloy-config.yaml"
GRAFANA_ALLOY_LOKI_OTLP_VALUES: "${{ github.workspace }}/.github/configs/alloy-config-loki-otlp.yaml"
GRAFANA_ALLOY_RECEIVER_SERVICE: "${{ github.workspace }}/.github/configs/receiver-service.yaml"
PROMETHEUS_VALUES: "${{ github.workspace }}/.github/configs/prometheus.yaml"
PROMETHEUS_WORKLOAD_VALUES: "${{ github.workspace }}/.github/configs/prometheus-workload.yaml"
CREDENTIALS: "${{ github.workspace }}/.github/configs/credentials.yaml"
LOKI_VALUES: "${{ github.workspace }}/.github/configs/loki.yaml"
TEMPO_VALUES: "" # No values for now
PYROSCOPE_VALUES: "${{ github.workspace }}/.github/configs/pyroscope.yaml"
GRAFANA_VALUES: "${{ github.workspace }}/.github/configs/grafana.yaml"
PODLOGS_OBJECTS: "${{ github.workspace }}/.github/configs/podlogs.yaml"
MYSQL_VALUES: "${{ github.workspace }}/.github/configs/mysql.yaml"
MYSQL_CONFIG_MANIFEST: "${{ github.workspace }}/.github/configs/mysql-config.yaml"
CERT_MANAGER_VALUES: "${{ github.workspace }}/.github/configs/cert-manager.yaml"
SECRETGEN_CONTROLLER_MANIFEST: https://github.com/carvel-dev/secretgen-controller/releases/latest/download/release.yml
CERTIFICATES_MANIFEST: "${{ github.workspace }}/.github/configs/certificates.yaml"
jobs:
check-for-doc-changes:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Regenerate docs
run: |
docker run --rm \
-v "$(pwd)/charts/k8s-monitoring-v1:/helm-docs" \
-u "$(id -u)" \
jnorwood/helm-docs
if ! git diff --exit-code; then
echo "Helm chart documentation is not up to date. Please run 'helm-docs' and commit changes!" >&2
exit 1
fi
check-for-generated-file-changes:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Helm
uses: azure/setup-helm@v4
- name: Check for generated file changes
working-directory: charts/k8s-monitoring-v1
run: |
make clean build
if [[ -n "$(git status --porcelain)" ]]; then
echo "k8s-monitoring Helm chart v1 generated files are not up to date. Please run 'make clean build', examine changes, and commit changes." >&2
exit 1
fi
static-test-chart:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # Required for `ct lint` to work
- name: Install Helm
uses: azure/setup-helm@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.9'
check-latest: true
- name: Set up chart-testing
uses: helm/chart-testing-action@v2
- name: Install yq
run: pip install yq
- name: Install ShellSpec
run: |
curl -fsSL https://git.io/shellspec | sh -s -- --yes
# Installing Grafana Alloy because we need it to lint the generated alloy config files.
# https://grafana.com/docs/alloy/latest/get-started/install/linux/
- name: Install Grafana Alloy
run: |
sudo mkdir -p /etc/apt/keyrings/
wget -q -O - https://apt.grafana.com/gpg.key | gpg --dearmor | sudo tee /etc/apt/keyrings/grafana.gpg > /dev/null
echo "deb [signed-by=/etc/apt/keyrings/grafana.gpg] https://apt.grafana.com stable main" | sudo tee /etc/apt/sources.list.d/grafana.list
sudo apt-get update
sudo apt-get install -y alloy
- name: Run tests
run: make test
working-directory: charts/k8s-monitoring-v1
test-chart:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Helm
uses: azure/setup-helm@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.9'
check-latest: true
- name: Set up chart-testing
uses: helm/chart-testing-action@v2
- name: List changed charts
id: list-changed
run: |
latestRelease=$(git describe --abbrev=0 --tags)
changed=$(ct list-changed --config "${CT_CONFIGFILE}" --since "${latestRelease}")
if [[ -n "$changed" ]]; then
echo "changed=true" >> "${GITHUB_OUTPUT}"
fi
- name: Create kind cluster
uses: helm/kind-action@v1
if: (steps.list-changed.outputs.changed == 'true') || (contains(github.event.pull_request.labels.*.name, 'full_test_required'))
with:
config: "${{ github.workspace }}/.github/configs/cluster-config.yaml"
- name: Create Certs and Credentials
if: (steps.list-changed.outputs.changed == 'true') || (contains(github.event.pull_request.labels.*.name, 'full_test_required'))
run: |
kubectl apply -f "${SECRETGEN_CONTROLLER_MANIFEST}"
kubectl apply -f "${CERTIFICATES_MANIFEST}"
kubectl apply -f "${CREDENTIALS}"
- name: Set up Helm repositories
if: (steps.list-changed.outputs.changed == 'true') || (contains(github.event.pull_request.labels.*.name, 'full_test_required'))
run: |
helm repo add grafana https://grafana.github.io/helm-charts
helm repo add jetstack https://charts.jetstack.io
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update
- name: Deploy Services for Test Data
if: (steps.list-changed.outputs.changed == 'true') || (contains(github.event.pull_request.labels.*.name, 'full_test_required'))
run: |
# MySQL for integration testing
helm install mysql oci://registry-1.docker.io/bitnamicharts/mysql -f "${MYSQL_VALUES}" -n mysql --create-namespace --wait
kubectl apply -f "${MYSQL_CONFIG_MANIFEST}"
# Cert Manager for integration testing (service annotations)
helm install cert-manager jetstack/cert-manager -f "${CERT_MANAGER_VALUES}" -n cert-manager --create-namespace --wait
# This alloy instance is only used for generating metrics, logs, and traces that'll get
# sent to the K8s Monitoring Alloy to test ingesting MLT from receivers.
kubectl apply -f "${GRAFANA_ALLOY_RECEIVER_SERVICE}"
helm install alloy grafana/alloy -f "${GRAFANA_ALLOY_VALUES}" -n alloy --create-namespace --wait
# This prometheus instance is used pod annotation testing with https
helm install prometheus-workload prometheus-community/prometheus --version ^25 -f "${PROMETHEUS_WORKLOAD_VALUES}" -n prometheus --create-namespace --timeout 10m --wait
# Deploy the Prometheus Operator CRDs, since we want to deploy Loki with a ServiceMonitor later
helm install prom-crds prometheus-community/prometheus-operator-crds --wait
- name: Deploy Prometheus
if: (steps.list-changed.outputs.changed == 'true') || (contains(github.event.pull_request.labels.*.name, 'full_test_required'))
run: |
helm install prometheus prometheus-community/prometheus --version ^25 -f "${PROMETHEUS_VALUES}" -n prometheus --create-namespace --timeout 10m --wait
- name: Deploy Loki
if: (steps.list-changed.outputs.changed == 'true') || (contains(github.event.pull_request.labels.*.name, 'full_test_required'))
run: |
helm install loki grafana/loki -f "${LOKI_VALUES}" -n loki --create-namespace --wait
helm install loki-otlp grafana/alloy -f "${GRAFANA_ALLOY_LOKI_OTLP_VALUES}" -n loki --wait
- name: Deploy Tempo
if: (steps.list-changed.outputs.changed == 'true') || (contains(github.event.pull_request.labels.*.name, 'full_test_required'))
run: |
helm install tempo grafana/tempo -n tempo --create-namespace --wait
- name: Deploy Pyroscope
if: (steps.list-changed.outputs.changed == 'true') || (contains(github.event.pull_request.labels.*.name, 'full_test_required'))
run: |
helm install pyroscope grafana/pyroscope -f "${PYROSCOPE_VALUES}" -n pyroscope --create-namespace --wait
- name: Deploy Grafana
if: (steps.list-changed.outputs.changed == 'true') || (contains(github.event.pull_request.labels.*.name, 'full_test_required'))
run: |
helm install grafana grafana/grafana -f "${GRAFANA_VALUES}" -n grafana --create-namespace --wait
kubectl apply -f "${PODLOGS_OBJECTS}"
- name: Test chart
if: (steps.list-changed.outputs.changed == 'true') || (contains(github.event.pull_request.labels.*.name, 'full_test_required'))
run: |
latestRelease=$(git describe --abbrev=0 --tags)
ct install --config "${CT_CONFIGFILE}" --since "${latestRelease}" --helm-extra-args "--timeout 10m" --charts charts/k8s-monitoring-v1