Skip to content

Commit a14c26d

Browse files
1gtmEmruz Hossain
andauthored
[cherry-pick] Don't overwrite superuser password of restored database (#660) (#669)
/cherry-pick Signed-off-by: Emruz Hossain <emruz@appscode.com> Co-authored-by: Emruz Hossain <emruz@appscode.com>
1 parent fc9f230 commit a14c26d

File tree

67 files changed

+1576
-2810
lines changed

Some content is hidden

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

67 files changed

+1576
-2810
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ jobs:
8181
helm repo add appscode https://charts.appscode.com/stable/
8282
helm repo update
8383
helm install stash-crds appscode/stash-crds
84+
helm install kubedb-crds appscode/kubedb-crds
8485
helm install kmodules-crds appscode/kmodules-crds
8586
kubectl wait --for=condition=NamesAccepted crds --all --timeout=5m
8687

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,3 +572,10 @@ release:
572572
.PHONY: clean
573573
clean:
574574
rm -rf .go bin
575+
576+
# make and load docker image to kind cluster
577+
.PHONY: push-to-kind
578+
push-to-kind: container
579+
@echo "Loading docker image into kind cluster...."
580+
@kind load docker-image $(REGISTRY)/stash-postgres:$(TAG)
581+
@echo "Image has been pushed successfully into kind cluster."

docs/examples/backup/appbinding.yaml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@ metadata:
77
app.kubernetes.io/component: database
88
app.kubernetes.io/instance: sample-postgres
99
app.kubernetes.io/managed-by: kubedb.com
10-
app.kubernetes.io/name: postgres
11-
app.kubernetes.io/version: "12.4"
12-
kubedb.com/kind: Postgres
13-
kubedb.com/name: sample-postgres
10+
app.kubernetes.io/name: postgreses.kubedb.com
1411
name: sample-postgres
1512
namespace: demo
1613
spec:

docs/examples/backup/postgres.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
apiVersion: kubedb.com/v1alpha1
1+
apiVersion: kubedb.com/v1alpha2
22
kind: Postgres
33
metadata:
44
name: sample-postgres
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
apiVersion: kubedb.com/v1alpha1
1+
apiVersion: kubedb.com/v1alpha2
22
kind: Postgres
33
metadata:
44
name: restored-postgres
55
namespace: demo
66
spec:
77
version: "12.4"
88
storageType: Durable
9-
databaseSecret:
10-
secretName: sample-postgres-auth # use same secret as original the database
9+
authSecret:
10+
name: sample-postgres-auth # use same secret as original the database
1111
storage:
1212
storageClassName: "standard"
1313
accessModes:
@@ -16,6 +16,5 @@ spec:
1616
requests:
1717
storage: 1Gi
1818
init:
19-
stashRestoreSession:
20-
name: sample-postgres-restore
19+
waitForInitialRestore: true
2120
terminationPolicy: Delete

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: sample-postgres-restore
55
namespace: demo
66
labels:
7-
kubedb.com/kind: Postgres # this label is mandatory if you are using KubeDB to deploy the database.
7+
app.kubernetes.io/name: postgreses.kubedb.com # this label is mandatory if you are using KubeDB to deploy the database.
88
spec:
99
task:
1010
name: postgres-restore-12.4.0-v4

docs/standalone.md

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Let's deploy a sample PostgreSQL database and insert some data into it.
5656
Below is the YAML of a sample Postgres crd that we are going to create for this tutorial:
5757

5858
```yaml
59-
apiVersion: kubedb.com/v1alpha1
59+
apiVersion: kubedb.com/v1alpha2
6060
kind: Postgres
6161
metadata:
6262
name: sample-postgres
@@ -132,10 +132,7 @@ metadata:
132132
app.kubernetes.io/component: database
133133
app.kubernetes.io/instance: sample-postgres
134134
app.kubernetes.io/managed-by: kubedb.com
135-
app.kubernetes.io/name: postgres
136-
app.kubernetes.io/version: "12.4"
137-
kubedb.com/kind: Postgres
138-
kubedb.com/name: sample-postgres
135+
app.kubernetes.io/name: postgreses.kubedb.com
139136
name: sample-postgres
140137
namespace: demo
141138
spec:
@@ -417,16 +414,16 @@ Now, we have to deploy the restored database similarly as we have deployed the o
417414
Below is the YAML for `Postgres` crd we are going deploy to initialize from backup,
418415

419416
```yaml
420-
apiVersion: kubedb.com/v1alpha1
417+
apiVersion: kubedb.com/v1alpha2
421418
kind: Postgres
422419
metadata:
423420
name: restored-postgres
424421
namespace: demo
425422
spec:
426423
version: "12.4"
427424
storageType: Durable
428-
databaseSecret:
429-
secretName: sample-postgres-auth # use same secret as original the database
425+
authSecret:
426+
name: sample-postgres-auth # use same secret as original the database
430427
storage:
431428
storageClassName: "standard"
432429
accessModes:
@@ -435,15 +432,14 @@ spec:
435432
requests:
436433
storage: 1Gi
437434
init:
438-
stashRestoreSession:
439-
name: sample-postgres-restore
435+
waitForInitialRestore: true
440436
terminationPolicy: Delete
441437
```
442438

443439
Here,
444440

445441
- `spec.databaseSecret.secretName` specifies the name of the database secret of the original database. You must use the same secret in the restored database. Otherwise, the restore process will fail.
446-
- `spec.init.stashRestoreSession.name` specifies the `RestoreSession` crd name that we are going to use to restore this database.
442+
- `spec.init.waitForInitialRestore` tells KubeDB to wait for the first restore to complete before marking the database as ready.
447443

448444
Let's create the above database,
449445

@@ -483,7 +479,7 @@ metadata:
483479
name: sample-postgres-restore
484480
namespace: demo
485481
labels:
486-
kubedb.com/kind: Postgres # this label is mandatory if you are using KubeDB to deploy the database.
482+
app.kubernetes.io/name: postgreses.kubedb.com # this label is mandatory if you are using KubeDB to deploy the database.
487483
spec:
488484
task:
489485
name: postgres-restore-{{< param "info.subproject_version" >}}
@@ -500,13 +496,13 @@ spec:
500496

501497
Here,
502498

503-
- `metadata.labels` specifies a `kubedb.com/kind: Postgres` label that is used by KubeDB to watch this `RestoreSession`.
499+
- `metadata.labels` specifies a `app.kubernetes.io/name: postgreses.kubedb.com` label that is used by KubeDB to watch this `RestoreSession`.
504500
- `spec.task.name` specifies the name of the `Task` crd that specifies the Functions and their execution order to restore a PostgreSQL database.
505501
- `spec.repository.name` specifies the `Repository` crd that holds the backend information where our backed up data has been stored.
506502
- `spec.target.ref` refers to the AppBinding crd for the `restored-postgres` database where the backed up data will be restored.
507503
- `spec.rules` specifies that we are restoring from the latest backup snapshot of the original database.
508504

509-
> **Warning:** Label `kubedb.com/kind: Postgres` is mandatory if you are using KubeDB to deploy the database. Otherwise, the database will be stuck in `Initializing` state.
505+
> **Warning:** Label `app.kubernetes.io/name: postgreses.kubedb.com` is mandatory if you are using KubeDB to deploy the database. Otherwise, the database will be stuck in `Initializing` state.
510506

511507
Let's create the `RestoreSession` crd we have shown above,
512508

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-20210218144958-579bf8307d65
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.8
18+
stash.appscode.dev/apimachinery v0.11.10-0.20210219134546-33840ed82608
1919
)
2020

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

0 commit comments

Comments
 (0)