CNPG Operator Migration Guide
This guide will assist you in migrating to the new CNPG operator.
Prerequisites
-
Install PGAdmin form the TrueCharts Stable train.
-
Setup tcdbinfo.sh script
-
Add the Operator train to your TrueCharts Catalog
Acquire Database Credentials
- Run tcdbinfo.sh to get a list of database credentials.
bash tcdbinfo.sh
Connect to CNPG Databases in PGAdmin
- Click Add Server.
- Choose a name for the database, this will only be used to help you identify it.
- Enter database server and credentials previously acquired from tcdbinfo.sh script and save.
Backup CNPG Databases
- Right click on the database and select backup as shown below.
- Choose a name for the database backup and click backup.
Remove Old CNPG
- Run the following command in system shell as root.
k3s kubectl delete --grace-period 30 --v=4 -k https://github.com/truecharts/manifests/delete2
Install cloudnative-pg
- Install cloudnative-pg from the operator train, wait for it to go ACTIVE.
Prepare CNPG Apps
-
Edit the app config of the CNPG application (home assistant in this example) and save the configuration without making any changes.
-
Wait for all pods to be created and app to be Active. This may take a few minutes. In this example Home Assistant will show ACTIVE 3/3 when its ready.
-
Get the name of the app deploy.
k3s kubectl get deploy -n ix-<app>
- Stop the main pod of the app you are migrating.
k3s kubectl scale deploy <app> -n ix-<app> --replicas=0
Restore CNPG Databases
- Right click on the database and select restore as shown below in PGAdmin.
- Select the database backup you created previously.
- Configure Data/Objects as shown below.
- Configure Options as shown below and click restore.
PGAdmin Error
PGAdmin may display an error during the restore process. This is known to occur and may be ignored if the app functions properly.
- Start the main pod of the app you are migrating.
k3s kubectl scale deploy <app> -n ix-<app> --replicas=1