Deleting a Postgres Instance from Kubernetes
This section describes how to delete Postgres pods and other resources that are created when you deploy a Postgres instance to Kubernetes. When deleting the resources, everything related to that instance is deleted, including the persistent volume claims (PVCs) and the access secrets. Any application bound to the deleted instance will have to rebind with new credentials.
Warning Do not delete the Postgres operator when there are existing Postgres instances. If the Postgres operator is deleted, you will get an error if you try to reinstall it. See Cannot Reinstall Operator after Deleting for a workaround to this problem.
Follow these steps to delete a Postgres instance from Kubernetes.
Change to the Tanzu SQL with Postgres workspace directory with the Kubernetes manifest you used to deploy the Postgres instance.
$ cd ./postgres-v<postgres-version>+<vmware-version>
kubectl deletecommand, specifying the manifest you used to deploy the instance. For example:
$ kubectl delete -f ./pg-instance-example.yaml --wait=false
postgres.sql.tanzu.vmware.com "my-postgres" deleted
Note: The optional
wait=falseflag returns immediately without waiting for the deletion to complete.
kubectlstops the Postgres instance and deletes the Kubernetes resources for the deployment.
If for any reason stopping the Postgres instance fails, use
kubectlto display the
$ kubectl logs -l app=postgres-operator
The Postgres operator should remain for future deployments:
$ kubectl get all
NAME READY STATUS RESTARTS AGE pod/postgres-operator-546ffd888b-dc6zk 1/1 Running 0 26h NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 18d NAME READY UP-TO-DATE AVAILABLE AGE deployment.apps/postgres-operator 1/1 1 1 26h NAME DESIRED CURRENT READY AGE replicaset.apps/postgres-operator-546ffd888b 1 1 1 26h
If you want to remove the Postgres operator, follow the instructions in Uninstalling Tanzu SQL with Postgres for Kubernetes.