Skip to content

Commit aa29a26

Browse files
author
Sunil Thaha
committed
ci: release helm chart as an artifact
Signed-off-by: Sunil Thaha <[email protected]>
1 parent 932c8f7 commit aa29a26

File tree

2 files changed

+82
-0
lines changed

2 files changed

+82
-0
lines changed

.github/k8s/action.yaml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ runs:
4545
run: |
4646
kubectl version --client
4747
48+
- name: Setup Helm
49+
uses: azure/setup-helm@v4
50+
with:
51+
version: latest
52+
4853
- name: Checkout source
4954
uses: actions/checkout@v4
5055
with:
@@ -56,6 +61,11 @@ runs:
5661
go-version-file: go.mod
5762
cache: false
5863

64+
- name: Lint Helm chart
65+
shell: bash
66+
run: |
67+
helm lint manifests/helm/kepler
68+
5969
- name: Build image
6070
shell: bash
6171
run: |
@@ -128,6 +138,55 @@ runs:
128138
fi
129139
done
130140
141+
- name: Remove existing Kepler deployment
142+
shell: bash
143+
run: |
144+
echo "::group::Remove existing Kepler deployment before Helm test"
145+
make undeploy
146+
echo "::endgroup::"
147+
148+
- name: Test Helm deployment
149+
shell: bash
150+
run: |
151+
echo "::group::Deploy Kepler using Helm"
152+
# Update Helm chart to use the locally built image
153+
sed -i 's|repository: quay.io/sustainable_computing_io/kepler|repository: localhost:5001/kepler|' manifests/helm/kepler/values.yaml
154+
sed -i 's|tag: latest|tag: dev|' manifests/helm/kepler/values.yaml
155+
sed -i '/fake-cpu-meter:/{n;s/enabled: false/enabled: true/}' manifests/helm/kepler/values.yaml
156+
157+
# Install using Helm
158+
helm install kepler-helm-test manifests/helm/kepler --namespace kepler-helm --create-namespace --wait --timeout=5m
159+
echo "::endgroup::"
160+
161+
- name: Verify Helm deployment
162+
shell: bash
163+
run: |
164+
echo "::group::Verify Helm deployment"
165+
kubectl rollout status daemonset/kepler-helm-test -n kepler-helm --timeout=5m
166+
kubectl get pods -n kepler-helm
167+
echo "::endgroup::"
168+
169+
- name: Validate Helm metrics endpoint
170+
shell: bash
171+
run: |
172+
echo "::group::Test Helm deployment metrics"
173+
kubectl port-forward service/kepler-helm-test 28283:28282 -n kepler-helm &
174+
sleep 20
175+
176+
HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:28283/metrics)
177+
[[ $HTTP_STATUS -ne 200 ]] && echo "Helm deployment HTTP status code is not 200" && exit 1
178+
179+
echo "Helm deployment metrics endpoint is working"
180+
echo "::endgroup::"
181+
182+
- name: Cleanup Helm deployment
183+
shell: bash
184+
run: |
185+
echo "::group::Cleanup Helm deployment"
186+
helm uninstall kepler-helm-test -n kepler-helm
187+
kubectl delete namespace kepler-helm
188+
echo "::endgroup::"
189+
131190
- name: Run must gather
132191
shell: bash
133192
run: |

.github/workflows/release.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ jobs:
3030
cache: true
3131
check-latest: true
3232

33+
- name: Setup Helm
34+
uses: azure/setup-helm@v4
35+
with:
36+
version: latest
37+
3338
- name: Login to Image Registry
3439
uses: docker/login-action@v2
3540
with:
@@ -53,6 +58,22 @@ jobs:
5358
TAG_NAME=${{ github.ref_name }}
5459
echo "version=$TAG_NAME" >> "$GITHUB_OUTPUT"
5560
61+
- name: Update Helm Chart Version
62+
shell: bash
63+
run: |
64+
VERSION=${{ steps.version.outputs.version }}
65+
# Remove 'v' prefix from version
66+
CHART_VERSION=${VERSION#v}
67+
# Update Chart.yaml with the release version
68+
sed -i "s/^version:.*/version: $CHART_VERSION/" manifests/helm/kepler/Chart.yaml
69+
sed -i "s/^appVersion:.*/appVersion: \"$VERSION\"/" manifests/helm/kepler/Chart.yaml
70+
71+
- name: Package Helm Chart
72+
shell: bash
73+
run: |
74+
mkdir -p helm-releases
75+
helm package manifests/helm/kepler -d helm-releases
76+
5677
- name: Create GitHub Release
5778
uses: softprops/action-gh-release@v2
5879
with:
@@ -61,6 +82,8 @@ jobs:
6182
generate_release_notes: true
6283
draft: false
6384
make_latest: true
85+
files: |
86+
helm-releases/*.tgz
6487
env:
6588
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6689

0 commit comments

Comments
 (0)