Skip to content

Commit 1760a2c

Browse files
committed
make namespace a variable for easier copy/paste
Signed-off-by: Laurent <laurent.rochette@codefresh.io>
1 parent 1c57ee1 commit 1760a2c

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

_docs/installation/codefresh-on-prem-upgrade.md

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -478,11 +478,12 @@ For more information, see [bitnami/postgresql](https://github.com/bitnami/charts
478478

479479
1.Obtain the PostgresSQL administrator password:
480480
```shell
481-
export PGPASSWORD=$(kubectl get secret --namespace codefresh cf-postgresql -o jsonpath="{.data.postgres-password}" | base64 --decode)
481+
NAMESPACE=codefresh
482+
export PGPASSWORD=$(kubectl get secret --namespace $NAMESPACE cf-postgresql -o jsonpath="{.data.postgres-password}" | base64 --decode)
482483
```
483484
1.Forward the PostgreSQL service port and place the process in the background:
484485
```shell
485-
kubectl port-forward --namespace codefresh svc/cf-postgresql 5432:5432 &
486+
kubectl port-forward --namespace $NAMESPACE svc/cf-postgresql 5432:5432 &
486487
```
487488
1.Create a directory for the backup files and make it the current working directory:
488489
```shell
@@ -500,32 +501,32 @@ docker run --rm --name postgresql-backup -e PGPASSWORD=$PGPASSWORD -v $(pwd):/ap
500501

501502
Here:
502503
* The *--net* parameter lets the Docker container use the host's network stack and thereby gain access to the forwarded port.
503-
* The *pg_dump* command connects to the PostgreSQL service and creates backup files in the */app* directory, which is mapped to the current directory (*psqlbackup/*) on the Docker host with the *-v* parameter.
504+
* The *pg_dump* command connects to the PostgreSQL service and creates backup files in the */app* directory, which is mapped to the current directory (*psqlbackup/*) on the Docker host with the *-v* parameter.
504505
* The *--rm* parameter deletes the container after the *pg_dump* command completes execution.
505506

506507
**After the upgrade:**
507508

508509
Create an environment variable with the password for the new stateful set:
509510
```shell
510-
export PGPASSWORD=$(kubectl get secret --namespace codefresh cf-postgresql -o jsonpath="{.data.postgres-password}" | base64 --decode)
511+
export PGPASSWORD=$(kubectl get secret --namespace $NAMESPACE cf-postgresql -o jsonpath="{.data.postgres-password}" | base64 --decode)
511512
```
512513

513514
Forward the PostgreSQL service port for the new stateful set and place the process in the background:
514515
```shell
515-
kubectl port-forward --namespace codefresh svc/cf-postgresql 5432:5432
516+
kubectl port-forward --namespace $NAMESPACE svc/cf-postgresql 5432:5432
516517
```
517518

518519
Restore the contents of the backup into the new release using the *pg_restore* tool. If this tool is not available on your system, mount the directory containing the backup files as a volume in Bitnami's PostgreSQL Docker container and use the *pg_restore* client tool in the container image to import the backup into the new cluster, as shown below:
519520
```shell
520521
cd psqlbackup
521-
docker run --rm --name postgresql-backup -e PGPASSWORD=$PGPASSWORD -v $(pwd):/app --net="host" bitnami/postgresql:13 pg_restore --Fc --create --dbname postgres -h host.docker.internal -p 5432 /app/audit.dump
522+
docker run --rm --name postgresql-backup -e PGPASSWORD=$PGPASSWORD -v $(pwd):/app --net="host" bitnami/postgresql:13 pg_restore -Fc --create --dbname postgres -h host.docker.internal -p 5432 /app/audit.dump
522523
```
523524

524525
> The above command is true for Windows and macOS, for Linux users `host.docker.internal` has to be replaced with `127.0.0.1`
525526

526527
#### Backup and restore via Helm hooks
527528

528-
You can also run Postgresql database migration with `pre-upgrade` and `post-upgrade` helm hooks.
529+
You can also run Postgresql database migration with `pre-upgrade` and `post-upgrade` helm hooks.
529530
> It's strongly recommended to create a **MANUAL** backup prior to the upgrade!
530531

531532

@@ -564,11 +565,12 @@ For more information, see [bitnami/mongodb](https://github.com/bitnami/charts/tr
564565

565566
1. Obtain the MongoDB administrator password:
566567
```shell
567-
export MONGODB_ROOT_PASSWORD=$(kubectl get secret --namespace codefresh cf-mongodb -o jsonpath="{.data.mongodb-root-password}" | base64 --decode)
568+
NAMESPACE=codefresh
569+
export MONGODB_ROOT_PASSWORD=$(kubectl get secret --namespace $NAMESPACE cf-mongodb -o jsonpath="{.data.mongodb-root-password}" | base64 --decode)
568570
```
569571
1. Forward the MongoDB service port and place the process in the background:
570572
```shell
571-
kubectl port-forward --namespace codefresh svc/mongodb 27017:27017 &
573+
kubectl port-forward --namespace $NAMESPACE svc/mongodb 27017:27017 &
572574
```
573575
1. Create a directory for the backup files and make it the current working directory:
574576
```shell
@@ -585,20 +587,20 @@ docker run --rm --name mongodb-backup -v $(pwd):/app --net="host" bitnami/mongod
585587
> The above command is true for Windows and macOS, for Linux users `host.docker.internal` has to be replaced with `127.0.0.1`
586588

587589
Here:
588-
* The *--net* parameter lets the Docker container use the host's network stack and thereby gain access to the forwarded port.
589-
* The *mongodump* command connects to the MongoDB service and creates backup files in the */app* directory, which is mapped to the current directory (*mongobackup/*) on the Docker host with the *-v* parameter.
590+
* The *--net* parameter lets the Docker container use the host's network stack and thereby gain access to the forwarded port.
591+
* The *mongodump* command connects to the MongoDB service and creates backup files in the */app* directory, which is mapped to the current directory (*mongobackup/*) on the Docker host with the *-v* parameter.
590592
* The *--rm* parameter deletes the container after the *mongodump* command completes execution.
591593

592594
**After the upgrade:**
593595

594596
1. Create an environment variable with the password for the new stateful set:
595597
```shell
596-
export MONGODB_ROOT_PASSWORD=$(kubectl get secret --namespace codefresh cf-mongodb -o jsonpath="{.data.mongodb-root-password}" | base64 --decode)
598+
export MONGODB_ROOT_PASSWORD=$(kubectl get secret --namespace $NAMESPACE cf-mongodb -o jsonpath="{.data.mongodb-root-password}" | base64 --decode)
597599
```
598600
1. Forward the MongoDB service port for the new stateful set and place the process in the background:
599601
(**Note!** Default service address was changed)
600602
```shell
601-
kubectl port-forward --namespace codefresh svc/cf-mongodb 27017:27017 &
603+
kubectl port-forward --namespace $NAMESPACE svc/cf-mongodb 27017:27017 &
602604
```
603605
1. Restore the contents of the backup into the new release using the `mongorestore` tool.
604606
If this tool is not available on your system, mount the directory containing the backup files as a volume in Bitnami's MongoDB Docker container and use the `mongorestore` client tool in the container image to import the backup into the new cluster, as shown below:
@@ -612,12 +614,12 @@ docker run --rm --name mongodb-backup -v $(pwd):/app --net="host" bitnami/mongod
612614
1. Stop the service port forwarding by terminating the background process.
613615
1. Connect to the new stateful set and confirm that your data has been successfully restored:
614616
```shell
615-
kubectl run --namespace codefresh mongodb-new-client --rm --tty -i --restart='Never' --image docker.io/bitnami/mongodb:4.2 --command -- mongo codefresh --host cf-mongodb --authenticationDatabase admin -u root -p $MONGODB_ROOT_PASSWORD --eval "db.accounts.find()"
617+
kubectl run --namespace $NAMESPACE mongodb-new-client --rm --tty -i --restart='Never' --image docker.io/bitnami/mongodb:4.2 --command -- mongo codefresh --host cf-mongodb --authenticationDatabase admin -u root -p $MONGODB_ROOT_PASSWORD --eval "db.accounts.find()"
616618
```
617619

618620
#### Backup and restore via Helm hooks
619621

620-
You can also run MongoDB database migration with `pre-upgrade` and `post-upgrade` helm hooks.
622+
You can also run MongoDB database migration with `pre-upgrade` and `post-upgrade` helm hooks.
621623

622624
> It's strongly recommended to create a **MANUAL** backup prior to the upgrade!
623625

0 commit comments

Comments
 (0)