These scripts assist you with migrating an existing Patroni cluster from GlusterFS to NetApp storage. The strategy depends on Patroni's ability to leverage Postgres WAL history archiving to replay transactions and maintain history lineage. Note that this gist runs with a few assumptions and isn't fully parameterized. We assume your Patroni cluster is named "patroni-master", and have a working knowledge of OpenShift and patronictl.
- Add temporary permissive NSP rules to namespace
- Create a new temporary statefulset which will extend the existing statefulset cluster
- Force master to failover to the new temporary node
- Delete the original statefulset and its PVCs
- Recreate the original statefulset cluster with the new storage class request
- Force master to failover to one of the new cluster nodes
- Delete the temporary statefulset and its PVC
- Remove any temporary NSP rules in namespace
Run the following:
export NAMESPACE=<YOURNAMESPACE>
./clone-statefulset-temp.sh $NAMESPACE patroni-master
This will create a temporary statefulset attached with the existing cluster. Follow the instructions printed on screen to force a failover to the temporary pod and then delete the original statefulset and PVC.
Once everything is now on the temporary statefulset only, run the following:
export NAMESPACE=<YOURNAMESPACE>
./clone-statefulset-restore.sh $NAMESPACE patroni-master-x
This will reverse the process by recreating the original statefulset attached to the existing cluster. Follow the instructions printed on screen to force a failover to one of the re-established pods and then delete the temporary statefulset and PVC. You will also want to remove any temporary NSP that were used with the following command:
export NAMESPACE=<YOURNAMESPACE>
oc delete -n $NAMESPACE nsp -l template=networksecurity-template
At the end of this, you should now be on NetApp block storage without any downtime to your dependent applications.
A big thanks to @cvarjao for his initial script and pattern idea: https://github.com/cvarjao/platform-services/blob/patroni-supporting-scripts/apps/pgsql/patroni/scripts/clone-statefulset.sh