Skip to content
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

update mongo db blueprint #1106

Merged
merged 6 commits into from
Oct 14, 2021
Merged
Show file tree
Hide file tree
Changes from 5 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
6 changes: 6 additions & 0 deletions examples/stable/mongodb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,13 @@ $ kanctl create profile s3compliant --access-key <aws-access-key-id> \

The command will configure a location where artifacts resulting from Kanister data operations such as backup should go. This is stored as a profiles.cr.kanister.io CustomResource (CR) which is then referenced in Kanister ActionSets. Every ActionSet requires a Profile reference to complete the action. This CR (profiles.cr.kanister.io) can be shared between Kanister-enabled application instances.

**NOTE:**

If you have installed MongoDB chart using existing mongo secret by setting paramter `--set auth.existingSecret=<mongo-secret-name>` you will need to modify the secret name in the blueprint `mongo-blueprint.yaml` at following places:
```bash
actions.backup.phases[0].objects.mongosecret.name: <mongo-secret-name>
actions.restore.phases[0].objects.mongosecret.name: <mongo-secret-name>
```
### Create Blueprint
Create Blueprint in the same namespace as the controller

Expand Down
8 changes: 4 additions & 4 deletions examples/stable/mongodb/blueprint-v2/mongo-blueprint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ actions:
objects:
mongosecret:
kind: Secret
name: '{{ index .Object.metadata.labels "app.kubernetes.io/instance" }}-mongodb'
name: '{{ .StatefulSet.Name }}'
kale-amruta marked this conversation as resolved.
Show resolved Hide resolved
namespace: "{{ .StatefulSet.Namespace }}"
args:
namespace: "{{ .StatefulSet.Namespace }}"
Expand All @@ -29,7 +29,7 @@ actions:
- pipefail
- -c
- |
host='{{ index .Object.metadata.labels "app.kubernetes.io/instance" }}-mongodb-0.{{ index .Object.metadata.labels "app.kubernetes.io/instance" }}-mongodb-headless.{{ .StatefulSet.Namespace }}.svc.cluster.local'
host='{{ .StatefulSet.Name }}-0.{{ .StatefulSet.Name }}-headless.{{ .StatefulSet.Namespace }}.svc.cluster.local'
dbPassword='{{ index .Phases.takeConsistentBackup.Secrets.mongosecret.Data "mongodb-root-password" | toString }}'
dump_cmd="mongodump --oplog --gzip --archive --host ${host} -u root -p ${dbPassword}"
backup_file_path='rs_backup.gz'
Expand All @@ -45,7 +45,7 @@ actions:
objects:
mongosecret:
kind: Secret
name: '{{ index .Object.metadata.labels "app.kubernetes.io/instance" }}-mongodb'
name: '{{ .StatefulSet.Name }}'
namespace: "{{ .StatefulSet.Namespace }}"
args:
namespace: "{{ .StatefulSet.Namespace }}"
Expand All @@ -58,7 +58,7 @@ actions:
- pipefail
- -c
- |
host='{{ index .Object.metadata.labels "app.kubernetes.io/instance" }}-mongodb-0.{{ index .Object.metadata.labels "app.kubernetes.io/instance" }}-mongodb-headless.{{ .StatefulSet.Namespace }}.svc.cluster.local'
host='{{ .StatefulSet.Name }}-0.{{ .StatefulSet.Name }}-headless.{{ .StatefulSet.Namespace }}.svc.cluster.local'
dbPassword='{{ index .Phases.pullFromStore.Secrets.mongosecret.Data "mongodb-root-password" | toString }}'
restore_cmd="mongorestore --gzip --archive --oplogReplay --drop --host ${host} -u root -p ${dbPassword}"
backup_file_path='rs_backup.gz'
Expand Down
8 changes: 4 additions & 4 deletions examples/stable/mongodb/mongo-blueprint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ actions:
objects:
mongosecret:
kind: Secret
name: '{{ index .Object.metadata.labels "app.kubernetes.io/instance" }}-mongodb'
name: '{{ .StatefulSet.Name }}'
namespace: "{{ .StatefulSet.Namespace }}"
args:
namespace: "{{ .StatefulSet.Namespace }}"
Expand All @@ -27,7 +27,7 @@ actions:
- pipefail
- -c
- |
host='{{ index .Object.metadata.labels "app.kubernetes.io/instance" }}-mongodb-0.{{ index .Object.metadata.labels "app.kubernetes.io/instance" }}-mongodb-headless.{{ .StatefulSet.Namespace }}.svc.cluster.local'
host='{{ .StatefulSet.Name }}-0.{{ .StatefulSet.Name }}-headless.{{ .StatefulSet.Namespace }}.svc.cluster.local'
dbPassword='{{ index .Phases.takeConsistentBackup.Secrets.mongosecret.Data "mongodb-root-password" | toString }}'
dump_cmd="mongodump --oplog --gzip --archive --host ${host} -u root -p ${dbPassword}"
${dump_cmd} | kando location push --profile '{{ toJson .Profile }}' --path '/mongodb-replicaset-backups/{{ .StatefulSet.Name }}/{{ toDate "2006-01-02T15:04:05.999999999Z07:00" .Time | date "2006-01-02T15-04-05" }}/rs_backup.gz' -
Expand All @@ -40,7 +40,7 @@ actions:
objects:
mongosecret:
kind: Secret
name: '{{ index .Object.metadata.labels "app.kubernetes.io/instance" }}-mongodb'
name: '{{ .StatefulSet.Name }}'
namespace: "{{ .StatefulSet.Namespace }}"
args:
namespace: "{{ .StatefulSet.Namespace }}"
Expand All @@ -53,7 +53,7 @@ actions:
- pipefail
- -c
- |
host='{{ index .Object.metadata.labels "app.kubernetes.io/instance" }}-mongodb-0.{{ index .Object.metadata.labels "app.kubernetes.io/instance" }}-mongodb-headless.{{ .StatefulSet.Namespace }}.svc.cluster.local'
host='{{ .StatefulSet.Name }}-0.{{ .StatefulSet.Name }}-headless.{{ .StatefulSet.Namespace }}.svc.cluster.local'
dbPassword='{{ index .Phases.pullFromBlobStore.Secrets.mongosecret.Data "mongodb-root-password" | toString }}'
restore_cmd="mongorestore --gzip --archive --oplogReplay --drop --host ${host} -u root -p ${dbPassword}"
kando location pull --profile '{{ toJson .Profile }}' --path '{{ .ArtifactsIn.cloudObject.KeyValue.path }}' - | ${restore_cmd}
Expand Down