From 2b9ea33681f0f9cd647e960762bd1ba1457b5208 Mon Sep 17 00:00:00 2001 From: David Young Date: Mon, 11 May 2020 11:22:02 +1200 Subject: [PATCH 1/7] Add deployment annotation --- charts/docker-mailserver/Chart.yaml | 2 +- charts/docker-mailserver/templates/deployment.yaml | 4 ++++ charts/docker-mailserver/values.yaml | 6 ++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/charts/docker-mailserver/Chart.yaml b/charts/docker-mailserver/Chart.yaml index f2f5b40c..f4661287 100644 --- a/charts/docker-mailserver/Chart.yaml +++ b/charts/docker-mailserver/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v1 appVersion: "6.3.0" description: A fullstack but simple mailserver (smtp, imap, antispam, antivirus, ssl...) using Docker. name: docker-mailserver -version: 0.2.4-pre2 +version: 0.2.4-pre3 sources: - https://github.com/funkypenguin/helm-docker-mailserver maintainers: diff --git a/charts/docker-mailserver/templates/deployment.yaml b/charts/docker-mailserver/templates/deployment.yaml index b701dece..26ffb7d3 100644 --- a/charts/docker-mailserver/templates/deployment.yaml +++ b/charts/docker-mailserver/templates/deployment.yaml @@ -8,6 +8,10 @@ metadata: heritage: "{{ .Release.Service }}" release: "{{ .Release.Name }}" name: {{ template "dockermailserver.fullname" . }} +{{- if .Values.pod.dockermailserver.annotations }} + annotations: +{{ toYaml .Values.deployment.annotations | indent 4 }} +{{ end }} spec: replicas: {{ default 2 .Values.deployment.replicas }} selector: diff --git a/charts/docker-mailserver/values.yaml b/charts/docker-mailserver/values.yaml index 919a7788..39f5cff0 100644 --- a/charts/docker-mailserver/values.yaml +++ b/charts/docker-mailserver/values.yaml @@ -96,6 +96,12 @@ livenessTests: commands: - "clamscan /tmp/docker-mailserver/TrustedHosts" +deployment: + + ## Add annotations to the deployment + ## Useful for using something like stash to backup data (https://stash.run/docs/v0.9.0-rc.0/guides/latest/auto-backup/workload/) + annotations: {} + pod: # pod.dockermailserver section refers to the configuration of the docker-mailserver pod itself. Note that teh many environment variables which define the behaviour of docker-mailserver are configured here dockermailserver: From 4567478388aaab7ca85b6d0dab58d131b825c355 Mon Sep 17 00:00:00 2001 From: David Young Date: Mon, 11 May 2020 13:38:13 +1200 Subject: [PATCH 2/7] Make ct install actually work --- .ci/ct-config.yaml | 2 +- .github/workflows/on-pr-lint-charts.yml | 21 +++++++ ...-lint-charts.yml => on-pr-test-charts.yml} | 4 +- .../on-push-master-publish-chart.yml | 13 ----- TESTING.md | 56 +++++++++++++++++++ .../templates/_upstream-env-variables.tpl | 2 +- .../templates/deployment.yaml | 8 +-- charts/docker-mailserver/values.yaml | 2 +- 8 files changed, 86 insertions(+), 22 deletions(-) create mode 100644 .github/workflows/on-pr-lint-charts.yml rename .github/workflows/{on-push-lint-charts.yml => on-pr-test-charts.yml} (95%) create mode 100644 TESTING.md diff --git a/.ci/ct-config.yaml b/.ci/ct-config.yaml index 66b5b544..588a905f 100644 --- a/.ci/ct-config.yaml +++ b/.ci/ct-config.yaml @@ -4,4 +4,4 @@ chart-repos: - haproxy=https://haproxytech.github.io/helm-charts -lint-conf: .ci/lint-config.yaml +lint-conf: .ci/lint-config.yaml \ No newline at end of file diff --git a/.github/workflows/on-pr-lint-charts.yml b/.github/workflows/on-pr-lint-charts.yml new file mode 100644 index 00000000..0d315f4a --- /dev/null +++ b/.github/workflows/on-pr-lint-charts.yml @@ -0,0 +1,21 @@ +name: Linting + +on: + pull_request: + paths: + - 'charts/**' + - '.github/**' + +jobs: + lint-test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v1 + + - name: Run chart-testing (lint) + id: lint + uses: helm/chart-testing-action@v1.0.0-rc.1 + with: + config: .ci/ct-config.yaml + command: lint \ No newline at end of file diff --git a/.github/workflows/on-push-lint-charts.yml b/.github/workflows/on-pr-test-charts.yml similarity index 95% rename from .github/workflows/on-push-lint-charts.yml rename to .github/workflows/on-pr-test-charts.yml index 334d6162..86bc39a0 100644 --- a/.github/workflows/on-push-lint-charts.yml +++ b/.github/workflows/on-pr-test-charts.yml @@ -1,7 +1,7 @@ -name: Lint and Test Charts +name: Testing on: - push: + pull_request: paths: - 'charts/**' - '.github/**' diff --git a/.github/workflows/on-push-master-publish-chart.yml b/.github/workflows/on-push-master-publish-chart.yml index 7ce50923..fefb2601 100644 --- a/.github/workflows/on-push-master-publish-chart.yml +++ b/.github/workflows/on-push-master-publish-chart.yml @@ -15,19 +15,6 @@ jobs: steps: - uses: actions/checkout@v2 - # - uses: azure/setup-helm@v1 - # id: installhelm3 - # with: - # version: 'v3.0.3' - # - name: Publish helm charts - # uses: funkypenguin/helm-gh-pages-action@v1.1.1 - # with: - # # A personal access token needed to push your site after it has been built. - # access-token: ${{ secrets.CR_TOKEN }} - # # The branch expected by GitHub to have the static files needed for your site. - # deploy-branch: chart - # # The folder in which the helm charts are located - # charts-folder: charts - name: Fetch history run: git fetch --prune --unshallow diff --git a/TESTING.md b/TESTING.md new file mode 100644 index 00000000..1c357f8a --- /dev/null +++ b/TESTING.md @@ -0,0 +1,56 @@ +# How this chart is tested + +# Automated tests + +Every pull request to the master branch trigger the following tests: + +* ct lint +* ct install + +# Local testing + +If you're submitting a PR, and you want to ensure your changes will pass automated testing (above), here are your options: + +## Linting + +We use helm's [chart-testing](https://github.com/helm/chart-testing) tool to lint our charts. The tool can be installed locally, or it can be run in a Docker container. + +To run in Docker: + +1. Have Docker installed +2. Run `./ci/scripts/local-lint` + +To run locally: + +1. Have ct installed (Get a binary package from https://github.com/helm/chart-testing/releases) +2. Run `ct lint --config=.ci/ct-config.yaml` + +## Deployment testing + +*ct* can also test a chart by deploying it to a temporary namespace in a Kubernetes cluster, and waiting for indications that the deployment has been successful. This is a good way to test how the deployment behaves "for real". + + + + +ct lint --config=.ci/ct-config.yaml + +Create a KinD cluster, by running `kind create cluster`: + +``` +❯ kind create cluster +Creating cluster "kind" ... + ✓ Ensuring node image (kindest/node:v1.17.0) đŸ–ŧ + ✓ Preparing nodes đŸ“Ļ + ✓ Writing configuration 📜 + ✓ Starting control-plane 🕹ī¸ + ✓ Installing CNI 🔌 + ✓ Installing StorageClass 💾 +Set kubectl context to "kind-kind" +You can now use your cluster with: + +kubectl cluster-info --context kind-kind + +Have a nice day! 👋 +``` + +Trigger a `ct install` test against the KinD cluster, by running `t install --config=.ci/ct-config.yaml`. **ct** will target your current context (be careful if you've got multiple contexts configured!), create a temporary namespace, and deploy the chart into that namespace, until `helm --wait` indicates success. After this, the helm release will be removed, the namespace deleted, and you can retire your KinD cluster by running `kind delete cluster`. \ No newline at end of file diff --git a/charts/docker-mailserver/templates/_upstream-env-variables.tpl b/charts/docker-mailserver/templates/_upstream-env-variables.tpl index 0df43906..5ce6d30a 100644 --- a/charts/docker-mailserver/templates/_upstream-env-variables.tpl +++ b/charts/docker-mailserver/templates/_upstream-env-variables.tpl @@ -18,7 +18,7 @@ We list them here (and include this template in deployment.yaml) to keep deploym - name: SMTP_ONLY value: {{ .Values.pod.dockermailserver.smtp_only | quote }} - name: SSL_TYPE - value: {{ default "manual" .Values.pod.dockermailserver.ssl_type | quote }} + value: {{ .Values.pod.dockermailserver.ssl_type | quote }} - name: SSL_CERT_PATH value: {{ default "/tmp/ssl/tls.crt" .Values.pod.dockermailserver.ssl_cert_path | quote }} - name: SSL_KEY_PATH diff --git a/charts/docker-mailserver/templates/deployment.yaml b/charts/docker-mailserver/templates/deployment.yaml index 26ffb7d3..f829019e 100644 --- a/charts/docker-mailserver/templates/deployment.yaml +++ b/charts/docker-mailserver/templates/deployment.yaml @@ -142,13 +142,13 @@ spec: command: - /bin/bash - /tmp/docker-mailserver/am-i-healthy.sh - initialDelaySeconds: 600 - timeoutSeconds: 60 - failureThreshold: 3 + initialDelaySeconds: 60 + timeoutSeconds: 10 + failureThreshold: 2 readinessProbe: tcpSocket: port: 25 - initialDelaySeconds: 600 + initialDelaySeconds: 60 periodSeconds: 20 timeoutSeconds: 1 failureThreshold: 3 diff --git a/charts/docker-mailserver/values.yaml b/charts/docker-mailserver/values.yaml index 39f5cff0..960d59a5 100644 --- a/charts/docker-mailserver/values.yaml +++ b/charts/docker-mailserver/values.yaml @@ -369,7 +369,7 @@ rainloop: ## These values are for the haproxy sub-chart haproxy: # haproxy.enabled will deploy an haproxy sub-chart, configured for the TCP ports used by docker-mailserver - enabled: true + enabled: false controller: replicaCount: 1 kind: "Deployment" From 1fb454fce63ffc0cfd6664e1b6d41e766013d061 Mon Sep 17 00:00:00 2001 From: David Young Date: Mon, 11 May 2020 13:46:37 +1200 Subject: [PATCH 3/7] Bump to 0.2.4 with annotations and working ct tests --- TESTING.md | 5 +++++ charts/docker-mailserver/Chart.yaml | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/TESTING.md b/TESTING.md index 1c357f8a..9ea1bb84 100644 --- a/TESTING.md +++ b/TESTING.md @@ -7,6 +7,11 @@ Every pull request to the master branch trigger the following tests: * ct lint * ct install + +[![Linting](https://github.com/funkypenguin/helm-docker-mailserver/workflows/Linting/badge.svg)](.github/workflows/on-pr-lint-charts.yml) +[![Testing](https://github.com/funkypenguin/helm-docker-mailserver/workflows/Testing/badge.svg)](.github/workflows/on-pr-test-charts.yml) + + # Local testing If you're submitting a PR, and you want to ensure your changes will pass automated testing (above), here are your options: diff --git a/charts/docker-mailserver/Chart.yaml b/charts/docker-mailserver/Chart.yaml index f4661287..97edc7d1 100644 --- a/charts/docker-mailserver/Chart.yaml +++ b/charts/docker-mailserver/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v1 appVersion: "6.3.0" description: A fullstack but simple mailserver (smtp, imap, antispam, antivirus, ssl...) using Docker. name: docker-mailserver -version: 0.2.4-pre3 +version: 0.2.4 sources: - https://github.com/funkypenguin/helm-docker-mailserver maintainers: From 491558fc0cb6e2150f9442f66c38b01b020145f4 Mon Sep 17 00:00:00 2001 From: David Young Date: Mon, 11 May 2020 13:49:56 +1200 Subject: [PATCH 4/7] Use latest version of chart-testing action --- .github/workflows/on-pr-lint-charts.yml | 4 ++-- .github/workflows/on-pr-test-charts.yml | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/on-pr-lint-charts.yml b/.github/workflows/on-pr-lint-charts.yml index 0d315f4a..b3eeed6e 100644 --- a/.github/workflows/on-pr-lint-charts.yml +++ b/.github/workflows/on-pr-lint-charts.yml @@ -7,7 +7,7 @@ on: - '.github/**' jobs: - lint-test: + ct-lint: runs-on: ubuntu-latest steps: - name: Checkout @@ -15,7 +15,7 @@ jobs: - name: Run chart-testing (lint) id: lint - uses: helm/chart-testing-action@v1.0.0-rc.1 + uses: helm/chart-testing-action@v3 with: config: .ci/ct-config.yaml command: lint \ No newline at end of file diff --git a/.github/workflows/on-pr-test-charts.yml b/.github/workflows/on-pr-test-charts.yml index 86bc39a0..441f17ae 100644 --- a/.github/workflows/on-pr-test-charts.yml +++ b/.github/workflows/on-pr-test-charts.yml @@ -7,7 +7,7 @@ on: - '.github/**' jobs: - lint-test: + ct-test: runs-on: ubuntu-latest steps: - name: Checkout @@ -15,20 +15,20 @@ jobs: - name: Run chart-testing (lint) id: lint - uses: helm/chart-testing-action@v1.0.0-rc.1 + uses: helm/chart-testing-action@v3 with: config: .ci/ct-config.yaml command: lint - name: Create kind cluster - uses: helm/kind-action@v1.0.0-alpha.3 + uses: helm/kind-action@v3 with: install_local_path_provisioner: true # Only build a kind cluster if there are chart changes to test. if: steps.lint.outputs.changed == 'true' - name: Run chart-testing (install) - uses: helm/chart-testing-action@v1.0.0-rc.1 + uses: helm/chart-testing-action@v3 with: command: install config: .ci/ct-config.yaml From 405499a3f57cfb513ef702e4ebe628f5d1e49a5b Mon Sep 17 00:00:00 2001 From: David Young Date: Mon, 11 May 2020 13:53:25 +1200 Subject: [PATCH 5/7] Add a dispatcher to trigger a helm repo update --- .../on-push-master-publish-chart.yml | 22 ++++++------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/.github/workflows/on-push-master-publish-chart.yml b/.github/workflows/on-push-master-publish-chart.yml index fefb2601..40116669 100644 --- a/.github/workflows/on-push-master-publish-chart.yml +++ b/.github/workflows/on-push-master-publish-chart.yml @@ -36,18 +36,10 @@ jobs: env: CR_TOKEN: "${{ secrets.CR_TOKEN }}" - # - name: Discord notification - # env: - # DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} - # uses: Ilshidur/action-discord@master - # with: - # args: | - # Greetings, geeks! 🤓 - - # A new/updated helm ⎈ chart is fresh out of the oven! - - # Here's what's changed: - # > ${{github.event.commits[0].message}} - - # Get more details at: - # {{ EVENT_PAYLOAD.compare }} \ No newline at end of file + - name: Emit repository_dispatch + uses: mvasigh/dispatch-action@master + with: + token: ${{ secrets.CR_TOKEN }} + repo: charts + owner: geek-cookbook + event_type: chart_update \ No newline at end of file From e20fadcf8f8c08d31fcc572129ee28df95ae1c89 Mon Sep 17 00:00:00 2001 From: David Young Date: Mon, 11 May 2020 13:58:23 +1200 Subject: [PATCH 6/7] Un-break the chart-testing action --- .github/workflows/on-pr-lint-charts.yml | 2 +- .github/workflows/on-pr-test-charts.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/on-pr-lint-charts.yml b/.github/workflows/on-pr-lint-charts.yml index b3eeed6e..b3bed579 100644 --- a/.github/workflows/on-pr-lint-charts.yml +++ b/.github/workflows/on-pr-lint-charts.yml @@ -15,7 +15,7 @@ jobs: - name: Run chart-testing (lint) id: lint - uses: helm/chart-testing-action@v3 + uses: helm/chart-testing-action@v1.0.0-rc.2 with: config: .ci/ct-config.yaml command: lint \ No newline at end of file diff --git a/.github/workflows/on-pr-test-charts.yml b/.github/workflows/on-pr-test-charts.yml index 441f17ae..3b40460e 100644 --- a/.github/workflows/on-pr-test-charts.yml +++ b/.github/workflows/on-pr-test-charts.yml @@ -15,7 +15,7 @@ jobs: - name: Run chart-testing (lint) id: lint - uses: helm/chart-testing-action@v3 + uses: helm/chart-testing-action@v1.0.0-rc.2 with: config: .ci/ct-config.yaml command: lint @@ -28,7 +28,7 @@ jobs: if: steps.lint.outputs.changed == 'true' - name: Run chart-testing (install) - uses: helm/chart-testing-action@v3 + uses: helm/chart-testing-action@v1.0.0-rc.2 with: command: install config: .ci/ct-config.yaml From cd6d96683d21fbef95b10146e803f4c1cf25c4fd Mon Sep 17 00:00:00 2001 From: David Young Date: Mon, 11 May 2020 14:02:05 +1200 Subject: [PATCH 7/7] Moar fixing --- .github/workflows/on-pr-test-charts.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/on-pr-test-charts.yml b/.github/workflows/on-pr-test-charts.yml index 3b40460e..c22bfd16 100644 --- a/.github/workflows/on-pr-test-charts.yml +++ b/.github/workflows/on-pr-test-charts.yml @@ -21,7 +21,7 @@ jobs: command: lint - name: Create kind cluster - uses: helm/kind-action@v3 + uses: helm/kind-action@v1.0.0-rc.1 with: install_local_path_provisioner: true # Only build a kind cluster if there are chart changes to test.