Don't want to install anything locally just yet? Try a demonstration directly in your browser:
Red Hat OpenShift Container Platform users can test the certified operator for EDB Postgres for Kubernetes on the Red Hat CodeReady Containers (CRC) for OpenShift.
The instructions contained in this section are for demonstration, testing, and practice purposes only and must not be used in production.
Like any other Kubernetes application, EDB Postgres for Kubernetes is deployed using regular manifests written in YAML.
By following these instructions you should be able to start a PostgreSQL cluster on your local Kubernetes/Openshift installation and experiment with it.
If you are running Openshift, use
oc every time
kubectl is mentioned
in this documentation.
kubectl commands are compatible with
The first part is about installing Minikube, Kind, or CRC. Please spend some time reading about the systems and decide which one to proceed with. After setting up one of them, please proceed with part 2.
We also provide instructions for setting up monitoring with Prometheus and Grafana for local testing/evaluation, in part 4
Minikube is a tool that makes it easy to run Kubernetes locally. Minikube runs a single-node Kubernetes cluster inside a Virtual Machine (VM) on your laptop for users looking to try out Kubernetes or develop with it day-to-day. Normally, it is used in conjunction with VirtualBox.
You can find more information in the official Kubernetes documentation on how to install Minikube in your local personal environment. When you installed it, run the following command to create a minikube cluster:
This will create the Kubernetes cluster, and you will be ready to use it. Verify that it works with the following command:
You will see one node called
If you do not want to use a virtual machine hypervisor, then Kind is a tool for running local Kubernetes clusters using Docker container "nodes" (Kind stands for "Kubernetes IN Docker" indeed).
kind on your environment following the instructions in the Quickstart,
then create a Kubernetes cluster with:
Download Red Hat CRC and move the binary inside a directory in your
Run the following commands:
crc startoutput will explain how to proceed.
Execute the output of the
Log in as
kubeadminwith the printed
oc logincommand. You can also open the web console running
crc console. User and password are the same as for the
CRC doesn't come with a StorageClass, so one has to be configured. Follow the Dynamic volume provisioning wiki page and install
Now that you have a Kubernetes installation up and running on your laptop, you can proceed with EDB Postgres for Kubernetes installation.
Refer to the "Installation" section and then proceed with the deployment of a PostgreSQL cluster.
As with any other deployment in Kubernetes, to deploy a PostgreSQL cluster
you need to apply a configuration file that defines your desired
cluster-example.yaml sample file
defines a simple
Cluster using the default storage class to allocate
For more detailed information about the available options, please refer to the "API Reference" section.
In order to create the 3-node PostgreSQL cluster, you need to run the following command:
You can check that the pods are being created with the
get pods command:
That will look for pods in the default namespace. To separate your cluster
from other workloads on your Kubernetes installation, you could always create
a new namespace to deploy clusters on.
Alternatively, you can use labels. The operator will apply the
label on all objects relevant to a particular cluster. For example:
Note that we are using
k8s.enterprisedb.io/cluster as the label. In the past you may
have seen or used
postgresql. This label is being deprecated, and
will be dropped in the future. Please use
By default, the operator will install the latest available minor version
of the latest major version of PostgreSQL when the operator was released.
You can override this by setting the
imageName key in the
spec section of
Cluster definition. For example, to install PostgreSQL 13.6:
The immutable infrastructure paradigm requires that you always
point to a specific version of the container image.
Never use tags like
13 in a production environment
as it might lead to unpredictable scenarios in terms of update
policies and version consistency in the cluster.
For strict deterministic and repeatable deployments, you can add the digests
to the image name, through the
There are some examples cluster configurations bundled with the operator. Please refer to the "Examples" section.
Installing Prometheus and Grafana is beyond the scope of this project. The instructions in this section are provided for experimentation and illustration only.
In this section we show how to deploy Prometheus and Grafana for observability, and how to create a Grafana Dashboard to monitor EDB Postgres for Kubernetes clusters, and a set of Prometheus Rules defining alert conditions.
We include a configuration file for the deployment of this Helm chart that will provide useful initial settings for observability of EDB Postgres for Kubernetes clusters.
We need to add the
prometheus-community helm chart repository, and then
install the Kube Prometheus stack using the sample configuration we provide:
We can accomplish this with the following commands:
After completion, you will have Prometheus, Grafana and Alert Manager installed with values from the
- From the Prometheus installation, you will have the Prometheus Operator watching for any
- The Grafana installation will be watching for a Grafana dashboard
For further information about the above command see the helm install documentation.
You can see several Custom Resources have been created:
as well as a series of Services:
At this point, a EDB Postgres for Kubernetes cluster deployed with Monitoring activated would be observable via Prometheus.
For example, you could deploy a simple cluster with
To access Prometheus, port-forward the Prometheus service:
Then access the Prometheus console locally at:
Assuming that the monitoring stack was successfully deployed, and you have a Cluster with
you should find a series of metrics relating to EDB Postgres for Kubernetes clusters. Again, please
refer to the monitoring section for more information.
You can now define some alerts by creating a
You should see the default alerts now:
In the Prometheus console, you can click on the Alerts menu to see the alerts we just installed.
In our "plain" installation, Grafana is deployed with no predefined dashboards.
You can port-forward:
And access Grafana locally at
providing the credentials
admin as username,
prom-operator as password (defined in
We can now install our sample Grafana dashboard:
Which will be picked up by the Grafana page in a few seconds. You should now
EDB Postgres for Kubernetes dashboard.
Some graphs in the previous dashboard make use of metrics that are in alpha stage by the time
this was created, like
producing some graphs to show
Note that in our example setup, both Prometheus and Grafana will pick up any other EDB Postgres for Kubernetes clusters deployed with Monitoring activated.