Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
23 changes: 23 additions & 0 deletions charts/cnpg-mastodon-deploy/.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/cnpg-mastodon-deploy/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: cnpg-mastodon-deploy
description: A deployment of a Cloudnative PostgreSQL cluster for Mastodon.

# 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

# 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: "17.5"
56 changes: 56 additions & 0 deletions charts/cnpg-mastodon-deploy/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "cnpg.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 "cnpg.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 "cnpg.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

{{/*
Object store name
*/}}
{{- define "cnpg.store.name"}}
{{- printf "%s-store" (include "cnpg.fullname" .) }}
{{- end }}

{{/*
Cluster backup name
*/}}
{{- define "cnpg.backup.name"}}
{{- printf "%s-backup" (include "cnpg.fullname" .) }}
{{- end }}
35 changes: 35 additions & 0 deletions charts/cnpg-mastodon-deploy/templates/cluster.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
name: {{ include "cnpg.fullname" . }}
labels:
{{- include "cnpg.labels" . | nindent 4 }}
{{- with .Values.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
instances: {{ .Values.instances }}
imageName: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
{{- if eq .Values.backup.method "plugin" }}
plugins:
- name: barman-cloud.cloudnative-pg.io
isWALArchiver: true
parameters:
barmanObjectName: {{ include "cnpg.store.name" . }}
{{- end }}
bootstrap:
initdb:
database: {{ .Values.cluster.dbname }}
owner: {{ .Values.cluster.owner }}
secret:
name: {{ .Values.cluster.secret }}
postInitSQL:
- CREATE DATABASE {{ .Values.cluster.dbname }} OWNER {{ .Values.cluster.owner }}
storage:
size: {{ .Values.cluster.storage }}
monitoring:
enablePodMonitor: true
affinity:
{{- with .Values.affinity }}
{{- toYaml . | nindent 4 }}
{{- end }}
24 changes: 24 additions & 0 deletions charts/cnpg-mastodon-deploy/templates/object-store.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{{- if eq .Values.backup.method "plugin" }}
apiVersion: barmancloud.cnpg.io/v1
kind: ObjectStore
metadata:
name: {{ include "cnpg.store.name" . }}
labels:
{{- include "cnpg.labels" . | nindent 4 }}
{{- with .Values.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
configuration:
destinationPath: {{ .Values.backup.objectStore.destinationPath }}
endpointURL: {{ .Values.backup.objectStore.endpointUrl }}
s3Credentials:
accessKeyId:
name: {{ .Values.backup.objectStore.s3Credentials }}
key: ACCESS_KEY_ID
secretAccessKey:
name: {{ .Values.backup.objectStore.s3Credentials }}
key: ACCESS_SECRET_KEY
wal:
compression: gzip
{{- end }}
19 changes: 19 additions & 0 deletions charts/cnpg-mastodon-deploy/templates/scheduled-backup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: postgresql.cnpg.io/v1
kind: ScheduledBackup
metadata:
name: {{ include "cnpg.backup.name" . }}
labels:
{{- include "cnpg.labels" . | nindent 4 }}
{{- with .Values.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
schedule: {{ .Values.backup.schedule }}
backupOwnerReference: self
cluster:
name: {{ .Values.cluster.name }}
method: {{ .Values.backup.method }}
{{- if eq .Values.backup.method "plugin" }}
pluginConfiguration:
name: barman-cloud.cloudnative-pg.io
{{- end }}
49 changes: 49 additions & 0 deletions charts/cnpg-mastodon-deploy/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Default values for cnpg.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

# Number of postgres instances to create for this cluster.
instances: 2

# Postgres image to use for the cluster.
image:
repository: ghcr.io/cloudnative-pg/postgresql
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: ""

nameOverride: ""
fullnameOverride: ""

# Configuration for the postgres cluster itself
cluster:

# Database name and owner
dbname: mastodon
owner: mastodon
# Secret contains the user credentials (must be kubernetes.io/basic-auth)
secret: postgres-auth

# Volume size for the cluster pods
storage: 25Gi

# Configuration for cluster backup
backup:
method: plugin
schedule: "0 0 0 * * *" # At midnight every day

# If using 'method: plugin', these need to be filled out
objectStore:
destinationPath:
endpointUrl:

# Secret where S3 credentials are stored, must be in the form:
# ACCESS_KEY_ID: xxxxxxx
# ACCESS_SECRET_KEY: xxxxxxx
# ACCESS_SESSION_TOKEN: xxxxxxx # if required
s3Credentials: s3-credentials

# Additional labels to add to all resources
labels: {}

affinity: {}