Skip to content

Commit a0e9506

Browse files
1gtmEmruz Hossain
andauthored
[cherry-pick] Support multiple commands in backup/restore pipeline (#335) (#343)
/cherry-pick Signed-off-by: Emruz Hossain <emruz@appscode.com> Co-authored-by: Emruz Hossain <emruz@appscode.com>
1 parent f4a09d8 commit a0e9506

File tree

66 files changed

+2219
-2805
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+2219
-2805
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,14 @@ jobs:
7272
kubectl wait --for=condition=Ready nodes --all --timeout=5m
7373
kubectl get nodes
7474
echo
75-
echo "create docker-registry secret"
76-
kubectl create secret docker-registry ${REGISTRY_SECRET} --namespace=kube-system --docker-server=https://index.docker.io/v1/ --docker-username=${USERNAME} --docker-password=${DOCKER_TOKEN}
77-
78-
- name: Install CRDs
79-
run: |
80-
kubectl apply -f https://github.com/stashed/apimachinery/raw/master/crds/stash.appscode.com_functions.yaml
81-
kubectl apply -f https://github.com/stashed/apimachinery/raw/master/crds/stash.appscode.com_tasks.yaml
75+
echo "install helm 3"
76+
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
77+
echo "install stash-crds chart"
78+
helm repo add appscode https://charts.appscode.com/stable/
79+
helm repo update
80+
helm install stash-crds appscode/stash-crds
81+
helm install kubedb-crds appscode/kubedb-crds
82+
helm install kmodules-crds appscode/kmodules-crds
8283
kubectl wait --for=condition=NamesAccepted crds --all --timeout=5m
8384
8485
- name: Test charts

docs/examples/restore/restored-mysql.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,6 @@ spec:
1515
resources:
1616
requests:
1717
storage: 50Mi
18+
init:
19+
waitForInitialRestore: true
1820
terminationPolicy: WipeOut

docs/examples/restore/restoresession.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ metadata:
44
name: restore-sample-mysql
55
namespace: demo
66
labels:
7-
kubedb.com/kind: MySQL # this label is mandatory if you are using KubeDB to deploy the database.
7+
app.kubernetes.io/name: mysqls.kubedb.com # this label is mandatory if you are using KubeDB to deploy the database.
88
spec:
99
task:
1010
name: mysql-restore-8.0.3-v6

docs/mysql.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,7 @@ metadata:
130130
app.kubernetes.io/component: database
131131
app.kubernetes.io/instance: sample-mysql
132132
app.kubernetes.io/managed-by: kubedb.com
133-
app.kubernetes.io/name: mysql
134-
app.kubernetes.io/version: 8.0.3
135-
kubedb.com/kind: MySQL
136-
kubedb.com/name: sample-mysql
133+
app.kubernetes.io/name: mysqls.kubedb.com
137134
name: sample-mysql
138135
namespace: demo
139136
spec:
@@ -456,12 +453,14 @@ spec:
456453
resources:
457454
requests:
458455
storage: 50Mi
456+
init:
457+
waitForInitialRestore: true
459458
terminationPolicy: WipeOut
460459
```
461460

462461
Here,
463462

464-
- `spec.init.stashRestoreSession.name` specifies the `RestoreSession` CRD name that we will use later to restore the database.
463+
- `spec.init.waitForInitialRestore` tells KubeDB to wait for the first restore to complete before marking this database as ready to use.
465464

466465
Let's create the above database,
467466

@@ -501,7 +500,7 @@ metadata:
501500
name: sample-mysql-restore
502501
namespace: demo
503502
labels:
504-
kubedb.com/kind: MySQL # this label is mandatory if you are using KubeDB to deploy the database.
503+
app.kubernetes.io/name: mysqls.kubedb.com # this label is mandatory if you are using KubeDB to deploy the database.
505504
spec:
506505
task:
507506
name: mysql-restore-{{< param "info.subproject_version" >}}
@@ -518,13 +517,13 @@ spec:
518517

519518
Here,
520519

521-
- `.metadata.labels` specifies a `kubedb.com/kind: MySQL` label that is used by KubeDB to watch this RestoreSession object.
520+
- `.metadata.labels` specifies a `app.kubernetes.io/name: mysqls.kubedb.com` label that is used by KubeDB to watch this RestoreSession object.
522521
- `.spec.task.name` specifies the name of the Task CRD that specifies the necessary Functions and their execution order to restore a MySQL database.
523522
- `.spec.repository.name` specifies the Repository CRD that holds the backend information where our backed up data has been stored.
524523
- `.spec.target.ref` refers to the newly created AppBinding object for the `restored-mysql` MySQL object.
525524
- `.spec.rules` specifies that we are restoring data from the latest backup snapshot of the database.
526525

527-
> **Warning:** Label `kubedb.com/kind: MySQL` is mandatory if you are using KubeDB to deploy the database. Otherwise, the database will be stuck in **`Initializing`** state.
526+
> **Warning:** Label `app.kubernetes.io/name: mysqls.kubedb.com` is mandatory if you are using KubeDB to deploy the database. Otherwise, the database will be stuck in **`Provisioning`** state.
528527

529528
Let's create the RestoreSession CRD object we have shown above,
530529

go.mod

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ require (
1111
k8s.io/api v0.18.9
1212
k8s.io/apimachinery v0.18.9
1313
k8s.io/client-go v0.18.9
14-
kmodules.xyz/client-go v0.0.0-20210118094617-273ba20ad7ca
15-
kmodules.xyz/custom-resources v0.0.0-20201124062543-bd8d35c21b0c
16-
kmodules.xyz/offshoot-api v0.0.0-20201105074700-8675f5f686f2
14+
kmodules.xyz/client-go v0.0.0-20210218100652-8f345ddfe801
15+
kmodules.xyz/custom-resources v0.0.0-20210222100152-7426e3678989
16+
kmodules.xyz/offshoot-api v0.0.0-20210218144050-e1d794cb382a
1717
kmodules.xyz/schema-checker v0.1.0
18-
stash.appscode.dev/apimachinery v0.11.9
18+
stash.appscode.dev/apimachinery v0.11.10-0.20210223054644-c403645d9bc1
1919
)
2020

2121
replace bitbucket.org/ww/goautoneg => gomodules.xyz/goautoneg v0.0.0-20120707110453-a547fc61f48d

0 commit comments

Comments
 (0)