Skip to content
This repository has been archived by the owner on Jun 4, 2024. It is now read-only.

Helm chart for acces-plugin-email #459

Merged
merged 20 commits into from
Mar 31, 2022
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .cloudbuild/ci/helm-unittest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
steps:
- name: 'alpine/helm'
entrypoint: /bin/sh
args:
- -c
- |
apk add openssl curl bash git &&
helm plugin install https://github.com/vbehar/helm3-unittest &&
kbence marked this conversation as resolved.
Show resolved Hide resolved
helm unittest ./charts/access/email
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,10 @@ update-tag:
lint: GO_LINT_FLAGS ?=
lint:
golangci-lint run -c .golangci.yml $(GO_LINT_FLAGS)

.PHONY: test-helm-access-email
test-helm-access-email:
helm unittest ./charts/access/email

.PHONY: test-helm
test-helm: test-helm-access-email
23 changes: 23 additions & 0 deletions charts/access/email/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
24 changes: 24 additions & 0 deletions charts/access/email/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: access-plugin-email
description: A Helm chart for Kubernetes

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like for this to hit 1.0.0 before we release to customers. It doesn't (and probably shouldn't) be there yet in this PR though.


# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "9.0.0"
133 changes: 133 additions & 0 deletions charts/access/email/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# Teleport Access Request Email Plugin

This chart sets up and configures a Deployment for the Access Request Email plugin.

## Settings

The following values can be set for the Helm chart:

<table>
<tr>
<th>Name</th>
<th>Description</th>
<th>Type</th>
<th>Default</th>
<th>Required</th>
</tr>

<tr>
<td><code>teleport.address</code></td>
<td>Host/port combination of the teleport auth server</td>
<td>string</td>
<td><code>""</code></td>
<td>yes</td>
</tr>
<tr>
<td><code>teleport.identitySecretName</code></td>
<td>Name of the Kubernetes secret that contains the credentials for the connection</td>
<td>string</td>
<td><code>""</code></td>
</tr>
<tr>
<td><code>teleport.identitySecretPath</code></td>
<td>Key of the field in the secret specified by <code>teleport.identitySecretName</code></td>
<td>string</td>
<td><code>"auth_id"</code></td>
</tr>

<tr>
<td><code>mailgun.enabled</code></td>
<td>
Specifies if the Mailgun integration should be enabled. Mutually exclusive with <code>smtp.enabled</code>.
In the case of both values are set to true, <code>mailgun.enabled</code> will take precedence.
</td>
<td>boolean</td>
<td><code>false</code></td>
</tr>
<tr>
<td><code>mailgun.domain</code></td>
<td>Domain name of the Mailgun instance</td>
<td>string</td>
<td><code>""</code></td>
</tr>
<tr>
<td><code>mailgun.privateKey</code></td>
<td>Private key for accessing the Mailgun instance</td>
<td>string</td>
<td><code>""</code></td>
</tr>

<tr>
<td><code>smtp.enabled</code></td>
<td>
Specifies if the MailSMTPgun integration should be enabled. Mutually exclusive with <code>mailgun.enabled</code>.
In the case of both values are set to true, <code>mailgun.enabled</code> will take precedence.
</td>
<td>boolean</td>
<td><code>false</code></td>
</tr>
<tr>
<td><code>smtp.host</code></td>
<td>SMTP host.</td>
<td>string</td>
<td><code>""</code></td>
</tr>
<tr>
<td><code>smtp.port</code></td>
<td>Port of the SMTP server.</td>
<td>integer</td>
<td><code>587</code></td>
</tr>
<tr>
<td><code>smtp.username</code></td>
<td>Username to be used with the SMTP server.</td>
<td>string</td>
<td><code>""</code></td>
</tr>
<tr>
<td><code>smtp.password</code></td>
<td>Password to be used with the SMTP server. Mutually exclusive with <code>smtp.passwordFile</code>.</td>
<td>string</td>
<td><code>""</code></td>
</tr>
<tr>
<td><code>smtp.passwordFile</code></td>
<td>
Path of the file that contains the password to be used with the SMTP server. Can be mounted via <code>volumes</code> and <code>volumeMounts</code>. Mutually exclusive with <code>smtp.password</code>.
</td>
<td>string</td>
<td><code>""</code></td>
</tr>

<tr>
<td><code>delivery.sender</code></td>
<td>Email address to be used in the <code>From</code> field of the emails.</td>
<td>string</td>
<td><code>""</code></td>
</tr>
<tr>
<td><code>delivery.recipients</code></td>
<td>Array of the recipients the plugin should send emails.</td>
<td>array</td>
<td><code>[]</code></td>
</tr>

<tr>
<td><code>log.output</code></td>
<td>
Logger output. Could be <code>"stdout"</code>, <code>"stderr"</code> or a file name,
eg. <code>"/var/lib/teleport/gitlab.log"</code>
</td>
<td>string</td>
<td><code>"stdout"</code></td>
</tr>
<tr>
<td><code>log.severity</code></td>
<td>
Logger severity. Possible values are <code>"INFO"</code>, <code>"ERROR"</code>,
<code>"DEBUG"</code> or <code>"WARN"</code>.
</td>
<td>string</td>
<td><code>"INFO"</code></td>
</tr>
</table>
62 changes: 62 additions & 0 deletions charts/access/email/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "email.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "email.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "email.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "email.labels" -}}
helm.sh/chart: {{ include "email.chart" . }}
{{ include "email.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "email.selectorLabels" -}}
app.kubernetes.io/name: {{ include "email.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "email.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "email.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
35 changes: 35 additions & 0 deletions charts/access/email/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "email.fullname" . }}
labels:
{{- include "email.labels" . | nindent 4 }}
data:
teleport-email.toml: |
[teleport]
wadells marked this conversation as resolved.
Show resolved Hide resolved
addr = "{{ .Values.teleport.address }}"
identity = "/var/lib/teleport/plugins/email/auth_id"

{{ if .Values.mailgun.enabled }}
[mailgun]
domain = "{{ .Values.mailgun.domain }}"
private_key = "{{ .Values.mailgun.privateKey }}"
{{ else if .Values.smtp.enabled }}
[smtp]
host = "{{ .Values.smtp.host }}"
port = {{ .Values.smtp.port }}
username = "{{ .Values.smtp.username }}"
{{ if eq .Values.smtp.passwordFile "" -}}
password = "{{ .Values.smtp.password }}"
{{ else -}}
password_file = "{{ .Values.smtp.passwordFile }}"
wadells marked this conversation as resolved.
Show resolved Hide resolved
{{ end }}
{{ end -}}

[delivery]
sender = "{{ .Values.delivery.sender }}"
recipients = {{ .Values.delivery.recipients | toJson }}

[log]
output = "{{ .Values.log.output }}"
severity = "{{ .Values.log.severity }}"
77 changes: 77 additions & 0 deletions charts/access/email/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "email.fullname" . }}
labels:
{{- include "email.labels" . | nindent 4 }}
spec:
replicas: 1
selector:
matchLabels:
{{- include "email.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "email.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
command:
- /usr/local/bin/teleport-plugin
- start
- "--config"
- "/etc/teleport-email.toml"
ports:
- name: http
containerPort: 80
protocol: TCP
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:
- name: config
mountPath: /etc/teleport-email.toml
subPath: teleport-email.toml
- name: auth-id
mountPath: /var/lib/teleport/plugins/email/auth_id
subPath: {{ .Values.teleport.identitySecretPath }}
{{- with .Values.volumeMounts -}}
{{- toYaml . | nindent 12 }}
{{- end}}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- name: config
configMap:
name: {{ include "email.fullname" . }}
defaultMode: 0600
- name: auth-id
secret:
secretName: "{{ .Values.teleport.identitySecretName }}"
defaultMode: 0600
{{- with .Values.volumes -}}
{{- toYaml . | nindent 8 }}
{{- end }}
Loading