Skip to content

Commit 3b4f670

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

File tree

67 files changed

+1583
-2817
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

+1583
-2817
lines changed

.github/workflows/ci.yml

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

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: 9.6.19
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: "9.6.19"
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-9.6.19-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: 9.6.19
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:
@@ -416,16 +413,16 @@ Now, we have to deploy the restored database similarly as we have deployed the o
416413
Below is the YAML for `Postgres` crd we are going deploy to initialize from backup,
417414

418415
```yaml
419-
apiVersion: kubedb.com/v1alpha1
416+
apiVersion: kubedb.com/v1alpha2
420417
kind: Postgres
421418
metadata:
422419
name: restored-postgres
423420
namespace: demo
424421
spec:
425422
version: "9.6.19"
426423
storageType: Durable
427-
databaseSecret:
428-
secretName: sample-postgres-auth # use same secret as original the database
424+
authSecret:
425+
name: sample-postgres-auth # use same secret as original the database
429426
storage:
430427
storageClassName: "standard"
431428
accessModes:
@@ -434,15 +431,14 @@ spec:
434431
requests:
435432
storage: 1Gi
436433
init:
437-
stashRestoreSession:
438-
name: sample-postgres-restore
434+
waitForInitialRestore: true
439435
terminationPolicy: Delete
440436
```
441437

442438
Here,
443439

444440
- `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.
445-
- `spec.init.stashRestoreSession.name` specifies the `RestoreSession` crd name that we are going to use to restore this database.
441+
- `spec.init.waitForInitialRestore` tells KubeDB to wait for the first restore to complete before marking the database as ready.
446442

447443
Let's create the above database,
448444

@@ -482,7 +478,7 @@ metadata:
482478
name: sample-postgres-restore
483479
namespace: demo
484480
labels:
485-
kubedb.com/kind: Postgres # this label is mandatory if you are using KubeDB to deploy the database.
481+
app.kubernetes.io/name: postgreses.kubedb.com # this label is mandatory if you are using KubeDB to deploy the database.
486482
spec:
487483
task:
488484
name: postgres-restore-{{< param "info.subproject_version" >}}
@@ -499,13 +495,13 @@ spec:
499495

500496
Here,
501497

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

508-
> **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.
504+
> **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.
509505

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

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)