Skip to content

Commit adc556b

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 6e1fed6 + cf584ea commit adc556b

27 files changed

+349
-390
lines changed

.ci/ct-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
chart-repos:
55
- haproxy=https://haproxytech.github.io/helm-charts
66

7-
lint-conf: .ci/lint-config.yaml
7+
lint-conf: .ci/lint-config.yaml

.ci/scripts/local-ci.sh

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

.ci/scripts/local-ct-lint.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
docker run --rm -it -w /repo -v $(pwd):/repo quay.io/helmpack/chart-testing ct lint --all --config .ci/ct-config.yaml

.ci/scripts/local-kube-score.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
4+
for chart in `ls charts`;
5+
do
6+
helm template --values charts/$chart/ci/ci-values.yaml charts/$chart | kube-score score - \
7+
--ignore-test pod-networkpolicy \
8+
--ignore-test deployment-has-poddisruptionbudget \
9+
--ignore-test deployment-has-host-podantiaffinity \
10+
--ignore-test pod-probes \
11+
--ignore-test container-image-tag \
12+
--enable-optional-test container-security-context-privileged \
13+
--ignore-test container-security-context
14+
done
Lines changed: 79 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,95 @@
11
name: Lint and Test Charts
22

3-
on:
4-
push:
3+
on:
4+
# push:
5+
# paths:
6+
# - 'charts/**'
7+
# - '.github/**'
8+
pull_request:
59
paths:
610
- 'charts/**'
7-
- '.github/**'
11+
- '.github/**'
12+
workflow_dispatch:
13+
14+
env:
15+
KUBE_SCORE_VERSION: 1.10.0
16+
HELM_VERSION: v3.4.1
817

918
jobs:
1019
lint-test:
1120
runs-on: ubuntu-latest
1221
steps:
1322
- name: Checkout
14-
uses: actions/checkout@v1
15-
23+
uses: actions/checkout@v2
24+
with:
25+
fetch-depth: 0
26+
27+
- name: Set up Helm
28+
uses: azure/setup-helm@v1
29+
with:
30+
version: ${{ env.HELM_VERSION }}
31+
32+
- name: Set up kube-score
33+
run: |
34+
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
35+
chmod 755 kube-score
36+
37+
- name: Kube-score generated manifests
38+
run: helm template --values .ci/values-kube-score.yaml charts/* | ./kube-score score -
39+
--ignore-test pod-networkpolicy
40+
--ignore-test deployment-has-poddisruptionbudget
41+
--ignore-test deployment-has-host-podantiaffinity
42+
--ignore-test container-security-context
43+
--ignore-test pod-probes
44+
--ignore-test container-image-tag
45+
--enable-optional-test container-security-context-privileged
46+
47+
# python is a requirement for the chart-testing action below (supports yamllint among other tests)
48+
- uses: actions/setup-python@v2
49+
with:
50+
python-version: 3.7
51+
52+
- name: Set up chart-testing
53+
uses: helm/chart-testing-action@v2.0.1
54+
55+
- name: Run chart-testing (list-changed)
56+
id: list-changed
57+
run: |
58+
changed=$(ct list-changed --config .ci/ct-config.yaml)
59+
if [[ -n "$changed" ]]; then
60+
echo "::set-output name=changed::true"
61+
fi
62+
1663
- name: Run chart-testing (lint)
17-
id: lint
18-
uses: helm/chart-testing-action@v1.0.0-rc.1
64+
run: ct lint --config .ci/ct-config.yaml
65+
66+
# Refer to https://github.com/kubernetes-sigs/kind/releases when updating the node_images
67+
- name: Create 1.20 kind cluster
68+
uses: helm/kind-action@v1.1.0
1969
with:
20-
config: .ci/ct-config.yaml
21-
command: lint
70+
node_image: kindest/node:v1.20.2@sha256:8f7ea6e7642c0da54f04a7ee10431549c0257315b3a634f6ef2fecaaedb19bab
71+
cluster_name: kubernetes-1.20
72+
if: steps.list-changed.outputs.changed == 'true'
2273

23-
- name: Create kind cluster
24-
uses: helm/kind-action@v1.0.0-alpha.3
74+
- name: Run chart-testing (install) against 1.20
75+
run: ct install --config .ci/ct-config.yaml
76+
77+
- name: Create 1.19 kind cluster
78+
uses: helm/kind-action@v1.1.0
2579
with:
26-
install_local_path_provisioner: true
27-
# Only build a kind cluster if there are chart changes to test.
28-
if: steps.lint.outputs.changed == 'true'
80+
node_image: kindest/node:v1.19.7@sha256:a70639454e97a4b733f9d9b67e12c01f6b0297449d5b9cbbef87473458e26dca
81+
cluster_name: kubernetes-1.19
82+
if: steps.list-changed.outputs.changed == 'true'
83+
84+
- name: Run chart-testing (install) against 1.19
85+
run: ct install --config .ci/ct-config.yaml
2986

30-
- name: Run chart-testing (install)
31-
uses: helm/chart-testing-action@v1.0.0-rc.1
87+
- name: Create 1.18 kind cluster
88+
uses: helm/kind-action@v1.1.0
3289
with:
33-
command: install
34-
config: .ci/ct-config.yaml
90+
node_image: kindest/node:v1.18.15@sha256:5c1b980c4d0e0e8e7eb9f36f7df525d079a96169c8a8f20d8bd108c0d0889cc4
91+
cluster_name: kubernetes-1.18
92+
if: steps.list-changed.outputs.changed == 'true'
93+
94+
- name: Run chart-testing (install) against 1.18
95+
run: ct install --config .ci/ct-config.yaml

.github/workflows/on-push-master-publish-chart.yml

Lines changed: 23 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -4,63 +4,35 @@ on:
44
push:
55
branches:
66
- master
7+
- main # assume that the branch name may change in future
78
paths:
89
- 'charts/**'
9-
- '.github/**'
10+
- '.github/**'
11+
workflow_dispatch:
1012

1113
jobs:
12-
build:
14+
publish-chart:
1315

1416
runs-on: ubuntu-latest
1517

1618
steps:
17-
- uses: actions/checkout@v2
18-
# - uses: azure/setup-helm@v1
19-
# id: installhelm3
20-
# with:
21-
# version: 'v3.0.3'
22-
# - name: Publish helm charts
23-
# uses: funkypenguin/helm-gh-pages-action@v1.1.1
24-
# with:
25-
# # A personal access token needed to push your site after it has been built.
26-
# access-token: ${{ secrets.CR_TOKEN }}
27-
# # The branch expected by GitHub to have the static files needed for your site.
28-
# deploy-branch: chart
29-
# # The folder in which the helm charts are located
30-
# charts-folder: charts
19+
- name: Checkout
20+
uses: actions/checkout@v2
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Configure Git
25+
run: |
26+
git config user.name "$GITHUB_ACTOR"
27+
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
28+
29+
# We need cert-manager already installed in the cluster because we assume the CRDs exist
30+
- name: Add haproxy repo
31+
run: |
32+
helm repo add haprox https://haproxytech.github.io/helm-charts --force-update
33+
34+
- name: Run chart-releaser
35+
uses: helm/chart-releaser-action@v1.1.0
36+
env:
37+
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
3138

32-
- name: Fetch history
33-
run: git fetch --prune --unshallow
34-
35-
- name: Configure Git
36-
run: |
37-
git config user.name "$GITHUB_ACTOR"
38-
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
39-
40-
# See https://github.com/helm/chart-releaser-action/issues/6
41-
- name: Install Helm
42-
run: |
43-
curl -fsSLo get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
44-
chmod 700 get_helm.sh
45-
./get_helm.sh
46-
47-
- name: Run chart-releaser
48-
uses: helm/chart-releaser-action@v1.0.0-rc.2
49-
env:
50-
CR_TOKEN: "${{ secrets.CR_TOKEN }}"
51-
52-
# - name: Discord notification
53-
# env:
54-
# DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
55-
# uses: Ilshidur/action-discord@master
56-
# with:
57-
# args: |
58-
# Greetings, geeks! 🤓
59-
60-
# A new/updated helm ⎈ chart is fresh out of the oven!
61-
62-
# Here's what's changed:
63-
# > ${{github.event.commits[0].message}}
64-
65-
# Get more details at:
66-
# {{ EVENT_PAYLOAD.compare }}

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ The chart includes the following features:
4141

4242
* All configuration is done in values.yaml, or using the native "setup.sh" script (to create mailboxes or DKIM keys)
4343
* Avoids the [common problem of masking of source IP](https://kubernetes.io/docs/tutorials/services/source-ip/) by supporting haproxy's PROXY protocol (enabled by default)
44-
* Supports integration with external HAProxy, HAProxy Ingress Controller, or [poor-mans-k8s-lb](https://www.funkypenguin.co.nz/project/a-simple-free-load-balancer-for-your-kubernetes-cluster/)
4544
* Employs [cert-manager](https://github.com/jetstack/cert-manager) to automatically provide/renew SSL certificates
46-
* Bundles in [RainLoop](https://www.rainloop.net) for webmail access (enabled by default)
45+
* Bundles in [RainLoop](https://www.rainloop.net) for webmail access (disabled by default)
4746
* Starts in "demo" mode, allowing the user to test core functionality before configuring for specific domains
48-
47+
* CI/CD tested against Kubernetes 1.18,1.19, and 1.20 : ![Lint and Test Charts](https://github.com/funkypenguin/helm-docker-mailserver/workflows/Lint%20and%20Test%20Charts/badge.svg)
48+
*
4949
## Prerequisites
5050

51-
- Kubernetes 1.5+ (*CI validates against 1.12.0*)
51+
- Kubernetes 1.16+ (*CI validates against > 1.18.0*)
5252
- To use HAProxy ingress, you'll need to deploying the chart to a cluster with a cloud provider capable of provisioning an
5353
external load balancer (e.g. AWS, DO or GKE). (There is an [update planned](https://github.com/funkypenguin/docker-mailserver/issues/5) to support HA ingress on bare-metal deployments)
5454
- You control DNS for the domain(s) you intend to route through Traefik

TESTING.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# How this chart is tested
2+
3+
# Automated tests
4+
5+
Every pull request to the master branch trigger the following tests:
6+
7+
* ct lint
8+
* ct install
9+
10+
11+
[![Linting](https://github.com/funkypenguin/helm-docker-mailserver/workflows/Linting/badge.svg)](.github/workflows/on-pr-lint-charts.yml)
12+
[![Testing](https://github.com/funkypenguin/helm-docker-mailserver/workflows/Testing/badge.svg)](.github/workflows/on-pr-test-charts.yml)
13+
14+
15+
# Local testing
16+
17+
If you're submitting a PR, and you want to ensure your changes will pass automated testing (above), here are your options:
18+
19+
## Linting
20+
21+
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.
22+
23+
To run in Docker:
24+
25+
1. Have Docker installed
26+
2. Run `./ci/scripts/local-lint`
27+
28+
To run locally:
29+
30+
1. Have ct installed (Get a binary package from https://github.com/helm/chart-testing/releases)
31+
2. Run `ct lint --config=.ci/ct-config.yaml`
32+
33+
## Deployment testing
34+
35+
*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".
36+
37+
38+
39+
40+
ct lint --config=.ci/ct-config.yaml
41+
42+
Create a KinD cluster, by running `kind create cluster`:
43+
44+
```
45+
❯ kind create cluster
46+
Creating cluster "kind" ...
47+
✓ Ensuring node image (kindest/node:v1.17.0) 🖼
48+
✓ Preparing nodes 📦
49+
✓ Writing configuration 📜
50+
✓ Starting control-plane 🕹️
51+
✓ Installing CNI 🔌
52+
✓ Installing StorageClass 💾
53+
Set kubectl context to "kind-kind"
54+
You can now use your cluster with:
55+
56+
kubectl cluster-info --context kind-kind
57+
58+
Have a nice day! 👋
59+
```
60+
61+
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`.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
dependencies:
2+
- name: kubernetes-ingress
3+
repository: https://haproxytech.github.io/helm-charts
4+
version: 1.1.3
5+
digest: sha256:4676741dfbd0f8ba12d3eec6664a104f37ef512b606ac8a125e238893864251e
6+
generated: "2021-02-01T21:13:01.7790873Z"
Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
apiVersion: v1
2-
appVersion: "6.3.0"
1+
apiVersion: v2
2+
appVersion: "8.0.1"
33
description: A fullstack but simple mailserver (smtp, imap, antispam, antivirus, ssl...) using Docker.
44
name: docker-mailserver
5-
version: 0.2.4-pre1
5+
version: 0.3.0
66
sources:
77
- https://github.com/funkypenguin/helm-docker-mailserver
88
maintainers:
@@ -14,4 +14,12 @@ keywords:
1414
- dovecot
1515
- amavis
1616
- imap
17-
home: https://github.com/funkypenguin/helm-docker-mailserver
17+
home: https://github.com/funkypenguin/helm-docker-mailserver
18+
icon: https://avatars.githubusercontent.com/u/76868633?s=400&v=4
19+
20+
dependencies:
21+
- name: "kubernetes-ingress"
22+
version: "1.1.3"
23+
repository: "https://haproxytech.github.io/helm-charts"
24+
condition: haproxy.enabled
25+
alias: "haproxy"

0 commit comments

Comments
 (0)