Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---
- apiVersion: v1
- kind: Namespace
- metadata:
- name: database
- ---
- apiVersion: v1
- kind: ConfigMap
- metadata:
- namespace: database
- name: postgres-env
- labels:
- app: postgres
- data:
- POSTGRES_DB: postgresdb
- POSTGRES_USER: admin
- POSTGRES_PASSWORD: asdf
- PGDATA: /var/lib/postgresql/data/pgdata
- ---
- kind: ConfigMap
- apiVersion: v1
- metadata:
- namespace: database
- name: reproducer
- data:
- runtest.sh: |
- #!/bin/bash
- echo " ---- Installing requirements:"
- apt update > /dev/null 2>&1
- apt install net-tools vim dnsutils telnet iproute2 -y > /dev/null 2>&1
- echo " ---- Preparing pgpass:"
- echo "localhost:5432:postgresdb:admin:asdf" >> ~/.pgpass
- echo "pg:5432:postgresdb:admin:asdf" >> ~/.pgpass
- echo "pg.database:5432:postgresdb:admin:asdf" >> ~/.pgpass
- echo "pg.database.svc.cluster.local:5432:postgresdb:admin:asdf" >> ~/.pgpass
- echo "$(ip a s eth0 | grep -Po 'inet \K[\d.]+'):5432:postgresdb:admin:asdf" >> ~/.pgpass
- chmod 700 ~/.pgpass
- echo " ---- NetStat:"; netstat -plnt
- echo " ---- nslookup service:"; nslookup pg
- echo " ---- nslookup service fqdn:"; nslookup pg.database.svc.cluster.local
- echo " ---- Check local connection:"; psql -U admin postgresdb -c "\t";
- echo " ---- Check via pod IP:"; psql -h $(ip a s eth0 | grep -Po 'inet \K[\d.]+') -U admin postgresdb -c "\t";
- echo " ---- Check via service name:"; psql -h pg -U admin postgresdb -c "\t"
- echo " ---- Check via fqdn:"; psql -h pg.database.svc.cluster.local -U admin postgresdb -c "\t"
- ---
- apiVersion: extensions/v1beta1
- kind: Deployment
- metadata:
- namespace: database
- name: postgres
- spec:
- replicas: 1
- template:
- metadata:
- labels:
- app: postgres
- spec:
- containers:
- - name: postgres
- image: postgres:11.1
- imagePullPolicy: "IfNotPresent"
- ports:
- - containerPort: 5432
- envFrom:
- - configMapRef:
- name: postgres-env
- volumeMounts:
- - name: reproducer-volume
- mountPath: /reproducer
- volumes:
- - name: reproducer-volume
- configMap:
- name: reproducer
- ---
- apiVersion: v1
- kind: Service
- metadata:
- name: pg
- namespace: database
- labels:
- app: postgres
- spec:
- selector:
- app: postgres
- ports:
- - protocol: TCP
- name: postgres
- port: 5432
- targetPort: 5432
Add Comment
Please, Sign In to add comment