-
Notifications
You must be signed in to change notification settings - Fork 419
255 lines (235 loc) · 10.3 KB
/
chart.yaml
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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
name: Chart build
on:
workflow_dispatch: {}
# Normally using pull_request_target along with checking out the ref of the PR is not
# a good idea, but this is low risk since it's a Helm chart repo.
pull_request_target:
types: [opened, synchronize, reopened, ready_for_review]
# pull_request:
# branches:
# - develop
jobs:
test-chart:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Set up chart-testing
uses: helm/chart-testing-action@e6669bcd63d7cb57cb4380c33043eebe5d111992 # v2.6.1
# Lint all chart values including those in the ci directory.
- name: Run chart-testing (lint)
run: ct lint --chart-dirs=cost-analyzer/ --charts cost-analyzer/ --validate-maintainers=false
# Run `helm template` on the main values file plus all those in the ci directory.
- name: Helm template
run: |
helm template cost-analyzer/ -f cost-analyzer/values.yaml > full.yaml
directory="cost-analyzer/ci"
for file in "$directory"/*; do
if [ -f "$file" ]; then
helm template cost-analyzer/ -f "$file" >> full.yaml
fi
done
# Run Kubeconform on the combined, templatized output across all tested values stored in `full.yaml`.
# Ensure all the rendered resources are valid.
- name: Kubeconform
uses: docker://ghcr.io/yannh/kubeconform:latest
with:
entrypoint: /kubeconform
args: "-summary -ignore-missing-schemas -output text full.yaml"
# Test cluster versions.
deploy-chart:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
k8s-version:
- name: v1.22
version: v1.22.17
- name: v1.23
version: v1.23.17
- name: v1.24
version: v1.24.17
- name: v1.25
version: v1.25.16
- name: v1.26
version: v1.26.15
- name: v1.27
version: v1.27.16
- name: v1.28
version: v1.28.13
- name: v1.29
version: v1.29.8
- name: v1.30
version: v1.30.4
- name: v1.31
version: v1.31.0
needs: test-chart
name: ${{ matrix.k8s-version.name }} test
steps:
- name: Checkout
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Set up chart-testing
uses: helm/chart-testing-action@e6669bcd63d7cb57cb4380c33043eebe5d111992 # v2.6.1
- name: Create KinD cluster
uses: helm/kind-action@0025e74a8c7512023d06dc019c617aa3cf561fde # v1.10.0
with:
version: v0.20.0
node_image: kindest/node:${{ matrix.k8s-version.version }}
kubectl_version: ${{ matrix.k8s-version.version }}
# Create necessary test files in the cluster. Some configurations of the chart
# require pre-existing files like Secrets in order for volume mounts to be valid. Without them,
# Pods won't come up and tests will fail.
- name: Create kubecost Namespace and test files
run: |
kubectl create ns kubecost
kubectl -n kubecost create -f .github/ci-files
# Install the chart with default values and check results.
- name: Install Kubecost chart
working-directory: ./cost-analyzer
run: helm install --wait --wait-for-jobs kubecost . -n kubecost
# run: ct install --namespace kubecost --chart-dirs=cost-analyzer/ --charts cost-analyzer/
- name: Wait for ready
run: kubectl wait -n kubecost --for=condition=ready pod --selector app.kubernetes.io/name=cost-analyzer --timeout=120s
- name: Run Helm tests
run: helm test -n kubecost kubecost
- name: Uninstall chart
run: helm uninstall kubecost -n kubecost --no-hooks --wait
- name: Cleanup all Pods in Kubecost Namespace
run: kubectl -n kubecost delete deployments,daemonsets,statefulsets,pods --all --force
# Loops over all the other values files in the ci directory and installs the chart, runs Helm tests, and uninstalls.
# Additional sleeps seem necessary for the main Kubecost Pod to be completely available, both frontend and backend.
- name: Install, test, remove chart for other values
id: loopingtests
run: |
directory="cost-analyzer/ci"
for file in "$directory"/*; do
if [ -f "$file" ]; then
echo "### Sleeping for 30 seconds ###"
sleep 30
echo "### Performing installation with values from $file ###"
helm install --wait --wait-for-jobs kubecost cost-analyzer/ -n kubecost -f "$file"
echo "### Waiting for cost-analyzer Pod readiness. ###"
kubectl wait -n kubecost --for=condition=ready pod --selector app.kubernetes.io/name=cost-analyzer --timeout=120s
echo "### Sleeping for 60 seconds longer. ###"
sleep 60
echo "### [DEBUG] Listing Pods in Kubecost Namespace. ###"
kubectl -n kubecost get pods
echo "### Performing helm tests ###"
helm test -n kubecost $(helm ls -n kubecost --all --short)
echo "### Performing uninstallation ###"
helm uninstall $(helm ls -n kubecost --all --short) -n kubecost --no-hooks --wait
echo "### Cleaning up all Pods and Pod controllers in Kubecost Namespace ###"
kubectl -n kubecost delete deployments,daemonsets,statefulsets,pods --all --force
fi
done
deploy-ocp:
runs-on: ubuntu-latest
needs: test-chart
strategy:
matrix:
cluster:
- distribution: openshift
version: 4.13.0-okd
- distribution: openshift
version: 4.14.0-okd
- distribution: openshift
version: 4.15.0-okd
steps:
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
with:
ref: ${{ github.event.pull_request.head.sha }}
# Outputs: `cluster-kubeconfig`, `cluster-id`
- name: Create Cluster
id: create-cluster
uses: replicatedhq/compatibility-actions/create-cluster@v1
with:
kubernetes-distribution: ${{ matrix.cluster.distribution }}
kubernetes-version: ${{ matrix.cluster.version }}
cluster-name: ${{ matrix.cluster.distribution }}-${{ matrix.cluster.version }}
timeout-minutes: 10
ttl: 10m
export-kubeconfig: true
api-token: ${{ secrets.REPLICATED_API_TOKEN }}
# kubeconfig-path: /tmp/kubeconfig # optional, specifies path for Kubeconfig file
- name: Create kubecost Namespace and test files
run: |
kubectl create ns kubecost
kubectl -n kubecost create -f .github/ci-files
# Install the chart with OCP values and check results.
- name: Install Kubecost chart with OCP values
working-directory: ./cost-analyzer
run: |
helm install --wait --wait-for-jobs kubecost . -n kubecost -f values-openshift.yaml \
--set global.platforms.openshift.route.enabled=true \
--set global.platforms.openshift.scc.nodeExporter=true \
--set global.platforms.openshift.scc.networkCosts=true \
--set networkCosts.enabled=true \
--set prometheus.nodeExporter.enabled=true
# run: ct install --namespace kubecost --chart-dirs=cost-analyzer/ --charts cost-analyzer/
- name: Wait for ready
run: kubectl wait -n kubecost --for=condition=ready pod --selector app.kubernetes.io/name=cost-analyzer --timeout=120s
- name: Run Helm tests
run: helm test -n kubecost kubecost
- name: Remove Cluster
id: remove-cluster
uses: replicatedhq/compatibility-actions/remove-cluster@v1
continue-on-error: true
with:
api-token: ${{ secrets.REPLICATED_API_TOKEN }}
cluster-id: ${{ steps.create-cluster.outputs.cluster-id }}
deploy-eks:
runs-on: ubuntu-latest
needs: test-chart
strategy:
matrix:
cluster:
- distribution: eks
version: v1.28
- distribution: eks
version: v1.29
- distribution: eks
version: v1.30
steps:
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
with:
ref: ${{ github.event.pull_request.head.sha }}
# Outputs: `cluster-kubeconfig`, `cluster-id`
- name: Create Cluster
id: create-cluster
uses: replicatedhq/compatibility-actions/create-cluster@v1
with:
kubernetes-distribution: ${{ matrix.cluster.distribution }}
kubernetes-version: ${{ matrix.cluster.version }}
cluster-name: ${{ matrix.cluster.distribution }}-${{ matrix.cluster.version }}
timeout-minutes: 10
ttl: 10m
export-kubeconfig: true
api-token: ${{ secrets.REPLICATED_API_TOKEN }}
# kubeconfig-path: /tmp/kubeconfig # optional, specifies path for Kubeconfig file
- name: Create kubecost Namespace and test files
run: |
kubectl create ns kubecost
kubectl -n kubecost create -f .github/ci-files
# Install the chart with EKS values and check results.
- name: Install Kubecost chart with EKS values
working-directory: ./cost-analyzer
run: |
helm install --wait --wait-for-jobs kubecost . -n kubecost -f values-eks-cost-monitoring.yaml \
--set persistentVolume.storageClass=gp2 \
--set prometheus.server.persistentVolume.storageClass=gp2
# run: ct install --namespace kubecost --chart-dirs=cost-analyzer/ --charts cost-analyzer/
- name: Wait for ready
run: kubectl wait -n kubecost --for=condition=ready pod --selector app.kubernetes.io/name=cost-analyzer --timeout=120s
- name: Run Helm tests
run: helm test -n kubecost kubecost
- name: Remove Cluster
id: remove-cluster
uses: replicatedhq/compatibility-actions/remove-cluster@v1
continue-on-error: true
with:
api-token: ${{ secrets.REPLICATED_API_TOKEN }}
cluster-id: ${{ steps.create-cluster.outputs.cluster-id }}