Connect

How to connect to Your instance

Problem

You either want to connect to your PostgreSQL cluster from outside of the cluster or need to port forward so that you can use your favorite database management tool.

LoadBalancer

While using LoadBalancer, additional charges may apply for additional IPv4 addresses. Check pricing

LoadBalancer service type is supported on LPG-2 Appuio Cluster, and You can use it by setting:

apiVersion: vshn.appcat.vshn.io/v1
kind: VSHNPostgreSQL
metadata:
  name: my-postgresql
  namespace: app1-dev
spec:
  parameters:
    network:
      serviceType: LoadBalancer
    backup:
      deletionProtection: false
  writeConnectionSecretToRef:
    name: my-postgresql-dev-connection

This YAML snippet would create a PostgreSQL cluster and Service of type LoadBalancer. The Service would be accessible from outside of the cluster. You can get IP address of the service using either:

kubectl -n $instanceNamespace get service primary-service

Or access it directly from the connection secret:

kubectl -n app1-dev get secrets my-postgresql-dev-connection -o yaml | yq .data.LOADBALANCER_IP  | base64 -d

Port-forward

This is the default serviceType

You can port-forward to your PostgreSQL cluster using the kubectl port-forward command. This command always works, no matter what is set as serviceType.

kubectl -n $instanceNamespace port-forward services/primary-service 5432