---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: github-runner
  namespace: default
  labels:
    app: github-runner
spec:
  replicas: 1
  selector:
    matchLabels:
      app: github-runner
  template:
    metadata:
      labels:
        app: github-runner
    spec:
      volumes:
        - name: dind-storage
          emptyDir: {}
        - name: runner-storage
          emptyDir: {}
      containers:
      - name: runner
        image: kubops/github-runner:latest
        resources:
          limits:
            cpu: 500m
            memory: 512Mi
          requests:
            cpu: 500m
            memory: 512Mi
        volumeMounts:
          - name:  runner-storage
            mountPath: /home/runner/workspace
        env:
        - name: DOCKER_HOST
          value: 127.0.0.1
        - name: DOCKER_BUILDKIT
          value: "1"
        - name: GITHUB_PAT
          valueFrom:
            secretKeyRef:
              name: github-runner
              key: GITHUB_PAT
        - name: GITHUB_OWNER
          valueFrom:
            secretKeyRef:
              name: github-runner
              key: GITHUB_OWNER
        - name: GITHUB_REPOSITORY
          valueFrom:
            secretKeyRef:
              name: github-runner
              key: GITHUB_REPOSITORY
      - name: dind
        image: docker:19.03.13-dind
        command: ["dockerd"]
        args: ["--host=unix:///var/run/docker.sock", "--host=tcp://0.0.0.0:2375"]
        resources:
          limits:
            memory: "1024Mi"
            cpu: "1000m"
          requests:
            memory: "1024Mi"
            cpu: "1000m"
        securityContext:
          privileged: true
        volumeMounts:
          - name: dind-storage
            mountPath: /var/lib/docker
          - name:  runner-storage
            mountPath: /home/runner/workspace