Percona PostgreSQL on Fly Kubernetes

We’ve been playing around with Percona’s PostgreSQL operator as a way to figure out what features FKS is missing and get it up to snuff. The databases here are pretty close to being usable, and we hope to fully support all of the features soon. However, this is still alpha-quality and you should not be using this for data you care about. With that out of the way, here’s how you can get a copy running in your own Fly organization:

Set up Fly Kubernetes

  1. Spin up an FKS cluster with fly ext kubernetes create
  2. Run the following to merge the new kubeconfig into ~/.kube/config
KUBECONFIG=~/.kube/config:./$NEWKUBECONFIG kubectl config view --flatten > new-cfg && mv new-cfg ~/.kube/config
  1. You may want to rename the cluster from the name default to something more specific in ~/.kube/config.
  2. Jack into your private wireguard network
  3. Switch to your new cluster with kubectl config use-context $CLUSTER
  4. kubectl version should successfully show you a valid server version

Deploy the Operator

  1. Clone the fks branch of our fork of the operator.
  2. git clone https://github.com/superfly/percona-postgresql-operator.git --branch=fks
  3. cd percona-postgresql-operator
  4. Deploy the CRDs and RBAC resources:
  5. kubectl apply --server-side -f deploy/bundle.yaml
  6. Edit the Makefile and set IMAGE_TAG_BASE to a container registry repo that you have access to push to
  7. make build-docker-image && make deploy

Create a database

  1. kubectl apply -f deploy/cr.yaml
  2. Create a service that targets the primary
kubectl apply -f - <<EOF
apiVersion: v1
kind: Service
metadata:
  labels:
    app: primary-fly
  name: primary-fly
spec:
  type: ClusterIP
  ports:
  - name: 5432-5432
    port: 5432
    protocol: TCP
    targetPort: 5432
  selector:
    postgres-operator.crunchydata.com/cluster: cluster1
    postgres-operator.crunchydata.com/role: master
EOF
  1. Watch your pods come up (kubectl get pods -w)
  2. Now, you should be able to connect via psql to the primary-fly service fdaa IP with the credentials in the cluster1-pguser-cluster1 ConfigMap.
$ kubectl get service primary-fly
NAME          TYPE        CLUSTER-IP            EXTERNAL-IP   PORT(S)    AGE
primary-fly   ClusterIP   fdaa:1:a290:0:1::92   <none>        5432/TCP   28h

$ psql 'postgresql://cluster1:<password>@[fdaa:1:a290:0:1::92]:5432/cluster1'
psql (16.3)
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, compression: off)
Type "help" for help.

cluster1=> 
3 Likes