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
- Spin up an FKS cluster with
fly ext kubernetes create
- 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
- You may want to rename the cluster from the name
default
to something more specific in~/.kube/config
. - Jack into your private wireguard network
- Switch to your new cluster with
kubectl config use-context $CLUSTER
kubectl version
should successfully show you a valid server version
Deploy the Operator
- Clone the
fks
branch of our fork of the operator. git clone https://github.com/superfly/percona-postgresql-operator.git --branch=fks
cd percona-postgresql-operator
- Deploy the CRDs and RBAC resources:
kubectl apply --server-side -f deploy/bundle.yaml
- Edit the
Makefile
and setIMAGE_TAG_BASE
to a container registry repo that you have access to push to make build-docker-image && make deploy
Create a database
kubectl apply -f deploy/cr.yaml
- 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
- Watch your pods come up (
kubectl get pods -w
) - Now, you should be able to connect via
psql
to theprimary-fly
servicefdaa
IP with the credentials in thecluster1-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=>