---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  labels:
    app.kubernetes.io/name: $SERVICE_NAME
    release: "0.1"
  name: $SERVICE_NAME
  namespace: gitlab
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: $SERVICE_NAME
      release: "0.1"
  serviceName: $SERVICE_NAME
  template:
    metadata:
      labels:
        app.kubernetes.io/name: $SERVICE_NAME
        release: "0.1"
    spec:
      containers:
      - name: $SERVICE_NAME
        image: gitlab/gitlab-runner:alpine-v$VERSION_GITLAB_RUNNER
        volumeMounts:
        - mountPath: /etc/gitlab-runner
          name: config
        - mountPath: /var/run/docker.sock
          name: docker-socket
        - mountPath: /etc/gitlab-runner/certs/ca.crt
          name: $CA_SECRET
          readOnly: true
          subPath: tls.crt
      dnsConfig:
        nameservers: [ $DNS_SERVERS ]
        options:
        - name: use-vc
        - name: ndots
      nodeSelector:
        service.$SERVICE_NAME: allow
      serviceAccountName: gitlab-runner-dockersock
      volumes:
      - name: docker-socket
        hostPath: { path: /var/run/docker.sock }
      - name: $CA_SECRET
        secret:
          secretName: $CA_SECRET
  volumeClaimTemplates:
  - metadata:
      name: config
    spec:
      accessModes: [ ReadWriteOnce ]
      resources:
        requests:
          storage: 500Mi
