From 4d4eb33074d50bf70dcba4a2e8ab9d2427e71262 Mon Sep 17 00:00:00 2001 From: Fabio Rauber Date: Tue, 16 Aug 2022 11:05:07 -0300 Subject: [PATCH] Added new mail-mta-autoconfig chart --- charts/mail-mta-autoconfig/v0.1.0/.helmignore | 23 +++++++ charts/mail-mta-autoconfig/v0.1.0/Chart.yaml | 16 +++++ .../v0.1.0/templates/_helpers.tpl | 62 +++++++++++++++++++ .../v0.1.0/templates/cronjob.yaml | 38 ++++++++++++ .../v0.1.0/templates/rbac.yaml | 33 ++++++++++ .../v0.1.0/templates/serviceaccount.yaml | 12 ++++ charts/mail-mta-autoconfig/v0.1.0/values.yaml | 57 +++++++++++++++++ 7 files changed, 241 insertions(+) create mode 100644 charts/mail-mta-autoconfig/v0.1.0/.helmignore create mode 100644 charts/mail-mta-autoconfig/v0.1.0/Chart.yaml create mode 100644 charts/mail-mta-autoconfig/v0.1.0/templates/_helpers.tpl create mode 100644 charts/mail-mta-autoconfig/v0.1.0/templates/cronjob.yaml create mode 100644 charts/mail-mta-autoconfig/v0.1.0/templates/rbac.yaml create mode 100644 charts/mail-mta-autoconfig/v0.1.0/templates/serviceaccount.yaml create mode 100644 charts/mail-mta-autoconfig/v0.1.0/values.yaml diff --git a/charts/mail-mta-autoconfig/v0.1.0/.helmignore b/charts/mail-mta-autoconfig/v0.1.0/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/mail-mta-autoconfig/v0.1.0/.helmignore @@ -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/ diff --git a/charts/mail-mta-autoconfig/v0.1.0/Chart.yaml b/charts/mail-mta-autoconfig/v0.1.0/Chart.yaml new file mode 100644 index 0000000..d2faef3 --- /dev/null +++ b/charts/mail-mta-autoconfig/v0.1.0/Chart.yaml @@ -0,0 +1,16 @@ +apiVersion: v2 +name: mail-mta-autoconfig +description: Job to automatically configure DKIM Keys and DNS records. + +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 + +# 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: "0.1.0" diff --git a/charts/mail-mta-autoconfig/v0.1.0/templates/_helpers.tpl b/charts/mail-mta-autoconfig/v0.1.0/templates/_helpers.tpl new file mode 100644 index 0000000..f9f027f --- /dev/null +++ b/charts/mail-mta-autoconfig/v0.1.0/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "mail-mta-autoconfig.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 "mail-mta-autoconfig.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 "mail-mta-autoconfig.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "mail-mta-autoconfig.labels" -}} +helm.sh/chart: {{ include "mail-mta-autoconfig.chart" . }} +{{ include "mail-mta-autoconfig.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "mail-mta-autoconfig.selectorLabels" -}} +app.kubernetes.io/name: {{ include "mail-mta-autoconfig.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "mail-mta-autoconfig.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "mail-mta-autoconfig.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/mail-mta-autoconfig/v0.1.0/templates/cronjob.yaml b/charts/mail-mta-autoconfig/v0.1.0/templates/cronjob.yaml new file mode 100644 index 0000000..62647ec --- /dev/null +++ b/charts/mail-mta-autoconfig/v0.1.0/templates/cronjob.yaml @@ -0,0 +1,38 @@ +apiVersion: batch/v1beta1 +kind: CronJob +metadata: + name: {{ include "mail-mta-autoconfig.fullname" . }} + labels: + {{- include "mail-mta-autoconfig.labels" . | nindent 4 }} +spec: + # generate a random backup time between 1 and 5 AM + schedule: {{ .Values.schedule }} + concurrencyPolicy: Forbid + jobTemplate: + spec: + template: + metadata: + labels: + {{- include "mail-mta-autoconfig.selectorLabels" . | nindent 12 }} + spec: + serviceAccountName: {{ include "mail-mta-autoconfig.serviceAccountName" . }} + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 12 }} + {{- end }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 12 }} + containers: + - name: {{ .Release.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + command: [ "python3", "watch.py" ] + restartPolicy: OnFailure + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 12 }} + {{- end }} diff --git a/charts/mail-mta-autoconfig/v0.1.0/templates/rbac.yaml b/charts/mail-mta-autoconfig/v0.1.0/templates/rbac.yaml new file mode 100644 index 0000000..9f86165 --- /dev/null +++ b/charts/mail-mta-autoconfig/v0.1.0/templates/rbac.yaml @@ -0,0 +1,33 @@ +{{ if .Values.rbac.create }} +# This role is used to allow mail-mta-autoconfig to get namespaces and patch PVCs +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: {{ .Release.Name }}-role + labels: + {{- include "mail-mta-autoconfig.labels" . | nindent 4 }} +rules: +- apiGroups: [""] + resources: + - namespaces + - pods + - services + verbs: ["get", "list", "watch"] + +--- +# We bind the role to the mail-mta-autoconfig ServiceAccount +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: {{ .Release.Name }}-binding + labels: + {{- include "mail-mta-autoconfig.labels" . | nindent 4 }} +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: {{ .Release.Name }}-role +subjects: +- kind: ServiceAccount + name: {{ include "mail-mta-autoconfig.serviceAccountName" . }} + namespace: {{ .Release.Namespace }} +{{ end }} \ No newline at end of file diff --git a/charts/mail-mta-autoconfig/v0.1.0/templates/serviceaccount.yaml b/charts/mail-mta-autoconfig/v0.1.0/templates/serviceaccount.yaml new file mode 100644 index 0000000..c2c06b6 --- /dev/null +++ b/charts/mail-mta-autoconfig/v0.1.0/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "mail-mta-autoconfig.serviceAccountName" . }} + labels: + {{- include "mail-mta-autoconfig.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/charts/mail-mta-autoconfig/v0.1.0/values.yaml b/charts/mail-mta-autoconfig/v0.1.0/values.yaml new file mode 100644 index 0000000..4767d34 --- /dev/null +++ b/charts/mail-mta-autoconfig/v0.1.0/values.yaml @@ -0,0 +1,57 @@ +# Default values for mail-mta-autoconfig. + +image: + repository: porto.interlegis.leg.br/library/mail-mta-autoconfig + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: true + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +rbac: + create: true + +podAnnotations: {} + +podSecurityContext: {} + # fsGroup: 2000 + +# Defaults to midnight +schedule: "0 0 * * *" + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +nodeSelector: {} + +tolerations: [] + +affinity: {}