apiVersion: apps/v1
kind: Deployment
metadata:
  name: efs-rsync-target
  namespace: production
  labels:
    app: efs-rsync-target
spec:
  replicas: 1
  selector:
    matchLabels:
      app: efs-rsync-target
  template:
    metadata:
      labels:
        app: efs-rsync-target
    spec:
      containers:
      - name: efs-rsync-target
        image: docker.io/debian:bookworm-slim
        command:
          - /bin/sh
          - -c
          # also forward postgresql connections for developer access
          - "apt-get update && apt-get install -y rsync socat && socat tcp4-listen:5432,fork,reuseaddr tcp4:database-2.ctreuprwt6kf.us-east-1.rds.amazonaws.com:5432"
        ports:
        - containerPort: 5432
        volumeMounts:
        - name: persistent-storage
          mountPath: /data
      volumes:
      - name: persistent-storage
        persistentVolumeClaim:
          claimName: efs-claim
---
apiVersion: v1
kind: Service
metadata:
  name: postgres-proxy
  namespace: production
spec:
  selector:
    app: efs-rsync-target
  ports:
    - protocol: TCP
      port: 5432
      targetPort: 5432
---
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: efs-sc
provisioner: efs.csi.aws.com
---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: efs-pv
spec:
  capacity:
    storage: 10Gi
  volumeMode: Filesystem
  accessModes:
    - ReadWriteMany
  persistentVolumeReclaimPolicy: Retain
  storageClassName: efs-sc
  csi:
    driver: efs.csi.aws.com
    volumeHandle: fs-06d13f8a2e6613d57
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: efs-claim
  namespace: production
spec:
  accessModes:
    - ReadWriteMany
  storageClassName: efs-sc
  resources:
    requests:
      storage: 10Gi
