Skip to content

Commit d439c86

Browse files
authored
feat: add helm chart and improve pipelines (#12)
* add helm lint action and some other action chores * ignore .zed/ * improve containerfile syntax * feat: add helm chart * add lint and dry-run checks for helm chart * add secret generation * 🔥 remove k8s manifest files and change all references to helm chart installation * 🔥 remove namespace from storageclass example * add helm release docs * add helm release pipeline and optmize app release one * use my fork of k8s-lint action to include needed fix * use my fork of k8s-lint action to support directories * Update lint-golang.yaml * ignore missing schemas * ensure chart versions have been bumped properly before creating a release * trigger restart when secret changes by implementing hash check * fix: add missing tls arguments for snapshot webhook * update LICENSE * release helm package in OCI repo and provide artifacthub metadata * small e2e test workflow improvement * run resize jobs in parallel * perform helm upgrade --install during e2e test to prevent errors with an existing installation
1 parent aea5fd6 commit d439c86

46 files changed

Lines changed: 1629 additions & 1037 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,19 @@ jobs:
4343
platforms: linux/amd64
4444

4545
- name: Push image
46+
id: push-image
4647
uses: redhat-actions/push-to-registry@5ed88d269cf581ea9ef6dd6806d01562096bee9c # v2.8
4748
with:
4849
image: ${{ steps.build-image.outputs.image }}
49-
tags: ${{ steps.build-image.outputs.tags }}
50+
tags: ${{ inputs.tags }}
5051
registry: ghcr.io
52+
53+
- name: Build summary
54+
run: |
55+
echo "## Container image" >> "$GITHUB_STEP_SUMMARY"
56+
echo "" >> "$GITHUB_STEP_SUMMARY"
57+
echo "| Field | Value |" >> "$GITHUB_STEP_SUMMARY"
58+
echo "|---|---|" >> "$GITHUB_STEP_SUMMARY"
59+
echo "| Image | \`${{ steps.build-image.outputs.image }}\` |" >> "$GITHUB_STEP_SUMMARY"
60+
echo "| Tags | \`${{ inputs.tags }}\` |" >> "$GITHUB_STEP_SUMMARY"
61+
echo "| Digest | \`${{ steps.push-image.outputs.digest }}\` |" >> "$GITHUB_STEP_SUMMARY"

.github/workflows/build.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Build image
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
paths:
7+
- "internal/**"
8+
- "cmd/**"
9+
- "go.mod"
10+
- "go.sum"
11+
12+
permissions:
13+
contents: read
14+
packages: write
15+
16+
jobs:
17+
build-image:
18+
uses: ./.github/workflows/_reusable-build.yaml
19+
with:
20+
tags: ${{ github.sha }}
21+
secrets: inherit

.github/workflows/deploy.yaml

Lines changed: 0 additions & 20 deletions
This file was deleted.
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
name: Lint
1+
name: Lint Golang
22

33
on:
44
pull_request:
5+
paths:
6+
- '**/*.go'
7+
- go.mod
8+
- go.sum
9+
- '.github/workflows/lint-golang.yaml'
510

611
env:
712
GO_VERSION: '1.26'

.github/workflows/lint-helm.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Helm Lint
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'deploy/helm/**'
7+
- '.github/workflows/lint-helm.yaml'
8+
- '.github/workflows/lint-golang.yaml'
9+
10+
jobs:
11+
helm-lint:
12+
name: helm-lint
13+
runs-on: ubuntu-24.04
14+
steps:
15+
- name: Checkout head
16+
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
17+
18+
- name: Run helm lint
19+
run: make helm-lint
20+
21+
- name: Run kube-linter
22+
uses: stackrox/kube-linter-action@87802a2f4e01abebb3ee3c67a3002fea71f6eae5 # v1.0.7
23+
with:
24+
directory: deploy/helm
25+
config: deploy/helm/.kube-linter.yaml
26+
format: plain
27+
28+
- name: Run kubeconform
29+
uses: aardbol/k8s-lint@4ac6a6ad40152ad8478533d7e4d4d3c210f68eca # v5.0.0
30+
with:
31+
manifests: deploy/helm/
32+
lintType: kubeconform
33+
kubeconformOpts: -summary -strict -ignore-missing-schemas

.github/workflows/release-app.yaml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Release App
2+
3+
on:
4+
push:
5+
tags: ["v*.*.*"]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: write
10+
packages: write
11+
12+
jobs:
13+
release-app:
14+
runs-on: ubuntu-24.04
15+
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
19+
with:
20+
fetch-depth: 0
21+
22+
- name: Validate Chart versions
23+
env:
24+
APP: ${{ github.ref_name }}
25+
run: |
26+
MAIN_VERSION=$(git show main:deploy/helm/Chart.yaml | yq .version)
27+
MAIN_APP_VERSION=$(git show main:deploy/helm/Chart.yaml | yq .appVersion)
28+
TAG_VERSION=$(yq .version deploy/helm/Chart.yaml)
29+
TAG_APP_VERSION=$(yq .appVersion deploy/helm/Chart.yaml)
30+
31+
if [ "$TAG_VERSION" = "$MAIN_VERSION" ] && [ "$TAG_APP_VERSION" = "$MAIN_APP_VERSION" ]; then
32+
echo "Both version ($TAG_VERSION) and appVersion ($TAG_APP_VERSION) in" >> "$GITHUB_STEP_SUMMARY"
33+
echo "deploy/helm/Chart.yaml match main. Bump at least one before tagging." >> "$GITHUB_STEP_SUMMARY"
34+
exit 1
35+
fi
36+
37+
if [ "$TAG_APP_VERSION" != "$APP" ]; then
38+
echo "Tag ($APP) does not match appVersion ($TAG_APP_VERSION) in deploy/helm/Chart.yaml." >> "$GITHUB_STEP_SUMMARY"
39+
echo "Update appVersion in deploy/helm/Chart.yaml to match the tag." >> "$GITHUB_STEP_SUMMARY"
40+
exit 1
41+
fi
42+
43+
echo "Chart version: $TAG_VERSION (main: $MAIN_VERSION)"
44+
echo "App version: $TAG_APP_VERSION (main: $MAIN_APP_VERSION)"
45+
46+
- name: Log in to GHCR
47+
uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4.2.0
48+
with:
49+
registry: ghcr.io
50+
username: ${{ github.actor }}
51+
password: ${{ secrets.GITHUB_TOKEN }}
52+
53+
- name: Pull SHA image
54+
run: |
55+
buildah pull ghcr.io/${{ github.repository }}:${{ github.sha }} || {
56+
echo "## Release failed" >> "$GITHUB_STEP_SUMMARY"
57+
echo "No container image found for commit \`${{ github.sha }}\`." >> "$GITHUB_STEP_SUMMARY"
58+
echo "" >> "$GITHUB_STEP_SUMMARY"
59+
echo "The **Build image** workflow must have built this commit" >> "$GITHUB_STEP_SUMMARY"
60+
echo "before it can be released. Only commits pushed to \`main\`" >> "$GITHUB_STEP_SUMMARY"
61+
echo "that changed source code produce an image." >> "$GITHUB_STEP_SUMMARY"
62+
echo "" >> "$GITHUB_STEP_SUMMARY"
63+
echo "Tag a commit that was pushed to main and built successfully." >> "$GITHUB_STEP_SUMMARY"
64+
exit 1
65+
}
66+
67+
- name: Tag and push release
68+
run: |
69+
buildah tag ghcr.io/${{ github.repository }}:${{ github.sha }} ghcr.io/${{ github.repository }}:${{ github.ref_name }}
70+
buildah tag ghcr.io/${{ github.repository }}:${{ github.sha }} ghcr.io/${{ github.repository }}:latest
71+
buildah push ghcr.io/${{ github.repository }}:${{ github.ref_name }}
72+
buildah push ghcr.io/${{ github.repository }}:latest
73+
74+
- name: Get release notes
75+
run: make release-notes > .release_notes
76+
77+
- name: Create release
78+
run: gh release create "${{ github.ref_name }}" --notes-file .release_notes --draft
79+
env:
80+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: Release Helm chart
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- deploy/helm/Chart.yaml
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: write
12+
packages: write
13+
14+
env:
15+
CHART_DIR: deploy/helm
16+
REGISTRY: ghcr.io
17+
CHART_OCI_REPO: ${{ github.repository_owner }}/charts
18+
19+
jobs:
20+
release-helm:
21+
runs-on: ubuntu-24.04
22+
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
26+
27+
- name: Setup ORAS
28+
uses: oras-project/setup-oras@38de303aac69abb66f3e6255b7198bff35f323e3 # v2.0.0
29+
30+
- name: Check version bump
31+
id: check
32+
env:
33+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34+
run: |
35+
chart_version=$(yq .version "$CHART_DIR/Chart.yaml")
36+
echo "chart_version=$chart_version" >> "$GITHUB_OUTPUT"
37+
38+
if gh release view "helm-v$chart_version" > /dev/null 2>&1; then
39+
echo "Release helm-v$chart_version already exists. Skipping."
40+
echo "skip_release=true" >> "$GITHUB_OUTPUT"
41+
exit 0
42+
fi
43+
44+
is_prerelease="false"
45+
if [[ "$chart_version" == *-* ]]; then
46+
is_prerelease="true"
47+
fi
48+
echo "is_prerelease=$is_prerelease" >> "$GITHUB_OUTPUT"
49+
echo "skip_release=false" >> "$GITHUB_OUTPUT"
50+
51+
- name: Log in to GHCR
52+
if: steps.check.outputs.skip_release == 'false'
53+
uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4.2.0
54+
with:
55+
registry: ${{ env.REGISTRY }}
56+
username: ${{ github.actor }}
57+
password: ${{ secrets.GITHUB_TOKEN }}
58+
59+
- name: Get release notes
60+
if: steps.check.outputs.skip_release == 'false'
61+
run: make helm-release-notes > .release_notes
62+
63+
- name: Package chart
64+
if: steps.check.outputs.skip_release == 'false'
65+
run: |
66+
mkdir -p dist
67+
helm package ${{ env.CHART_DIR }} --destination dist
68+
69+
- name: Push chart to GHCR OCI
70+
if: steps.check.outputs.skip_release == 'false'
71+
run: |
72+
helm push dist/*.tgz oci://${{ env.REGISTRY }}/${{ env.CHART_OCI_REPO }}
73+
74+
- name: Push Artifact Hub metadata
75+
if: steps.check.outputs.skip_release == 'false'
76+
run: |
77+
chart_name=$(yq .name "$CHART_DIR/Chart.yaml")
78+
oras push ${{ env.REGISTRY }}/${{ env.CHART_OCI_REPO }}/${chart_name}:artifacthub.io \
79+
--config /dev/null:application/vnd.cncf.artifacthub.config.v1+yaml \
80+
artifacthub-repo.yml:application/vnd.cncf.artifacthub.repository-metadata.layer.v1.yaml
81+
82+
- name: Create release
83+
if: steps.check.outputs.skip_release == 'false'
84+
env:
85+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
86+
run: |
87+
gh release create "helm-v${{ steps.check.outputs.chart_version }}" \
88+
dist/*.tgz \
89+
--notes-file .release_notes \
90+
--title "helm-v${{ steps.check.outputs.chart_version }}" \
91+
${{ steps.check.outputs.is_prerelease == 'true' && '--prerelease' || '' }}

.github/workflows/release.yaml

Lines changed: 0 additions & 24 deletions
This file was deleted.

.github/workflows/test-e2e.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ env:
1313

1414
jobs:
1515
build-image:
16-
uses: ./.github/workflows/reusable-build.yaml
16+
uses: ./.github/workflows/_reusable-build.yaml
1717
with:
1818
checkout_ref: ${{ github.sha }}
1919
image_suffix: '-test'
@@ -35,16 +35,16 @@ jobs:
3535
mkdir -p ~/.kube
3636
echo "${{ secrets.KUBE_CONFIG }}" | base64 -d > ~/.kube/config
3737
38-
- name: Deploy CSI driver manifests
39-
run: make deploy-manifests CONTAINER_REPO=${{ env.REGISTRY }}/${{ env.TEST_IMAGE }} IMAGE_TAG=${{ github.sha }}
38+
- name: Deploy CSI driver via Helm
39+
run: make helm-upgrade HELM_OPTS="--install --set image.repository=${{ env.REGISTRY }}/${{ env.TEST_IMAGE }} --set image.tag=${{ github.sha }}"
4040

4141
e2e:
4242
runs-on: ubuntu-24.04
4343
needs: deploy
4444
strategy:
4545
fail-fast: false
4646
matrix:
47-
test-case: [SNAPSHOT, RESIZE, LIST, CREATEDELETE, PERSISTENCE]
47+
test-case: [SNAPSHOT, RESIZE_EXT4, RESIZE_XFS, LIST, CREATEDELETE, PERSISTENCE]
4848
steps:
4949
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
5050

@@ -58,4 +58,5 @@ jobs:
5858
echo "${{ secrets.KUBE_CONFIG }}" | base64 -d > ~/.kube/config
5959
6060
- name: Run ${{ matrix.test-case }} e2e test
61+
id: test
6162
run: make test-e2e ${{ matrix.test-case }}=y

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ cmd/upcloud-csi-manifest/upcloud-csi-manifest
55
.vscode
66
temp/
77
.idea/
8+
.zed/
89
.DS_Store
910
vendor/
1011
dist/

0 commit comments

Comments
 (0)