Skip to content

Commit

Permalink
Fix blueprint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
hairyhum committed Dec 5, 2024
1 parent ae6bceb commit 0ae0c40
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ actions:
master_password="{{ index .Phases.backupToStore.Secrets.esMasterCredSecret.Data "password" | toString }}"
NODE_TLS_REJECT_UNAUTHORIZED=0 elasticdump --bulk=true --input=https://${master_username}:${master_password}@${host_name}:9200 --output=$ > /tmp/data
ouptutImage: '{{if index .Options "kanisterImage" }} {{- .Options.kanisterImage -}} {{else -}} ghcr.io/kanisterio/kanister-tools:0.112.0 {{- end}}'
outputImage: '{{if index .Options "kanisterImage" }} {{- .Options.kanisterImage -}} {{else -}} ghcr.io/kanisterio/kanister-tools:0.112.0 {{- end}}'
outputCommand:
- bash
- -o
Expand Down Expand Up @@ -85,7 +85,7 @@ actions:
kopia_snap='{{ .ArtifactsIn.esBackup.KopiaSnapshot }}'
kando location pull --profile '{{ toJson .Profile }}' --path "${backup_file_path}" --kopia-snapshot "${kopia_snap}" - | gunzip -c > /tmp/data
ouptutImage: elasticdump/elasticsearch-dump:latest
outputImage: elasticdump/elasticsearch-dump:latest
outputCommand:
- bash
- -o
Expand Down
2 changes: 1 addition & 1 deletion examples/mongodb/blueprint-v2/mongo-blueprint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ actions:

backgroundImage: '{{if index .Options "kanisterImage" }} {{- .Options.kanisterImage -}} {{else -}} ghcr.io/kanisterio/kanister-tools:0.112.0 {{- end}}'
backgroundCommand:
- bash
- bash
- -o
- errexit
- -o
Expand Down
55 changes: 44 additions & 11 deletions examples/mysql/blueprint-v2/mysql-blueprint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,45 +11,67 @@ actions:
# `kopiaOutput` is the name provided to kando using `--output-name` flag
kopiaSnapshot: "{{ .Phases.dumpToStore.Output.kopiaOutput }}"
phases:
- func: KubeTask
- func: MultiContainerRun
name: dumpToStore
objects:
mysqlSecret:
kind: Secret
name: '{{ index .Object.metadata.labels "app.kubernetes.io/instance" }}'
namespace: '{{ .StatefulSet.Namespace }}'
args:
image: ghcr.io/kanisterio/mysql-sidecar:0.112.0
namespace: "{{ .StatefulSet.Namespace }}"
command:
sharedVolumeMedium: Memory

initImage: '{{if index .Options "kanisterImage" }} {{- .Options.kanisterImage -}} {{else -}} ghcr.io/kanisterio/kanister-tools:0.112.0 {{- end}}'
initCommand: ["bash", "-o", "errexit", "-o", "pipefail", "-c", "mkfifo /tmp/data"]

backgroundImage: mysql:8
backgroundCommand:
- bash
- -o
- errexit
- -o
- pipefail
- -c
- |
backup_file_path="dump.sql"
root_password="{{ index .Phases.dumpToStore.Secrets.mysqlSecret.Data "mysql-root-password" | toString }}"
dump_cmd="mysqldump --column-statistics=0 -u root --password=${root_password} -h {{ index .Object.metadata.labels "app.kubernetes.io/instance" }} --single-transaction --all-databases"
${dump_cmd} | kando location push --profile '{{ toJson .Profile }}' --path "${backup_file_path}" --output-name "kopiaOutput" -
${dump_cmd} > /tmp/data
outputImage: '{{if index .Options "kanisterImage" }} {{- .Options.kanisterImage -}} {{else -}} ghcr.io/kanisterio/kanister-tools:0.112.0 {{- end}}'
outputCommand:
- bash
- -o
- errexit
- -o
- pipefail
- -c
- |
backup_file_path="dump.sql"
cat /tmp/data | kando location push --profile '{{ toJson .Profile }}' --path "${backup_file_path}" --output-name "kopiaOutput" -
restore:
inputArtifactNames:
# The kopia snapshot info created in backup phase can be used here
# Use the `--kopia-snapshot` flag in kando to pass in `mysqlBackup.KopiaSnapshot`
- mysqlBackup
phases:
- func: KubeTask
- func: MultiContainerRun
name: restoreFromStore
objects:
mysqlSecret:
kind: Secret
name: '{{ index .Object.metadata.labels "app.kubernetes.io/instance" }}'
namespace: '{{ .StatefulSet.Namespace }}'
args:
image: ghcr.io/kanisterio/mysql-sidecar:0.112.0
namespace: "{{ .StatefulSet.Namespace }}"
command:
sharedVolumeMedium: Memory

initImage: '{{if index .Options "kanisterImage" }} {{- .Options.kanisterImage -}} {{else -}} ghcr.io/kanisterio/kanister-tools:0.112.0 {{- end}}'
initCommand: ["bash", "-o", "errexit", "-o", "pipefail", "-c", "mkfifo /tmp/data"]

backgroundImage: '{{if index .Options "kanisterImage" }} {{- .Options.kanisterImage -}} {{else -}} ghcr.io/kanisterio/kanister-tools:0.112.0 {{- end}}'
backgroundCommand:
- bash
- -o
- errexit
Expand All @@ -59,9 +81,20 @@ actions:
- |
backup_file_path="dump.sql"
kopia_snap='{{ .ArtifactsIn.mysqlBackup.KopiaSnapshot }}'
kando location pull --profile '{{ toJson .Profile }}' --path "${backup_file_path}" --kopia-snapshot "${kopia_snap}" - > /tmp/data
outputImage: mysql:8
outputCommand:
- bash
- -o
- errexit
- -o
- pipefail
- -c
- |
root_password="{{ index .Phases.restoreFromStore.Secrets.mysqlSecret.Data "mysql-root-password" | toString }}"
restore_cmd="mysql -u root --password=${root_password} -h {{ index .Object.metadata.labels "app.kubernetes.io/instance" }}"
kando location pull --profile '{{ toJson .Profile }}' --path "${backup_file_path}" --kopia-snapshot "${kopia_snap}" - | ${restore_cmd}
cat /tmp/data | mysql -u root --password=${root_password} -h {{ index .Object.metadata.labels "app.kubernetes.io/instance" }}
delete:
inputArtifactNames:
# The kopia snapshot info created in backup phase can be used here
Expand All @@ -71,7 +104,7 @@ actions:
- func: KubeTask
name: deleteFromStore
args:
image: ghcr.io/kanisterio/mysql-sidecar:0.112.0
image: '{{if index .Options "kanisterImage" }} {{- .Options.kanisterImage -}} {{else -}} ghcr.io/kanisterio/kanister-tools:0.112.0 {{- end}}'
namespace: "{{ .Namespace.Name }}"
command:
- bash
Expand Down
4 changes: 2 additions & 2 deletions examples/postgresql-ha/hook-blueprint/postgres-ha-hook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ actions:
namespace: '{{ .StatefulSet.Namespace }}'
args:
namespace: '{{ .StatefulSet.Namespace }}'
image: {{if .Options.psqlImage }} {{.Options.psqlImage}} {{else}} postgres:17-bullseye {{end}}
image: '{{if index .Options "psqlImage" }} {{- .Options.psqlImage -}} {{else -}} bitnami/postgresql-repmgr {{- end}}'
command:
- bash
- -o
Expand All @@ -41,7 +41,7 @@ actions:
postgresMaster=$(psql -U postgres -h $PGHOST -d repmgr -t -c "select node_name from repmgr.nodes where type='primary'")
postgresStandby=$(psql -U postgres -h $PGHOST -d repmgr -t -c "select node_name from repmgr.nodes where type='standby'")
primaryHost=''${postgresMaster}'.{{ .StatefulSet.Name }}-headless.{{ .StatefulSet.Namespace }}.svc.cluster.local'
secondaryHost=''${postgresStandby}'.{{ .StatefulSet.Name }}-headless.{{ .StatefulSet.Namespace }}.svc.cluster.local'
secondaryHost=''${postgresStandby}'.{{ .StatefulSet.Name }}-headless.{{ .StatefulSet.Namespace }}.svc.cluster.local'
export conn_info_primary='user=repmgr password='${PGREPL}' host='${primaryHost}' dbname=repmgr port=5432 connect_timeout=5'
export conn_info_standby='user=repmgr password='${PGREPL}' host='${secondaryHost}' dbname=repmgr port=5432 connect_timeout=5'
psql -U postgres -h $PGHOST -d repmgr -c "update repmgr.nodes set conninfo='${conn_info_primary}' where type='primary'"
Expand Down

0 comments on commit 0ae0c40

Please sign in to comment.