Accessing a Greenplum Cluster in Kubernetes

After you deploy a new Greenplum cluster to Kubernetes, you can access the cluster either by executing Greenplum utilities from within Kubernetes, or by using a locally-installed tool, such as psql, to access the Greenplum instance running in Kubernetes.

Accessing a Pod via Kubectl

Use the kubectl tool to run utilities directly in a Greenplum for Kubernetes pod. For example, to execute psql:

$ kubectl exec -it master-0 bash -- -c "source /opt/gpdb/; psql"
psql (8.3.23)
Type "help" for help.

You can also simply execute a bash shell and then execute multiple Greenplum utilities as necessary. For example:

$ kubectl exec -it master-0 -- /bin/bash
gpadmin@master-0:~$ gpstate
20181011:23:50:35:002410 gpstate:master-0:gpadmin-[INFO]:-Starting gpstate with args: 
20181011:23:50:36:002410 gpstate:master-0:gpadmin-[INFO]:-local Greenplum Version: 'postgres (Greenplum Database) 5.11.3 build dev'
20181011:23:50:36:002410 gpstate:master-0:gpadmin-[INFO]:-master Greenplum Version: 'PostgreSQL 8.3.23 (Greenplum Database 5.11.3 build dev) on x86_64-pc-linux-gnu, compiled by GCC gcc (Ubuntu 6.4.0-17ubuntu1~16.04) 6.4.0 20180424, 64-bit compiled on Oct 10 2018 22:25:23'
20181011:23:50:37:002410 gpstate:master-0:gpadmin-[INFO]:-Obtaining Segment details from master...
20181011:23:50:37:002410 gpstate:master-0:gpadmin-[INFO]:-Gathering data from segments...

Substitute the name of a different pod to access, for example, the standby master or an individual segment instance.

Accessing Greenplum from External Clients

If you have installed psql or another client application outside of Kubernetes (for example, on your local client machine), then you need to obtain the address and port number at which you can reach the Greenplum cluster. Follow these steps:

  1. For PKS or GKE deployments, the Greenplum load balancer provides the external address and port you can use to reach the cluster:

    $ kubectl get service/greenplum
    NAME        TYPE           CLUSTER-IP       EXTERNAL-IP   PORT(S)          AGE
    greenplum   LoadBalancer 5432:31643/TCP   13m
  2. For Minikube deployments, the Greenplum load balancer is not used. Instead, look for the greenplum entry in the output from minikube service list:

    $ minikube service list
    |  NAMESPACE  |         NAME         |            URL             |
    | default     | agent                | No node port               |
    | default     | greenplum            | |
    | default     | kubernetes           | No node port               |
    | kube-system | kube-dns             | No node port               |
    | kube-system | kubernetes-dashboard | |
    | kube-system | tiller-deploy        | No node port               |
  3. After you obtain the correct IP address and port, use them to connect to the Greenplum instance. For example, with a local psql client:

    $ psql -h -p 31643 -U gpadmin