Install Crunchy Data Postgres operator

2 minute read

It’s pretty simple, following the documentation, and tested with version 4.6.2 (commands super slightly adapted). Normally you might download the YAML file and adjust the installation settings in there, this is not done here (mainly because this is just a handling test).

export CRUNCHY_BASE=https://raw.githubusercontent.com/CrunchyData/postgres-operator
kubectl create namespace pgo
kubectl apply -f $CRUNCHY_BASE/v4.6.2/installers/kubectl/postgres-operator.yml

# install pgo binary - https://is.gd/U00wux
curl $CRUNCHY_BASE/v4.6.2/installers/kubectl/client-setup.sh > client-setup.sh
bash client-setup.sh
rm client-setup.sh

# THIS IS IMPORTANT
kubectl delete job -n pgo pgo-deploy

Using the pgo binary

Every time you want to use the binary you have to port-forward to the operator container, and set PGO_APISERVER_URL:

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

# second shell
export PGO_APISERVER_URL="https://127.0.0.1:8443"
pgo version

Upgrading the operator (untested)

Just apply the same manifest, but set the DEPLOY_ACTION in the YAML postgres-operator.yaml manifest to upgrade. You can do this by downloading and modifying, or just in a one-liner:

export CRUNCHY_BASE=https://raw.githubusercontent.com/CrunchyData/postgres-operator
export CRUNCHY_YAML=$CRUNCHY_BASE/v4.6.2/installers/kubectl/postgres-operator.yml
curl $CRUNCHY_YAML | sed 's/value: install/value: upgrade/g' | kubectl apply -f -

NOTE: If you get a huge error message you forgot to delete the job after the installation.

Uninstalling the operator

Like upgrade, but with the value uninstall.

export CRUNCHY_BASE=https://raw.githubusercontent.com/CrunchyData/postgres-operator
export CRUNCHY_YAML=$CRUNCHY_BASE/v4.6.2/installers/kubectl/postgres-operator.yml
curl $CRUNCHY_YAML | sed 's/value: install/value: uninstall/g' | kubectl apply -f -

NOTE: If you get a huge error message you forgot to delete the job after the installation.

Afterwards clean up the remaining stuff which is created by $CRUNCHY_YAML defined above:

kubectl delete job -n pgo pgo-deploy
kubectl delete clusterrolebinding pgo-deployer-crb
kubectl delete configmap pgo-deployer-cm
kubectl delete clusterrole pgo-deployer-cr
kubectl delete serviceaccount pgo-deployer-sa
kubectl delete namespace pgo

Impressions

  • Installing using the operator framework at operatorhub didn’t work. The framework failed to install.
  • I don’t like that the pgo binary is installed for every namespace you are using. This seems weird, it should somehow follow “standard” k8s RBAC, or the principle of kubectl contexts.
  • I also don’t like that the installation method is static and you cannot change the namespace without downloading and editing the files apparently.
  • I very much like the CLI approach, yet at the same time …
  • … it leaves the declarative “everything is a CRD / an API object” approach.

So … mixed. Haven’t tried the databases - yet.