I have a 1 master and 2 nodes configured with Istio and metallb, but I cant get to works a postgresql stetefullset. I also have configured a DNS record to redirect the request.
All pods and statefulset are Runing, but I get this error when I try to connect:
"Expected authentication request from server, but received H"
What im doing wrong?
apiVersion: v1
kind: Namespace
metadata:
name: awx
labels:
istio-injection: enabled
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: postgresql-db
namespace: awx
spec:
serviceName: postgresql-db
selector:
matchLabels:
app: postgresql-db
replicas: 2
template:
metadata:
labels:
app: postgresql-db
spec:
containers:
- name: postgresql-db
image: postgres:12.7
volumeMounts:
- name: postgresql-db-disk
mountPath: /data
# Config from Secret
envFrom:
- secretRef:
name: postgres-db-secret
ports:
- containerPort: 5432
name: postgresdb
# Volume Claim
volumeClaimTemplates:
- metadata:
name: postgresql-db-disk
namespace: awx
spec:
accessModes: ["ReadWriteOnce"]
storageClassName: "local-storage"
resources:
requests:
storage: 1Gi
---
apiVersion: v1
kind: Service
metadata:
name: postgres-db
namespace: awx
labels:
app: postgresql-db
spec:
selector:
app: postgresql-db
type: ClusterIP
ports:
- name: tcp
port: 5432
protocol: TCP
targetPort: 5432
---
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
name: postgresql-db
namespace: awx
spec:
host: postgresql-db
trafficPolicy:
tls:
mode: DISABLE
---
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: postgresql-db-gateway
namespace: awx
spec:
selector:
istio: ingressgateway # use istio default controller
servers:
- port:
number: 80
name: http-postgresql-db
protocol: HTTP
hosts:
- "*"
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: postgresql-db-vs
namespace: awx
spec:
hosts:
- "postgresql.awx.k8s"
gateways:
- postgresql-db-gateway
http:
- route:
- destination:
host: postgresql-db
port:
number: 5432
---
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: local-storage
namespace: awx
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer
#volumeBindingMode: Immediate
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: postgres-pv-1
namespace: awx
spec:
capacity:
storage: 1Gi
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Delete
storageClassName: local-storage
local:
path: /home/xxx/storage/postgres
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- k8snode01
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: postgres-pv-2
namespace: awx
spec:
capacity:
storage: 1Gi
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Delete
storageClassName: local-storage
local:
path: /home/xxx/storage/postgres
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- k8snode02
---
apiVersion: v1
kind: Secret
metadata:
name: postgres-db-secret
namespace: awx
type: Opaque
stringData:
POSTGRES_DB: awxDB
POSTGRES_USER: awxUSER
POSTGRES_PASSWORD: awxPASSWORD
PGDATA: /data/pgdata