The following is required prior to installing Crunchy PostgreSQL Operator using Ansible:
- postgres-operator playbooks source code for the target version
- Ansible 2.9.0+
- Kubernetes v1.11+
- Cluster admin privileges in Kubernetes
- kubectl configured to communicate with Kubernetes
- OpenShift v3.09+
- Cluster admin privileges in OpenShift
- oc configured to communicate with OpenShift
Installing from a Windows Host
If the Crunchy PostgreSQL Operator is being installed from a Windows host the following are required:
The installation of the Crunchy PostgreSQL Operator requires elevated privileges, as the following objects need to be created:
- Custom Resource Definitions
- Cluster RBAC for using one of the multi-namespace modes
- Create required namespaces
In Kubernetes versions prior to 1.12 (including Openshift up through 3.11), there is a limitation that requires an extra step during installation for the operator to function properly with watched namespaces. This limitation does not exist when using Kubernetes 1.12+. When a list of namespaces are provided through the NAMESPACE environment variable, the setupnamespaces.sh script handles the limitation properly in both the bash and ansible installation.
However, if the user wishes to add a new watched namespace after installation, where the user would normally use pgo create namespace to add the new namespace, they should instead run the add-targeted-namespace.sh script or they may give themselves cluster-admin privileges instead of having to run setupnamespaces.sh script. Again, this is only required when running on a Kubernetes distribution whose version is below 1.12. In Kubernetes version 1.12+ the pgo create namespace command works as expected.
Obtaining Operator Ansible Role
- Clone the postgres-operator project
Configuring the Inventory File
inventory.yaml file included with the PostgreSQL Operator Playbooks allows installers
to configure how Ansible will connect to your Kubernetes cluster. This file
should contain the following connection variables:
openshiftvariables if you are being using them for your environment. Both sets of variables cannot be used at the same time. The unused variables should be left commented out or removed.
||Required, if deploying to Kubernetes||When deploying to Kubernetes, set to configure the context name of the kubeconfig to be used for authentication.|
||Required, if deploying to OpenShift||When deploying to OpenShift, set to configure the hostname of the OpenShift cluster to connect to.|
||Required, if deploying to OpenShift||When deploying to OpenShift, set to configure the password used for login.|
||Required, if deploying to OpenShift||When deploying to Openshift, set to ignore the integrity of TLS certificates for the OpenShift cluster.|
||Required, if deploying to OpenShift||When deploying to OpenShift, set to configure the token used for login (when not using username/password authentication).|
||Required, if deploying to OpenShift||When deploying to OpenShift, set to configure the username used for login.|
To retrieve the
kubernetes_context value for Kubernetes installs, run the following command:
kubectl config current-context
values.yaml file contains all of the configuration parameters
for deploying the PostgreSQL Operator. The example file
contains defaults that should work in most Kubernetes environments, but it may
require some customization.
For a detailed description of each configuration parameter, please read the PostgreSQL Operator Installer Configuration Reference
Deploying Grafana and Prometheus
PostgreSQL clusters created by the operator can be configured to create additional containers for collecting metrics.
These metrics are very useful for understanding the overall health and performance of PostgreSQL database deployments over time. The collectors included by the operator are:
- PostgreSQL Exporter - PostgreSQL metrics
The operator, however, does not install the necessary timeseries database (Prometheus) for storing the collected metrics or the front end visualization (Grafana) of those metrics.
Included in these playbooks are roles for deploying Granfana and/or Prometheus. See the
for options to install the metrics stack.