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 Postgres workspace directory with the Kubernetes manifest you used to deploy the Postgres instance.
$ cd ./postgres-v<postgres-version>+<vmware-version>
kubectl delete command, specifying the manifest you used to deploy the instance. For example:
$ kubectl delete -f ./postgres.yaml --wait=false
postgres.sql.tanzu.vmware.com "postgres-sample" deleted
Note: The optional
wait=false flag returns immediately without waiting for the deletion to complete.
kubectl stops the Postgres instance and deletes the Kubernetes resources for the deployment.
If for any reason stopping the Postgres instance fails, use
kubectl to 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 40h service/postgres-operator-webhook-service ClusterIP 10.98.126.247 <none> 443/TCP 26h 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 VMware Tanzu SQL with Postgres for Kubernetes.