Operators
About
Operators are software extensions to Kubernetes that make use of custom resources to manage applications and their components. Operators follow Kubernetes principles, notably the control loop.
The operator pattern aims to capture the key aim of a human operator who is managing a service or set of services. Human operators who look after specific applications and services have deep knowledge of how the system ought to behave, how to deploy it, and how to react if there are problems.
Our first operator, PostgreSQL
Rather than deploy a VM, install postgres and manage it by hand, let's use an operator to do all the heavy lifting for us. With the operator installed we can declaratively write how we want our cluster to be, how many nodes, what type of replication and how backups happen. All with a few lines of yaml.. so let's go!
Crunchy Data PGO
A company named Crunchy Data have written a great PGSQL operator, Crunchy Data PGO. It provides high-availability, disaster-recovery, monitoring, TLS.. everything a good postgres cluster needs.
Install the operator
The recommended install method is to fork the repository, so hit github to create the fork and we'll continue on from there.
Clone your fork to your local workstation
YOUR_GITHUB_UN="$YOUR_GITHUB_USERNAME"
git clone --depth 1 "git@github.com:${YOUR_GITHUB_UN}/postgres-operator-examples.git"
cd postgres-operator-examples
Now we're ready to install:
kubectl apply -k kustomize/install/namespace
kubectl apply --server-side -k kustomize/install/default
and we can check the status by running:
kubectl -n postgres-operator get pods \
--selector=postgres-operator.crunchydata.com/control-plane=postgres-operator \
--field-selector=status.phase=Running
Once you you see 1 pod with Running status like below
Congratulations, you've now got an operator installed and are ready to use it to create a postgresql cluster.