back to downloads

Crunchy PostgreSQL Operator

Run your own production-grade PostgreSQL-as-a-Service on Kubernetes!

4.5.0
linux
amd64
View Crunchy PostgreSQL Operator documentation

Step 1: Install the PostgreSQL Operator

On environments that have a default storage class set up (which is most modern Kubernetes environments), the below command should work:

kubectl create namespace pgo
kubectl apply -f https://raw.githubusercontent.com/CrunchyData/postgres-operator/v4.5.0/installers/kubectl/postgres-operator.yml

This will launch the pgo-deployer container that will run the various setup and installation jobs. This can take a few minutes to complete depending on your Kubernetes cluster.

If your install is unsuccessful, you may need to modify your configuration. Please read the "Troubleshooting" section of the documentation. You can still get up and running fairly quickly with just a little bit of configuration.

Step 2: Install pgo Client

During or after the installation of the PostgreSQL Operator, download the pgo client set up script. This will help set up your local environment for using the PostgreSQL Operator:

curl https://raw.githubusercontent.com/CrunchyData/postgres-operator/v4.5.0/installers/kubectl/client-setup.sh > client-setup.sh
chmod +x client-setup.sh

When the PostgreSQL Operator is done installing, run the client setup script:

./client-setup.sh

This will download the pgo client and provide instructions for how to easily use it in your environment. It will prompt you to add some environmental variables for you to set up in your session, which you can do with the following commands:

export PGOUSER="${HOME?}/.pgo/pgo/pgouser"
export PGO_CA_CERT="${HOME?}/.pgo/pgo/client.crt"
export PGO_CLIENT_CERT="${HOME?}/.pgo/pgo/client.crt"
export PGO_CLIENT_KEY="${HOME?}/.pgo/pgo/client.key"
export PGO_APISERVER_URL='https://127.0.0.1:8443'
export PGO_NAMESPACE=pgo

If you wish to permanently add these variables to your environment, you can run the following:

cat <<EOF >> ~/.bashrc
export PGOUSER="${HOME?}/.pgo/pgo/pgouser"
export PGO_CA_CERT="${HOME?}/.pgo/pgo/client.crt"
export PGO_CLIENT_CERT="${HOME?}/.pgo/pgo/client.crt"
export PGO_CLIENT_KEY="${HOME?}/.pgo/pgo/client.key"
export PGO_APISERVER_URL='https://127.0.0.1:8443'
export PGO_NAMESPACE=pgo
EOF

source ~/.bashrc

NOTE: For macOS users, you must use ~/.bash_profile instead of ~/.bashrc

Step 3: Verification

Below are a few steps to check if the PostgreSQL Operator is up and running.

By default, the PostgreSQL Operator installs into a namespace called pgo. First, see that the the Kubernetes Deployment of the Operator exists and is healthy:

kubectl -n pgo get deployments

If successful, you should see output similar to this:

NAME                READY   UP-TO-DATE   AVAILABLE   AGE
postgres-operator   1/1     1            1           16h

Next, see if the Pods that run the PostgreSQL Operator are up and running:

kubectl -n pgo get pods

If successful, you should see output similar to this:

NAME                                READY   STATUS    RESTARTS   AGE
postgres-operator-56d6ccb97-tmz7m   4/4     Running   0          2m

Finally, let's see if we can connect to the PostgreSQL Operator from the pgo command-line client. The Ansible installer installs the pgo command line client into your environment, along with the username/password file that allows you to access the PostgreSQL Operator. In order to communicate with the PostgreSQL Operator API server, you will first need to set up a port forward to your local environment.

In a new console window, run the following command to set up a port forward:

kubectl -n pgo port-forward svc/postgres-operator 8443:8443

Back to your original console window, you can verify that you can connect to the PostgreSQL Operator using the following command:

pgo version

If successful, you should see output similar to this:

pgo client version 4.5.0
pgo-apiserver version 4.5.0

Step 4: Have Some Fun - Create a PostgreSQL Cluster

The quickstart installation method creates a namespace called pgo where the PostgreSQL Operator manages PostgreSQL clusters. Try creating a PostgreSQL cluster called hippo:

pgo create cluster -n pgo hippo

Alternatively, because we set the PGO_NAMESPACE environmental variable in our .bashrc file, we could omit the -n flag from the pgo create cluster command and just run this:

pgo create cluster hippo

Even with PGO_NAMESPACE set, you can always overwrite which namespace to use by setting the -n flag for the specific command. For explicitness, we will continue to use the -n flag in the remaining examples of this quickstart.

If your cluster creation command executed successfully, you should see output similar to this:

created Pgcluster hippo
workflow id 1cd0d225-7cd4-4044-b269-aa7bedae219b

This will create a PostgreSQL cluster named hippo. It may take a few moments for the cluster to be provisioned. You can see the status of this cluster using the pgo test command:

pgo test -n pgo hippo

When everything is up and running, you should see output similar to this:

cluster : hippo
	Services
		primary (10.97.140.113:5432): UP
	Instances
		primary (hippo-7b64747476-6dr4h): UP

The pgo test command provides you the basic information you need to connect to your PostgreSQL cluster from within your Kubernetes environment. For more detailed information, you can use pgo show cluster -n pgo hippo.

Next Steps

Want to learn more about the PostgreSQL Operator? Browse through the tutorial to learn more about what you can do!

TAGS:

4.5.0

docker pull registry.developers.crunchydata.com/crunchydata/postgres-operator:centos8-4.5.0
COMPRESSED SIZE: 365.02 MB

4.5.0

docker pull registry.developers.crunchydata.com/crunchydata/postgres-operator:centos7-4.5.0
COMPRESSED SIZE: 339.68 MB

4.4.1

docker pull registry.developers.crunchydata.com/crunchydata/postgres-operator:centos7-4.4.1
COMPRESSED SIZE: 340.07 MB

4.4.0

docker pull registry.developers.crunchydata.com/crunchydata/postgres-operator:centos7-4.4.0
COMPRESSED SIZE: 387.95 MB

4.4.0-beta.2

docker pull registry.developers.crunchydata.com/crunchydata/postgres-operator:centos7-4.4.0-beta.2
COMPRESSED SIZE: 387.17 MB

4.3.2

docker pull registry.developers.crunchydata.com/crunchydata/postgres-operator:centos7-4.3.2
COMPRESSED SIZE: 385.49 MB

4.3.0

docker pull registry.developers.crunchydata.com/crunchydata/postgres-operator:centos7-4.3.0
COMPRESSED SIZE: 486.61 MB

4.3.0-beta.2

docker pull registry.developers.crunchydata.com/crunchydata/postgres-operator:centos7-4.3.0-beta.2
COMPRESSED SIZE: 395.98 MB

4.3.0-beta.1

docker pull registry.developers.crunchydata.com/crunchydata/postgres-operator:centos7-4.3.0-beta.1
COMPRESSED SIZE: 393.73 MB

4.2.2

docker pull registry.developers.crunchydata.com/crunchydata/postgres-operator:centos7-4.2.2
COMPRESSED SIZE: 386.86 MB