-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add GitHub Actions to publish helm chart (#257)
* Add chart workflows (#1) * Add chart workflows * Fix publishing step in CI Signed-off-by: David Young <davidy@funkypenguin.co.nz> * Update CI on push-to-master (#3) * Put helm installation step in the correct CI job Signed-off-by: David Young <davidy@funkypenguin.co.nz> * Put helm installation step in the correct CI job (#4) * Update on-push-master-publish-chart.yml * Remove references to certmanager dependency Signed-off-by: David Young <davidy@funkypenguin.co.nz> * Add ability to customize kube-rbac-proxy image Signed-off-by: David Young <davidy@funkypenguin.co.nz> * Only install cert-manager if we're going to spin up KinD Signed-off-by: David Young <davidy@funkypenguin.co.nz>
- Loading branch information
1 parent
ace95d7
commit 1127c44
Showing
12 changed files
with
275 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
name: Lint and Test Charts | ||
|
||
on: | ||
push: | ||
paths: | ||
- 'charts/**' | ||
- '.github/**' | ||
workflow_dispatch: | ||
|
||
env: | ||
KUBE_SCORE_VERSION: 1.10.0 | ||
HELM_VERSION: v3.4.1 | ||
|
||
jobs: | ||
lint-test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up Helm | ||
uses: azure/setup-helm@v1 | ||
with: | ||
version: ${{ env.HELM_VERSION }} | ||
|
||
- name: Set up kube-score | ||
run: | | ||
wget https://github.com/zegl/kube-score/releases/download/v${{ env.KUBE_SCORE_VERSION }}/kube-score_${{ env.KUBE_SCORE_VERSION }}_linux_amd64 -O kube-score | ||
chmod 755 kube-score | ||
- name: Kube-score generated manifests | ||
run: helm template --values charts/.ci/values-kube-score.yaml charts/* | ./kube-score score - | ||
--ignore-test pod-networkpolicy | ||
--ignore-test deployment-has-poddisruptionbudget | ||
--ignore-test deployment-has-host-podantiaffinity | ||
--ignore-test container-security-context | ||
--ignore-test pod-probes | ||
--ignore-test container-image-tag | ||
--enable-optional-test container-security-context-privileged | ||
--enable-optional-test container-security-context-readonlyrootfilesystem | ||
|
||
# python is a requirement for the chart-testing action below (supports yamllint among other tests) | ||
- uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.7 | ||
|
||
- name: Set up chart-testing | ||
uses: helm/chart-testing-action@v2.0.1 | ||
|
||
- name: Run chart-testing (list-changed) | ||
id: list-changed | ||
run: | | ||
changed=$(ct list-changed --config charts/.ci/ct-config.yaml) | ||
if [[ -n "$changed" ]]; then | ||
echo "::set-output name=changed::true" | ||
fi | ||
- name: Run chart-testing (lint) | ||
run: ct lint --config charts/.ci/ct-config.yaml | ||
|
||
- name: Create kind cluster | ||
uses: helm/kind-action@v1.0.0 | ||
if: steps.list-changed.outputs.changed == 'true' | ||
|
||
# We need cert-manager already installed in the cluster because we assume the CRDs exist | ||
- name: Install cert-manager | ||
run: | | ||
helm repo add jetstack https://charts.jetstack.io --force-update | ||
helm install cert-manager jetstack/cert-manager --set installCRDs=true --wait | ||
if: steps.list-changed.outputs.changed == 'true' | ||
|
||
- name: Run chart-testing (install) | ||
run: ct install --config charts/.ci/ct-config.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
name: Publish helm chart | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
- main # assume that the branch name may change in future | ||
paths: | ||
- 'charts/**' | ||
- '.github/**' | ||
workflow_dispatch: | ||
|
||
env: | ||
KUBE_SCORE_VERSION: 1.10.0 | ||
HELM_VERSION: v3.4.1 | ||
|
||
jobs: | ||
lint-chart: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up Helm | ||
uses: azure/setup-helm@v1 | ||
with: | ||
version: ${{ env.HELM_VERSION }} | ||
|
||
- name: Set up kube-score | ||
run: | | ||
wget https://github.com/zegl/kube-score/releases/download/v${{ env.KUBE_SCORE_VERSION }}/kube-score_${{ env.KUBE_SCORE_VERSION }}_linux_amd64 -O kube-score | ||
chmod 755 kube-score | ||
- name: Kube-score generated manifests | ||
run: helm template --values charts/.ci/values-kube-score.yaml charts/* | ./kube-score score - | ||
--ignore-test pod-networkpolicy | ||
--ignore-test deployment-has-poddisruptionbudget | ||
--ignore-test deployment-has-host-podantiaffinity | ||
--ignore-test container-security-context | ||
--ignore-test pod-probes | ||
--ignore-test container-image-tag | ||
--enable-optional-test container-security-context-privileged | ||
--enable-optional-test container-security-context-readonlyrootfilesystem | ||
|
||
# python is a requirement for the chart-testing action below (supports yamllint among other tests) | ||
- uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.7 | ||
|
||
- name: Set up chart-testing | ||
uses: helm/chart-testing-action@v2.0.1 | ||
|
||
- name: Run chart-testing (list-changed) | ||
id: list-changed | ||
run: | | ||
changed=$(ct list-changed --config charts/.ci/ct-config.yaml) | ||
if [[ -n "$changed" ]]; then | ||
echo "::set-output name=changed::true" | ||
fi | ||
- name: Run chart-testing (lint) | ||
run: ct lint --config charts/.ci/ct-config.yaml | ||
|
||
- name: Create kind cluster | ||
uses: helm/kind-action@v1.0.0 | ||
if: steps.list-changed.outputs.changed == 'true' | ||
|
||
# We need cert-manager already installed in the cluster because we assume the CRDs exist | ||
- name: Install cert-manager | ||
run: | | ||
helm repo add jetstack https://charts.jetstack.io --force-update | ||
helm install cert-manager jetstack/cert-manager --set installCRDs=true --wait | ||
if: steps.list-changed.outputs.changed == 'true' | ||
|
||
- name: Run chart-testing (install) | ||
run: ct install --config charts/.ci/ct-config.yaml | ||
if: steps.list-changed.outputs.changed == 'true' | ||
|
||
publish-chart: | ||
|
||
runs-on: ubuntu-latest | ||
needs: lint-chart | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Configure Git | ||
run: | | ||
git config user.name "$GITHUB_ACTOR" | ||
git config user.email "$GITHUB_ACTOR@users.noreply.github.com" | ||
- name: Run chart-releaser | ||
uses: helm/chart-releaser-action@v1.1.0 | ||
env: | ||
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# This file defines the config for "ct" (chart tester) used by the helm linting GitHub workflow | ||
lint-conf: charts/.ci/lint-config.yaml | ||
chart-repos: | ||
- jetstack=https://charts.jetstack.io |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
rules: | ||
# One blank line is OK | ||
empty-lines: | ||
max-start: 1 | ||
max-end: 1 | ||
max: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
docker run --rm -it -w /repo -v $(pwd):/repo quay.io/helmpack/chart-testing ct lint --all --config charts/.ci/ct-config.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
|
||
|
||
for chart in `ls charts`; | ||
do | ||
helm template --values charts/$chart/ci/ci-values.yaml charts/$chart | kube-score score - \ | ||
--ignore-test pod-networkpolicy \ | ||
--ignore-test deployment-has-poddisruptionbudget \ | ||
--ignore-test deployment-has-host-podantiaffinity \ | ||
--ignore-test pod-probes \ | ||
--ignore-test container-image-tag \ | ||
--enable-optional-test container-security-context-privileged \ | ||
--enable-optional-test container-security-context-readonlyrootfilesystem \ | ||
--ignore-test container-security-context | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# This file sets some opinionated values for kube-score to use | ||
# when parsing the chart | ||
image: | ||
pullPolicy: Always | ||
|
||
podSecurityContext: | ||
fsGroup: 2000 | ||
|
||
securityContext: | ||
capabilities: | ||
drop: | ||
- ALL | ||
readOnlyRootFilesystem: true | ||
runAsNonRoot: true | ||
runAsUser: 2000 | ||
|
||
resources: | ||
limits: | ||
cpu: 100m | ||
memory: 128Mi | ||
requests: | ||
cpu: 100m | ||
memory: 128Mi | ||
|
||
# Set the following to true to create a dummy secret, allowing the manager pod to start | ||
# This is only useful in CI | ||
createDummySecret: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# This template only exists to facilitate CI testing of the chart, since | ||
# a secret is expected to be found in the namespace by the controller manager | ||
{{ if .Values.createDummySecret -}} | ||
apiVersion: v1 | ||
data: | ||
github_token: dGVzdA== | ||
kind: Secret | ||
metadata: | ||
name: controller-manager | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters