Shutting down the Postgres database in the Management subsystem on different environments

Shut down or fence the Postgres database in the Management subsystem to prevent data corruption, ensure safe failover, or perform maintenance tasks across development, staging, and production environments.

Before you begin

  • Make sure that the EDB cluster is healthy and running.
  • If the EDB cluster shuts down due to an issue in any environment, such as full disks, resolve the issue and then restart the cluster.

About this task

The shutdown of the Postgres database is controlled using the k8s.enterprisedb.io/fencedInstances annotation, which accepts a JSON-formatted list of instance names. If the annotation is set to ["*"], a singleton list with a wildcard, the entire cluster is shut down. To shut down only one EDB instance, replace the "*" in the command with the instance name.

Note: The OVA package includes API Connect with the CNP plug-in preinstalled. To install the CNP plug-in for other environments, see https://github.com/EnterpriseDB/kubectl-cnp.

Procedure

  1. If you are on an appliance (VMware), to run the kubectl commands, connect to the Management node and log in as root user (sudo -i).
  2. Shut down the cluster using the preinstalled CNP plug-in.
    1. To get the cluster name, run the following command.
      kubectl get clusters.postgresql.k8s.enterprisedb.io
    2. To shut down the cluster, run the following command.
      kubectl cnp fencing on <cluster_name_from_above_command> "*"
    Tip: You can also shut down the cluster if CNP plug-in is not preinstalled.
    1. To get the cluster name, run the following command.
      kubectl get clusters.postgresql.k8s.enterprisedb.io
    2. To shut down all the instances of the database, run the following command.
      kubectl annotate cluster <cluster_name_from_above_command> k8s.enterprisedb.io/fencedInstances='["*"]' -n <namespace>
    3. To shut down one instance of the database by passing the instance name, run the following command.
      kubectl annotate cluster <cluster_name_from_above_command> k8s.enterprisedb.io/fencedInstances='["<instance-name-db-1>"]' -n <namespace>

Results

The Postgres database in Management subsystem is now shut down.