diff --git a/charts/postgres-backup/.helmignore b/charts/postgres-backup/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/postgres-backup/.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/postgres-backup/Chart.yaml b/charts/postgres-backup/Chart.yaml new file mode 100644 index 0000000..2da2aa0 --- /dev/null +++ b/charts/postgres-backup/Chart.yaml @@ -0,0 +1,23 @@ +apiVersion: v2 +name: postgres-backup +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.0.1 + +# 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. +appVersion: 0.0.1 diff --git a/charts/postgres-backup/templates/_helpers.tpl b/charts/postgres-backup/templates/_helpers.tpl new file mode 100644 index 0000000..e4676e5 --- /dev/null +++ b/charts/postgres-backup/templates/_helpers.tpl @@ -0,0 +1,63 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "postgres-backup.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 "postgres-backup.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 "postgres-backup.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "postgres-backup.labels" -}} +helm.sh/chart: {{ include "postgres-backup.chart" . }} +{{ include "postgres-backup.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "postgres-backup.selectorLabels" -}} +app.kubernetes.io/name: {{ include "postgres-backup.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "postgres-backup.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "postgres-backup.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/postgres-backup/templates/cronjob.yaml b/charts/postgres-backup/templates/cronjob.yaml new file mode 100644 index 0000000..4466a99 --- /dev/null +++ b/charts/postgres-backup/templates/cronjob.yaml @@ -0,0 +1,34 @@ +apiVersion: batch/v1beta1 +kind: CronJob +metadata: + name: {{ include "postgres-backup.fullname" . }} + labels: + {{- include "postgres-backup.labels" . | nindent 4 }} +spec: + suspend: {{ .Values.cronjob.suspend }} + schedule: {{ .Values.cronjob.schedule | quote }} + startingDeadlineSeconds: {{ .Values.cronjob.startingDeadlineSeconds }} + concurrencyPolicy: {{ .Values.cronjob.concurrencyPolicy }} + successfulJobsHistoryLimit: {{ .Values.cronjob.successfulJobsHistoryLimit }} + failedJobsHistoryLimit: {{ .Values.cronjob.failedJobsHistoryLimit }} + jobTemplate: + spec: + backoffLimit: {{ .Values.cronjob.job.backoffLimit }} + template: + spec: + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + env: + - name: NODE_ENV + value: production + {{- with .Values.cronjob.container.envFrom }} + envFrom: + {{- toYaml . | nindent 16 }} + {{- end }} + restartPolicy: {{ .Values.cronjob.container.restartPolicy }} + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 12 }} + {{- end }} diff --git a/charts/postgres-backup/values.yaml b/charts/postgres-backup/values.yaml new file mode 100644 index 0000000..d06cc88 --- /dev/null +++ b/charts/postgres-backup/values.yaml @@ -0,0 +1,26 @@ +# Default values for postgres-backup. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +image: + repository: ghcr.io/panzelva/postgres-backup + pullPolicy: Always + # Overrides the image tag whose default is the chart appVersion. + tag: "" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +cronjob: + schedule: "0 0 * * *" + startingDeadlineSeconds: 20 + concurrencyPolicy: Forbid + successfulJobsHistoryLimit: 3 + failedJobsHistoryLimit: 1 + suspend: false + job: + backoffLimit: 6 + container: + envFrom: null + restartPolicy: OnFailure