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¶
-
Clone the PostgreSQL Operator repository by downloading the
postgres-operator
repository. -
Navigate to the installation directory:
postgres-operator/installers/metrics/ansible
. -
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'
-
Open the
values.yaml
file and modify configurations for Alert Manager, Grafana and Prometheus as per requirements:-
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
. -
Grafana (if required):
grafana_install: "true" grafana_storage_class_name: "sc_class_name" grafana_volume_size: "30Gi"
Info: Change the default size of
1Gi
to30Gi
as per your requirement. -
Prometheus (mandatory):
prometheus_install: "true" prometheus_storage_class_name: "sc_class_name" prometheus_volume_size: "50Gi"
Info: Change the default size of
1Gi
to50Gi
as per your requirement. -
Save the file.
-
-
Open a command line and navigate to
postgres-operator/installers/metrics/ansible
. -
Run the following command and wait for the installation to finish.
ansible-playbook -i /path/to/inventory.yaml --tags=install-metrics main.yml
-
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:
-
Use the xpc-monitor repository and select the appropriate folder based on your environment.
-
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.
-
Update the image in the deployment files, if required. The current image is:
crunchydata/crunchy-postgres-exporter:centos8-4.7.5
. -
Deploy YAML files in the LPC environment.
-
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
-
After deploying the YAML files, check the status of the pods under the
mdsp-oss
namespace. - Create a secret in the
mdsp-oss
namespace, referencingmdsp-secret-infra-credentials
and update it accordingly.
-
-
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. -
Create a PostgreSQL dashboard in Grafana. A JSON reference for the dashboard is available in the repository.