Skip to content

Commit

Permalink
Merge pull request #22 from funkypenguin/add-deployment-annotations
Browse files Browse the repository at this point in the history
Add deployment annotation
  • Loading branch information
funkypenguin authored May 11, 2020
2 parents 9805800 + cd6d966 commit 4162e81
Show file tree
Hide file tree
Showing 9 changed files with 113 additions and 42 deletions.
2 changes: 1 addition & 1 deletion .ci/ct-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
21 changes: 21 additions & 0 deletions .github/workflows/on-pr-lint-charts.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
with:
config: .ci/ct-config.yaml
command: lint
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
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
uses: actions/checkout@v1

- name: Run chart-testing (lint)
id: lint
uses: helm/[email protected].1
uses: helm/[email protected].2
with:
config: .ci/ct-config.yaml
command: lint

- name: Create kind cluster
uses: helm/[email protected]alpha.3
uses: helm/[email protected]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/[email protected].1
uses: helm/[email protected].2
with:
command: install
config: .ci/ct-config.yaml
35 changes: 7 additions & 28 deletions .github/workflows/on-push-master-publish-chart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
# 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
Expand All @@ -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 }}
- name: Emit repository_dispatch
uses: mvasigh/dispatch-action@master
with:
token: ${{ secrets.CR_TOKEN }}
repo: charts
owner: geek-cookbook
event_type: chart_update
61 changes: 61 additions & 0 deletions TESTING.md
Original file line number Diff line number Diff line change
@@ -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`.
2 changes: 1 addition & 1 deletion charts/docker-mailserver/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 8 additions & 4 deletions charts/docker-mailserver/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion charts/docker-mailserver/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 4162e81

Please sign in to comment.