apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  annotations:
    deployment.kubernetes.io/revision: "1"
  generation: 1
  labels:
    app: gitrunner-gitlab-runner
    chart: gitlab-runner-0.8.0-beta
    release: gitrunner
  name: gitrunner-gitlab-runner
spec:
  replicas: 1
  selector:
    matchLabels:
      app: gitrunner-gitlab-runner
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
    type: RollingUpdate
  template:
    metadata:
      annotations:
        prometheus.io/port: "9252"
        prometheus.io/scrape: "true"
      labels:
        app: gitrunner-gitlab-runner
    spec:
      containers:
      - command:
        - /bin/bash
        - /scripts/entrypoint
        env:
        - name: CI_SERVER_URL
          value: http://g.xxx.com.cn/ci/
        - name: CLONE_URL
        - name: RUNNER_REQUEST_CONCURRENCY
          value: "1"
        - name: RUNNER_EXECUTOR
          value: kubernetes
        - name: REGISTER_LOCKED
          value: "true"
        - name: RUNNER_TAG_LIST
          value: kubernetes-runner
        - name: KUBERNETES_IMAGE
          value: ubuntu:16.04
        - name: KUBERNETES_PRIVILEGED
          value: "true"
        - name: KUBERNETES_NAMESPACE
          value: default
        - name: KUBERNETES_CPU_LIMIT
        - name: KUBERNETES_MEMORY_LIMIT
        - name: KUBERNETES_CPU_REQUEST
        - name: KUBERNETES_MEMORY_REQUEST
        - name: KUBERNETES_SERVICE_ACCOUNT
        - name: KUBERNETES_SERVICE_CPU_LIMIT
        - name: KUBERNETES_SERVICE_MEMORY_LIMIT
        - name: KUBERNETES_SERVICE_CPU_REQUEST
        - name: KUBERNETES_SERVICE_MEMORY_REQUEST
        - name: KUBERNETES_HELPER_CPU_LIMIT
        - name: KUBERNETES_HELPER_MEMORY_LIMIT
        - name: KUBERNETES_HELPER_CPU_REQUEST
        - name: KUBERNETES_HELPER_MEMORY_REQUEST
        - name: KUBERNETES_HELPER_IMAGE
        - name: KUBERNETES_PULL_POLICY
        image: gitlab/gitlab-runner:alpine-v11.6.0
        imagePullPolicy: IfNotPresent
        lifecycle:
          preStop:
            exec:
              command:
              - gitlab-runner
              - unregister
              - --all-runners
        livenessProbe:
          exec:
            command:
            - /bin/bash
            - /scripts/check-live
          failureThreshold: 3
          initialDelaySeconds: 60
          periodSeconds: 10
          successThreshold: 1
          timeoutSeconds: 1
        name: gitrunner-gitlab-runner
        ports:
        - containerPort: 9252
          name: metrics
          protocol: TCP
        readinessProbe:
          exec:
            command:
            - /usr/bin/pgrep
            - gitlab.*runner
          failureThreshold: 3
          initialDelaySeconds: 10
          periodSeconds: 10
          successThreshold: 1
          timeoutSeconds: 1
        resources:
          limits:
            cpu: 200m
            memory: 256Mi
          requests:
            cpu: 10m
            memory: 128Mi
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
        volumeMounts:
        - mountPath: /secrets
          name: runner-secrets
        - mountPath: /home/gitlab-runner/.gitlab-runner
          name: etc-gitlab-runner
        - mountPath: /scripts
          name: scripts
      dnsPolicy: ClusterFirst
      initContainers:
      - command:
        - sh
        - /config/configure
        env:
        - name: CI_SERVER_URL
          value: http://g.xxx.com.cn/ci/
        - name: CLONE_URL
        - name: RUNNER_REQUEST_CONCURRENCY
          value: "1"
        - name: RUNNER_EXECUTOR
          value: kubernetes
        - name: REGISTER_LOCKED
          value: "true"
        - name: RUNNER_TAG_LIST
          value: kubernetes-runner
        - name: KUBERNETES_IMAGE
          value: ubuntu:16.04
        - name: KUBERNETES_PRIVILEGED
          value: "true"
        - name: KUBERNETES_NAMESPACE
          value: default
        - name: KUBERNETES_CPU_LIMIT
        - name: KUBERNETES_MEMORY_LIMIT
        - name: KUBERNETES_CPU_REQUEST
        - name: KUBERNETES_MEMORY_REQUEST
        - name: KUBERNETES_SERVICE_ACCOUNT
        - name: KUBERNETES_SERVICE_CPU_LIMIT
        - name: KUBERNETES_SERVICE_MEMORY_LIMIT
        - name: KUBERNETES_SERVICE_CPU_REQUEST
        - name: KUBERNETES_SERVICE_MEMORY_REQUEST
        - name: KUBERNETES_HELPER_CPU_LIMIT
        - name: KUBERNETES_HELPER_MEMORY_LIMIT
        - name: KUBERNETES_HELPER_CPU_REQUEST
        - name: KUBERNETES_HELPER_MEMORY_REQUEST
        - name: KUBERNETES_HELPER_IMAGE
        - name: KUBERNETES_PULL_POLICY
        image: gitlab/gitlab-runner:alpine-v11.6.0
        imagePullPolicy: IfNotPresent
        name: configure
        resources:
          limits:
            cpu: 200m
            memory: 256Mi
          requests:
            cpu: 10m
            memory: 128Mi
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
        volumeMounts:
        - mountPath: /secrets
          name: runner-secrets
        - mountPath: /config
          name: scripts
          readOnly: true
        - mountPath: /init-secrets
          name: init-runner-secrets
          readOnly: true
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext:
        fsGroup: 65533
        runAsUser: 100
      serviceAccount: gitlab
      serviceAccountName: gitlab
      terminationGracePeriodSeconds: 30
      volumes:
      - emptyDir:
          medium: Memory
        name: runner-secrets
      - emptyDir:
          medium: Memory
        name: etc-gitlab-runner
      - name: init-runner-secrets
        projected:
          defaultMode: 420
          sources:
          - secret:
              items:
              - key: runner-registration-token
                path: runner-registration-token
              - key: runner-token
                path: runner-token
              name: gitrunner-gitlab-runner
      - configMap:
          defaultMode: 420
          name: gitrunner-gitlab-runner
        name: scripts
