evryfs/github-actions-runner-operator

Configuration of custom github labels for runners

Closed this issue · 3 comments

Is there a way to configure custom github labels for runners at startup time. I'm currently installing this via helm chart, but didn't see anything immediately apparent on how to configure those custom github labels. I could go and add the label via the UI in github to a runner, but I'd rather have the labels automatically created based on what K8s cluster I have the github operator running. Wasn't sure if this was something that was already setup in this operator and can be easily configured, or not.

Github docs:
https://docs.github.com/en/free-pro-team@latest/actions/hosting-your-own-runners/using-labels-with-self-hosted-runners

Yes, you can declare the pool like this (notice ACTIONS_RUNNER_INPUT_LABELS env var):

apiVersion: "garo.tietoevry.com/v1alpha1"
kind: GithubActionRunner
metadata:
  namespace: github-actions-runner
  name: default-pool
spec:
  # minimum amount of runners that should be available
  minRunners: 1
  # maximum amount of runners that should be available
  maxRunners: 9
  # the GitHub organization name, from https://github.com/yourGithubOrgId
  organization: XXX
  # reference to secret in same namespace containing the token for GitHub, needs org-level scope
  tokenRef:
    # name of secret
    name: github-token
    # key within secret holding the value
    key: GH_TOKEN
  reconciliationPeriod: "1m"
  # a podspec like you wish for the runners.
  # the spec here will run the one from https://github.com/evryfs/github-actions-runner as the runner,
  # with a companion dind (Docker In Docker) container.
  podTemplateSpec:
    metadata:
      annotations:
        prometheus.io/scrape: 'true'
        prometheus.io/port: '3903'
    spec:
      affinity:
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
          - weight: 100
            podAffinityTerm:
              topologyKey: kubernetes.io/hostname
              labelSelector:
                matchExpressions:
                - key: garo.tietoevry.com/pool
                  operator: In
                  values:
                  - default-pool
      serviceAccount: runner
      containers:
        - name: metrics-exporter
          image: quay.io/evryfs/github-actions-runner-metrics:v0.0.3
          imagePullPolicy: IfNotPresent
          volumeMounts:
            - mountPath: /_diag
              name: runner-diag
              readOnly: true
          ports:
            - containerPort: 3903
        - env:
            - name: RUNNER_DEBUG
              value: "true"
            - name: DOCKER_TLS_CERTDIR
              value: /certs
            - name: DOCKER_HOST
              value: tcp://localhost:2376
            # https://github.com/fabric8io/docker-maven-plugin/issues/1342:
            - name: DOCKER_TLS_VERIFY
              value: "0"
            - name: DOCKER_CERT_PATH
              value: /certs/client
            - name: GH_ORG
              value: XXX
            - name: TZ
              value: "Europe/Oslo"
            - name: ACTIONS_RUNNER_INPUT_LABELS
              value: your,favorite,labels
          envFrom:
            - secretRef:
                name: github-token
          image: quay.io/evryfs/github-actions-runner:ubuntu20-20201116.1-2.274.2
          imagePullPolicy: IfNotPresent
          lifecycle:
            preStop:
              exec:
                command:
                  - /bin/bash
                  - -c
                  - /remove_runner.sh
          name: runner
          resources:
            requests:
              cpu: 100m
              memory: 128Mi
            limits:
              cpu: 4
              memory: 4Gi
          volumeMounts:
            - mountPath: /certs
              name: docker-certs
            - mountPath: /home/runner/_work
              name: runner-work
            - mountPath: /home/runner/.m2
              name: mvn-repo
            - mountPath: /home/runner/_diag
              name: runner-diag
            - mountPath: /home/runner/.m2/settings.xml
              name: settings-xml
              subPath: settings.xml
            - mountPath: /home/runner/.m2/settings-security.xml
              name: settings-xml
              subPath: settings-security.xml
        - env:
            - name: DOCKER_TLS_CERTDIR
              value: /certs
            - name: TZ
              value: "Europe/Oslo"
          image: docker:19.03.13-dind
          args:
          - --mtu=1430
          workingDir: /tmp
          name: docker
          resources:
            requests:
              cpu: 100m
              memory: 128Mi
            limits:
              cpu: 4
              memory: 4Gi
          securityContext:
            privileged: true
          volumeMounts:
            - mountPath: /var/lib/docker
              name: docker-storage
            - mountPath: /certs
              name: docker-certs
            - mountPath: /home/runner/_work
              name: runner-work
      volumes:
        - emptyDir: {}
          name: runner-work
        - emptyDir: {}
          name: runner-diag
        - emptyDir: {}
          name: mvn-repo
        - emptyDir: {}
          name: docker-storage
        - emptyDir: {}
          name: docker-certs
        - configMap:
            defaultMode: 420
            name: settings-xml
          name: settings-xml

Thanks!

Is this option ACTIONS_RUNNER_INPUT_LABELS deprecated?
Seems like it was deleted in one of the recent builds.

UPD: The feature still working if you add this.

            - name: ACTIONS_RUNNER_INPUT_LABELS
              value: your,favorite,labels

@davidkarlsen please bring it back in a future releases