# Gitea deployment with NFS-backed PVC
# Replaces the old hostPath volume with a PersistentVolumeClaim
# bound to the gitea-data-nfs PV (see pvs/gitea-pv.yaml).
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: gitea-data
  namespace: git-server
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 10Gi
  volumeName: gitea-data-nfs
  storageClassName: ""
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: gitea
  namespace: git-server
spec:
  replicas: 1
  selector:
    matchLabels:
      app: gitea
  template:
    metadata:
      labels:
        app: gitea
    spec:
      containers:
        - name: gitea
          image: gitea/gitea:latest
          imagePullPolicy: Always
          ports:
            - containerPort: 3000
            - containerPort: 22
          volumeMounts:
            - mountPath: /data
              name: gitea-data
      volumes:
        - name: gitea-data
          persistentVolumeClaim:
            claimName: gitea-data
---
apiVersion: v1
kind: Service
metadata:
  name: gitea-service
  namespace: git-server
spec:
  type: NodePort
  selector:
    app: gitea
  ports:
    - name: http
      port: 3000
      targetPort: 3000
      nodePort: 30300
    - name: ssh
      port: 22
      targetPort: 22
      nodePort: 30022
