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.

Deleting Postgres Pods and Resources

Follow these steps to delete a Postgres instance from Kubernetes.

  1. 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>
  2. Execute the kubectl delete command, specifying the manifest you used to deploy the instance. For example:

    kubectl delete -f ./postgres.yaml --wait=false "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.

  3. If for any reason stopping the Postgres instance fails, use kubectl to display the postgres-operator log.

    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        <none>           443/TCP          40h
    service/postgres-operator-webhook-service   ClusterIP    <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

Deleting the Postgres Operator

If you want to remove the Postgres operator, follow the instructions in Uninstalling VMware Tanzu SQL with Postgres for Kubernetes.

check-circle-line exclamation-circle-line close-line
Scroll to top icon