apiVersion: apps/v1
kind: Deployment
metadata:
  name: gitlab-deployment
  namespace: source-gitlab
spec:
  replicas: 1
  selector:
    matchLabels:
      app: gitlab
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 1
  template:
    metadata:
      labels:
        app: gitlab
    spec:
      containers:
      - name: gitlab
        image: sameersbn/gitlab:14.8.2
        env:
        - name: TZ
          value: Asia/Shanghai
        - name: GITLAB_TIMEZONE
          value: Asia/Shanghai
        - name: GITLAB_SECRETS_DB_KEY_BASE
          valueFrom:
            secretKeyRef:
              name: gitlab-secrets
              key: gitlab-secrets-db-key-base
        - name: GITLAB_SECRETS_SECRET_KEY_BASE
          valueFrom:
            secretKeyRef:
              name: gitlab-secrets
              key: gitlab-secrets-secret-key-base
        - name: GITLAB_SECRETS_OTP_KEY_BASE
          valueFrom:
            secretKeyRef:
              name: gitlab-secrets
              key: gitlab-secrets-otp-key-base
        - name: GITLAB_ROOT_PASSWORD
          valueFrom:
            secretKeyRef:
              name: gitlab-secrets
              key: gitlab-root-password
        - name: GITLAB_ROOT_EMAIL
          value: source@feishu.cn

        - name: GITLAB_EMAIL
          value: source@feishu.cn
        - name: GITLAB_EMAIL_REPLY_TO
          value: noreply@feishu.cn
        - name: GITLAB_INCOMING_EMAIL_ADDRESS
          value: reply@feishu.cn

        - name: GITLAB_HOST
          value: source.openeuler.sh
        - name: GITLAB_PORT
          value: "80"
        - name: GITLAB_SSH_PORT
          value: "22"

        - name: GITLAB_NOTIFY_ON_BROKEN_BUILDS
          value: "true"
        - name: GITLAB_NOTIFY_PUSHER
          value: "false"

        - name: GITLAB_BACKUP_SCHEDULE
          value: daily
        - name: GITLAB_BACKUP_TIME
          value: 01:00

        - name: DB_TYPE
          value: postgres
        - name: DB_HOST
          value: 172.16.1.63
        - name: DB_PORT
          value: "5432"
        - name: DB_USER
          value: root
        - name: DB_PASS
          valueFrom:
            secretKeyRef:
              name: gitlab-secrets
              key: postgres-password
        - name: DB_NAME
          value: postgres

        - name: REDIS_HOST
          value: redis-0.redis-service.source-gitlab.svc.cluster.local
        - name: REDIS_PORT
          value: "6379"

        - name: SMTP_ENABLED
          value: "true"
        - name: SMTP_DOMAIN
          value: feishu.cn
        - name: SMTP_HOST
          value: smtp.feishu.cn
        - name: SMTP_PORT
          value: "587"
        - name: SMTP_USER
          value: source@openeuler.sh
        - name: SMTP_PASS
          valueFrom:
            secretKeyRef:
              name: gitlab-secrets
              key: smtp-password
        - name: SMTP_STARTTLS
          value: "true"
        - name: SMTP_AUTHENTICATION
          value: login

        - name: IMAP_ENABLED
          value: "true"
        - name: IMAP_HOST
          value: imap.feishu.cn
        - name: IMAP_PORT
          value: "993"
        - name: IMAP_USER
          value: source@openeuler.sh
        - name: IMAP_PASS
          valueFrom:
            secretKeyRef:
              name: gitlab-secrets
              key: imap-password
        - name: IMAP_SSL
          value: "true"
        - name: IMAP_STARTTLS
          value: "true"
        ports:
        - name: http
          containerPort: 80
        - name: ssh
          containerPort: 22
        volumeMounts:
        - mountPath: /home/git/data
          name: gitlab-data
        livenessProbe:
          httpGet:
            path: /
            port: 80
          initialDelaySeconds: 300
          timeoutSeconds: 5
        readinessProbe:
          httpGet:
            path: /
            port: 80
          initialDelaySeconds: 5
          timeoutSeconds: 1
      restartPolicy: Always
      volumes:
      - name: gitlab-data
        persistentVolumeClaim:
          claimName: cce-evs-gitlab-data