Skip to content

Installing PostgreSQL Operator

This section explains the steps to install PostgreSQL Operator (PGO) in a Linux environment.

Prerequisites

The following requirements must be fulfilled to install PGO.

Ensure the following resources are installed on your Linux environment:

  • Linux environment
  • Curl, Helm, Ansible installed

Installing PostgreSQL Operator in any Linux Environment

  1. Clone the PostgreSQL Operator repository by downloading the postgres-operator repository.

  2. Navigate to the installation directory: postgres-operator/installers/metrics/ansible.

  3. Open the inventory.yaml file and uncomment the following lines and update the required details:

    openshift_host: 'HostName'
    openshift_skip_tls_verify: true
    openshift_user: 'username'
    openshift_password: 'password'
    
  4. Open the values.yaml file and modify configurations for Alert Manager, Grafana and Prometheus as per requirements:

    1. Alert Manager (if required):

      alertmanager_install: "true"
      alertmanager_storage_class_name: "sc_class_name"
      alertmanager_volume_size: "1Gi"
      

      Info: Change the size as per your requirement, default is 1Gi.

    2. Grafana (if required):

      grafana_install: "true"
      grafana_storage_class_name: "sc_class_name"
      grafana_volume_size: "30Gi"
      

      Info: Change the default size of 1Gi to 30Gi as per your requirement.

    3. Prometheus (mandatory):

      prometheus_install: "true"
      prometheus_storage_class_name: "sc_class_name"
      prometheus_volume_size: "50Gi"
      

      Info: Change the default size of 1Gi to 50Gi as per your requirement.

    4. Save the file.

  5. Open a command line and navigate to postgres-operator/installers/metrics/ansible.

  6. Run the following command and wait for the installation to finish.

    ansible-playbook -i /path/to/inventory.yaml --tags=install-metrics main.yml
    
  7. After installation, navigate to the LPC environment, select routes with the pgo namespace. Create a route for Prometheus (mandatory) and Grafana (if installed).

Reference Documentation

Installing PostgreSQL Exporter in any environment

To install PostgreSQL exporter in any LPC environment, follow the steps:

  1. Use the xpc-monitor repository and select the appropriate folder based on your environment.

  2. Navigate to the PostgreSQL Exporter Directory: rancher/lpc/postgres-exporter folder.

    There are six YAML files, including deployment, service, service-monitor files, categorized into Timeseries (ts) and Non-Timeseries. These files are deployed across all LPC environments under the mdsp-oss namespace.

  3. Update the image in the deployment files, if required. The current image is: crunchydata/crunchy-postgres-exporter:centos8-4.7.5.

  4. Deploy YAML files in the LPC environment.

    1. Login to the console of any environment and run the following commands:

      Kubectl deploy -f deployment.yaml -n mdsp-oss
      
      Kubectl deploy -f deployment-ts.yaml -n mdsp-oss
      
      Kubectl deploy -f service-nonts.yaml -n mdsp-oss
      
      Kubectl deploy -f service-ts.yaml-n mdsp-oss
      
      Kubectl deploy -f servicemonitor-nonts.yaml -n mdsp-oss
      
      Kubectl deploy -f servicemonitor-ts.yaml -n mdsp-oss
      
    2. After deploying the YAML files, check the status of the pods under the mdsp-oss namespace.

    3. Create a secret in the mdsp-oss namespace, referencing mdsp-secret-infra-credentials and update it accordingly.
  5. After successfully deploying the PostgreSQL exporter and creating secrets in the mdsp-oss namespace.

    Open Prometheus, run the query up{} and verify if the PostgreSQL job is listed. If yes, it confirms that the Service Monitor is exporting data to Prometheus.

  6. Create a PostgreSQL dashboard in Grafana. A JSON reference for the dashboard is available in the repository.


Last update: February 6, 2025