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

Photo by Daniel Cheung on Unsplash
ysung@ysung-a01 postgres-for-kubernetes-v1.0.0 % k exec -it pg-instance-1-0 -- psql
psql (11.9 (VMware Postgres 11.9.3))
Type "help" for help.
postgres=# \q
ysung@ysung-a01 postgres-for-kubernetes-v1.0.0 % k get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 67m
pg-instance-1 ClusterIP 10.97.198.100 <none> 5432/TCP 2m20s
pg-instance-1-agent ClusterIP None <none> <none> 2m20s
postgres-operator-webhook-service ClusterIP 10.103.143.54 <none> 443/TCP 4m33s
ysung@ysung-a01 deployments % cat test_dns.yaml
apiVersion: v1
kind: Pod
metadata:
name: dnsutils
labels:
run: dns
spec:
containers:
- name: dnsutils
image: gcr.io/kubernetes-e2e-test-images/dnsutils:1.3
command:
- sleep
- "3600"
imagePullPolicy: IfNotPresent
restartPolicy: Always
ysung@ysung-a01 deployments % k apply -f test_dns.yaml
pod/dnsutils created
ysung@ysung-a01 deployments % k exec dnsutils -- nslookup pg-instance-1
Server: 10.96.0.10
Address: 10.96.0.10#53
Name: pg-instance-1.default.svc.cluster.local
Address: 10.97.198.100
ysung@ysung-a01 kubectl % k port-forward service/pg-instance-1 5432:5432
Forwarding from 127.0.0.1:5432 -> 5432
Forwarding from [::1]:5432 -> 5432
ysung@ysung-a01 kubectl % k port-forward service/pg-instance-1 5432:5432
Forwarding from 127.0.0.1:5432 -> 5432
Forwarding from [::1]:5432 -> 5432
Handling connection for 5432
Handling connection for 5432
Handling connection for 5432
Handling connection for 5432
Handling connection for 5432
Handling connection for 5432
Handling connection for 5432
Handling connection for 5432
ysung@ysung-a01 kubectl % k exec -it pg-instance-1-0 -- psql
psql (11.9 (VMware Postgres 11.9.3))
Type "help" for help.
postgres=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+---------+---------+-----------------------
dev1 | postgres | UTF8 | C.UTF-8 | C.UTF-8 |
dverental | postgres | UTF8 | C.UTF-8 | C.UTF-8 |
postgres | postgres | UTF8 | C.UTF-8 | C.UTF-8 |
template0 | postgres | UTF8 | C.UTF-8 | C.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | C.UTF-8 | C.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
(5 rows)
postgres=# \c dverental
You are now connected to database "dverental" as user "postgres".
dverental=# \dt
List of relations
Schema | Name | Type | Owner
--------+---------------+-------+----------
public | actor | table | postgres
public | address | table | postgres
public | category | table | postgres
public | city | table | postgres
public | country | table | postgres
public | customer | table | postgres
public | film | table | postgres
public | film_actor | table | postgres
public | film_category | table | postgres
public | inventory | table | postgres
public | language | table | postgres
public | payment | table | postgres
public | rental | table | postgres
public | staff | table | postgres
public | store | table | postgres
(15 rows)
dverental=#

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