-
-
Notifications
You must be signed in to change notification settings - Fork 18
Add helm chart for cloudnative postgres #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
timetinytim
wants to merge
13
commits into
main
Choose a base branch
from
INF-309-add-cnpg
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 7 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
9243ec7
Add helm chart for cloudnative postgres
timetinytim 8e4c6b3
Cleanup whitespace
timetinytim 0584e64
Don't need to specify a name, helm does that for us
timetinytim 0102a99
No need to specify tag when appVersion does it
timetinytim 57f774d
Value fix
timetinytim 607c7eb
Fix storage
timetinytim 65348ed
Instances fix
timetinytim 7bd26a6
Rename chart
timetinytim 10625b2
Rename chart
timetinytim 11344a1
Allow superuser creds
timetinytim 2daae5b
Allow superuser creds
timetinytim 7c2358c
Fixed cluster naming bug
timetinytim 2ca9bd2
Retention policies for backups
timetinytim File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| apiVersion: v2 | ||
| name: cnpg | ||
| 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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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: {} | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather do it around 4:30am
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense, but I still think midnight is a good as a "default" chart value. We can just set it to 04:30 ourselves.