Hello @ahmed-86273 ,
I just tried below yaml files to deploy postgresdb pod , try to format it accordingly !
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pvc-postgre
spec:
accessModes:
- ReadWriteOnce
storageClassName: managed-premium
resources:
requests:
storage: 1Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: postgresdb
spec:
replicas: 1
selector:
matchLabels:
app: postgresdb
template:
metadata:
labels:
app: postgresdb
spec:
containers:
- name: postgresdb
image: postgres:latest
ports:
- containerPort: 5432
env:
- name: POSTGRES_USER
value: postgresuser
- name: POSTGRES_PASSWORD
value: postgrespwd
- name: POSTGRES_DB
value: postgresdb
- name: PGDATA
value: /var/lib/postgresql/backup
volumeMounts:
- name: database
mountPath: /var/lib/postgresql
subPath: backup
volumes:
- name: database
persistentVolumeClaim:
claimName: pvc-postgre
////////////////////////////////////////////
After deploying that YAML file , a pod will get created
//////////////////////////////////////////
Login to that POD to perform all the psql related operations:
/////////////////////////////////////////
Additionally you can expose the pod through a load balancer type service by using below yaml
apiVersion: v1
kind: Service
metadata:
name: postgres-db-lb
spec:
selector:
app: postgresdb
type: LoadBalancer
ports:
- port: 5432
//////////////////////////////////////////////
LB IP gets created
///////////////////////////////////////////
you can use that LB IP to connect by leveraging pgadmin UI tool.
Download pgadmin tool from here https://www.postgresql.org/ftp/pgadmin/pgadmin4/v6.4/windows/
Connect to it and you are good to go!
Let us know if those steps helps you out in getting started with postgres + AKS + PVC !
Regards,
Shiva.