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 Postgres instance and its resources, every resource related to that instance is deleted, including the access secrets. The PVCs associated with the instance would be deleted or retained depending upon the PVC retention policy you have configured, see Configure Persistent Volume Claim Retention Policy.

NOTE: Any application bound to the deleted instance will have to rebind with new credentials.

Deleting Postgres Pods and Resources

Follow these steps to delete a Postgres instance from Kubernetes.

  1. Change to the VMware Postgres Operator 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. The kubectl delete command stops the Postgres instance, and deletes the Kubernetes resources for the deployment.

    kubectl delete -f ./postgres.yaml --wait=false

    where the optional wait=false flag returns immediately, without waiting for the deletion to complete. The command returns an output similar to: "postgres-sample" deleted

    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 SQL with Postgres for Kubernetes.

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.

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