Deploying VMware Tanzu Data for K8S on GCE Part 2: Access Postgres

Photo by Daniel Cheung on Unsplash

This article is part 2 of Tanzu SQL Postgres. I demo how to access the instance through service and Kube-proxy to DBeaver on your desktop. The whole idea is putting some data into the pg-instance, and other deployments can consume it.

In Part1, I used “kubectl exec” to test the postgres connection. Does anyone really use that to run CRUD?

Let me show you a “little” better approach first. I can use kubectl port-forward to proxy the pg-instance-1 service to my local desktop port, then use DBeaver to access the instance.

First, let’s make sure the service is running and kube_dns can resolve it. “kubectl get svc” shows pg-instance-1 service has port 5432/TCP.

The following is a DNS_Utils I used to check the resolution.

This nslookup confirms that I have my Tanzu SQL Postgres exposed as a service and accessed through the Cluster_IP. Now I can use port forward to proxy this service to my local desktop port (localhost).

The default template of DBeaver Postgres connection setting is perfect (nothing to change).

Let’s load some data! Check this out

After I restored the dvdrental from EDB, you can see my port-forward terminal traffic like this.

And I have data restored to my Tanzu SQL Postgres instance. Next part, let’s deploy a Blockduster online store consuming this instance in K8s. Stay tuned.

A data nerd started from data center field engineer to cloud database reliability engineer.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store