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..b3bed579 --- /dev/null +++ b/.github/workflows/on-pr-lint-charts.yml @@ -0,0 +1,21 @@ +name: Linting + +on: + pull_request: + paths: + - 'charts/**' + - '.github/**' + +jobs: + ct-lint: + 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.2 + 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 76% rename from .github/workflows/on-push-lint-charts.yml rename to .github/workflows/on-pr-test-charts.yml index 334d6162..c22bfd16 100644 --- a/.github/workflows/on-push-lint-charts.yml +++ b/.github/workflows/on-pr-test-charts.yml @@ -1,13 +1,13 @@ -name: Lint and Test Charts +name: Testing on: - push: + pull_request: paths: - 'charts/**' - '.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@v1.0.0-rc.2 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@v1.0.0-rc.1 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@v1.0.0-rc.2 with: command: install config: .ci/ct-config.yaml diff --git a/.github/workflows/on-push-master-publish-chart.yml b/.github/workflows/on-push-master-publish-chart.yml index 7ce50923..40116669 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 @@ -49,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 diff --git a/TESTING.md b/TESTING.md new file mode 100644 index 00000000..9ea1bb84 --- /dev/null +++ b/TESTING.md @@ -0,0 +1,61 @@ +# How this chart is tested + +# Automated tests + +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: + +## 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/Chart.yaml b/charts/docker-mailserver/Chart.yaml index f2f5b40c..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-pre2 +version: 0.2.4 sources: - https://github.com/funkypenguin/helm-docker-mailserver maintainers: 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 b701dece..f829019e 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: @@ -138,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 919a7788..960d59a5 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: @@ -363,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"