apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: gogs-pv-claim
  namespace: gogs
  labels:
    app: gogs-app
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: ""
  resources:
    requests:
      storage: 10Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: gogs
  namespace: gogs
  labels:
    app: gogs-app
spec:
  selector:
    matchLabels:
      app: gogs-app
      tier: frontend
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: gogs-app
        tier: frontend
    spec:
      containers:
      - image: docker-registry:32000/gogs:1.0
        name: gogs
        env:
        - name: DB_TYPE
          value: mysql
        - name: DB_NAME
          value: gogs
        - name: DB_HOST
          value: gogs-mysql
        - name: DB_PASS
          valueFrom:
            secretKeyRef:
              name: mysqlgogs-pass
              key: password
        - name: DB_USER
          valueFrom:
            secretKeyRef:
              name: mysqlgogs-pass
              key: db_user
        ports:
          - containerPort: 3000
            name: http
            protocol: TCP
          - containerPort: 22
            name: ssh
            protocol: TCP
        volumeMounts:
        - name: gogs-persistent-storage
          mountPath: /data
      imagePullSecrets:
      - name: reg-cred-secret
      volumes:
      - name: gogs-persistent-storage
        persistentVolumeClaim:
          claimName: gogs-pv-claim
