Quickstart v1
This section guides you through testing a PostgreSQL cluster on your local machine by deploying EDB Postgres for Kubernetes on a local Kubernetes cluster using either Kind or Minikube.
Red Hat OpenShift Container Platform users can test the certified operator for EDB Postgres for Kubernetes on the Red Hat OpenShift Local (formerly Red Hat CodeReady Containers).
Warning
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.
Important
Make sure that you have kubectl
installed on your machine in order
to connect to the Kubernetes cluster, or oc
if using OpenShift Local.
Please follow the Kubernetes documentation on how to install kubectl
or the Openshift documentation on how to install oc
.
Note
If you are running Openshift, use oc
every time kubectl
is mentioned
in this documentation. kubectl
commands are compatible with oc
ones.
Part 1 - Setup the local Kubernetes/Openshift Local playground
The first part is about installing Minikube, Kind, or OpenShift Local. 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
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 minikube
.
Kind
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).
Install kind
on your environment following the instructions in the Quickstart,
then create a Kubernetes cluster with:
OpenShift Local (formerly CodeReady Containers (CRC))
Download OpenShift Local and move the binary inside a directory in your
PATH
.Run the following commands:
The
crc start
output will explain how to proceed.
Execute the output of the
crc oc-env
command.Log in as
kubeadmin
with the printedoc login
command. You can also open the web console runningcrc console
. User and password are the same as for theoc login
command.OpenShift Local doesn't come with a StorageClass, so one has to be configured. Follow the Dynamic volume provisioning wiki page and install
rancher/local-path-provisioner
.
Part 2: Install EDB Postgres for Kubernetes
Now that you have a Kubernetes installation up and running on your laptop, you can proceed with EDB Postgres for Kubernetes installation.
Unless specified in a cluster configuration file, EDB Postgres for Kubernetes will currently deploy Community Postgresql operands by default. See the section Deploying EDB Postgres servers for more information.
Refer to the "Installation" section and then proceed with the deployment of a PostgreSQL cluster.
Part 3: Deploy 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
.
The cluster-example.yaml
sample file
defines a simple Cluster
using the default storage class to allocate
disk space:
There's more
For more detailed information about the available options, please refer to the "API Reference" section.
In order to create the 3-node Community 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 k8s.enterprisedb.io/cluster
label on all objects relevant to a particular cluster. For example:
Important
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 k8s.enterprisedb.io/cluster
.
Deploying EDB Postgres servers
By default, the operator will install the latest available minor version
of the latest major version of Community PostgreSQL when the operator was released.
You can override this by setting the imageName
key in the spec
section of
the Cluster
definition. For example, to install EDB Postgres Advanced 16.4 you can use: