-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This also comments out pitr postgres, even thogh that application is fainling because of helm version upgrade resolving that is taking sometime. I will push another PR to add that in test apps once that is fixed.
- Loading branch information
1 parent
e1dd7e7
commit aacad92
Showing
4 changed files
with
88 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
83 changes: 83 additions & 0 deletions
83
examples/stable/postgresql/v10.16.2/postgres-blueprint.yaml
This file contains 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,83 @@ | ||
apiVersion: cr.kanister.io/v1alpha1 | ||
kind: Blueprint | ||
metadata: | ||
name: postgres-bp | ||
actions: | ||
backup: | ||
kind: StatefulSet | ||
outputArtifacts: | ||
cloudObject: | ||
keyValue: | ||
backupLocation: "{{ .Phases.pgDump.Output.backupLocation }}" | ||
phases: | ||
- func: KubeTask | ||
name: pgDump | ||
objects: | ||
pgSecret: | ||
kind: Secret | ||
name: '{{ index .Object.metadata.labels "app.kubernetes.io/instance" }}-postgresql' | ||
namespace: '{{ .StatefulSet.Namespace }}' | ||
args: | ||
image: ghcr.io/kanisterio/postgres-kanister-tools:0.72.0 | ||
namespace: '{{ .StatefulSet.Namespace }}' | ||
command: | ||
- bash | ||
- -o | ||
- errexit | ||
- -o | ||
- pipefail | ||
- -c | ||
- | | ||
export PGHOST='{{ index .Object.metadata.labels "app.kubernetes.io/instance" }}-postgresql.{{ .StatefulSet.Namespace }}.svc.cluster.local' | ||
export PGUSER='postgres' | ||
export PGPASSWORD='{{ index .Phases.pgDump.Secrets.pgSecret.Data "postgresql-password" | toString }}' | ||
BACKUP_LOCATION=pg_backups/{{ .StatefulSet.Namespace }}/{{ .StatefulSet.Name }}/{{ toDate "2006-01-02T15:04:05.999999999Z07:00" .Time | date "2006-01-02T15:04:05Z07:00" }}/backup.sql.gz | ||
pg_dumpall --clean -U $PGUSER | gzip -c | kando location push --profile '{{ toJson .Profile }}' --path "${BACKUP_LOCATION}" - | ||
kando output backupLocation "${BACKUP_LOCATION}" | ||
restore: | ||
kind: StatefulSet | ||
inputArtifactNames: | ||
- cloudObject | ||
phases: | ||
- func: KubeTask | ||
name: pgRestore | ||
objects: | ||
pgSecret: | ||
kind: Secret | ||
name: '{{ index .Object.metadata.labels "app.kubernetes.io/instance" }}-postgresql' | ||
namespace: '{{ .StatefulSet.Namespace }}' | ||
args: | ||
image: ghcr.io/kanisterio/postgres-kanister-tools:0.72.0 | ||
namespace: '{{ .StatefulSet.Namespace }}' | ||
command: | ||
- bash | ||
- -o | ||
- errexit | ||
- -o | ||
- pipefail | ||
- -c | ||
- | | ||
export PGHOST='{{ index .Object.metadata.labels "app.kubernetes.io/instance" }}-postgresql.{{ .StatefulSet.Namespace }}.svc.cluster.local' | ||
export PGUSER='postgres' | ||
export PGPASSWORD='{{ index .Phases.pgRestore.Secrets.pgSecret.Data "postgresql-password" | toString }}' | ||
BACKUP_LOCATION={{ .ArtifactsIn.cloudObject.KeyValue.backupLocation }} | ||
kando location pull --profile '{{ toJson .Profile }}' --path "${BACKUP_LOCATION}" - | gunzip -c -f | sed 's/LOCALE/LC_COLLATE/' | psql -q -U "${PGUSER}" | ||
delete: | ||
inputArtifactNames: | ||
- cloudObject | ||
phases: | ||
- func: KubeTask | ||
name: deleteDump | ||
args: | ||
image: ghcr.io/kanisterio/postgres-kanister-tools:0.72.0 | ||
namespace: "{{ .Namespace.Name }}" | ||
command: | ||
- bash | ||
- -o | ||
- errexit | ||
- -o | ||
- pipefail | ||
- -c | ||
- | | ||
kando location delete --profile '{{ toJson .Profile }}' --path '{{ .ArtifactsIn.cloudObject.KeyValue.backupLocation }}' | ||