apiVersion: apps/v1 kind: Deployment metadata: name: postgres-deployment spec: replicas: 1 selector: matchLabels: app: postgres template: metadata: labels: app: postgres spec: containers: - name: postgres image: postgis/postgis:16-3.4 env: - name: POSTGRES_USER value: "postgres" - name: POSTGRES_PASSWORD value: "password" - name: POSTGRES_DB value: "gis" ports: - containerPort: 5432 volumeMounts: - mountPath: /var/lib/postgresql/data name: pgdata - mountPath: /docker-entrypoint-initdb.d name: schema volumes: - name: pgdata persistentVolumeClaim: claimName: pgdata-pvc - name: schema hostPath: path: ${PGDATA} --- apiVersion: v1 kind: Service metadata: name: postgres-service spec: ports: - port: 5432 targetPort: 5432 selector: app: postgres type: ClusterIP --- apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: name: allow-cas-postgres spec: podSelector: matchLabels: app: cas policyTypes: - Ingress ingress: - from: - podSelector: matchLabels: app: postgres ports: - protocol: TCP port: 5432 --- apiVersion: v1 kind: PersistentVolumeClaim metadata: name: pgdata-pvc spec: accessModes: - ReadWriteOnce resources: requests: storage: 1Gi