Skip to content

Commit

Permalink
feat: redevelop github-actions-runners (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
SweetOps authored Oct 1, 2021
1 parent ad8cb2d commit 5879919
Show file tree
Hide file tree
Showing 8 changed files with 153 additions and 112 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/helm-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,11 @@ jobs:
fi
- name: Run chart-testing (lint)
run: ct lint --config ct.yaml
run: ct lint --config ct.yaml

- name: Create kind cluster
uses: helm/[email protected]
if: steps.list-changed.outputs.changed == 'true'

- name: Run chart-testing (install)
run: ct install --config ct.yaml
2 changes: 1 addition & 1 deletion charts/github-actions-runners/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ apiVersion: v2
name: github-actions-runners
description: A Helm chart for provisioning Github Actions runners
type: application
version: 0.0.2
version: 0.0.3
maintainers:
- name: SweetOps
11 changes: 0 additions & 11 deletions charts/github-actions-runners/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,3 @@ Selector labels
app.kubernetes.io/name: {{ include "github-actions-runners.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "github-actions-runners.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "github-actions-runners.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
19 changes: 14 additions & 5 deletions charts/github-actions-runners/templates/hpa.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
{{- if not .Values.autoscaling.enabled }}
{{- range .Values.runnerDeployments }}
---
{{- $enabled := printf "%t" .enabled }}
{{- if regexMatch "nil" $enabled }}{{- $enabled = "true" }}{{- end }}
{{- if (eq $enabled "true") }}
{{- if .autoscaling.enabled }}
kind: HorizontalRunnerAutoscaler
apiVersion: actions.summerwind.dev/v1alpha1
metadata:
name: {{ include "github-actions-runners.fullname" . }}
name: {{ include "github-actions-runners.fullname" $ }}-{{ .name }}
labels:
{{- include "github-actions-runners.labels" . | nindent 4 }}
github-actions-runner: {{ .name }}
{{- include "github-actions-runners.labels" $ | nindent 4 }}
spec:
scaleTargetRef:
name: {{ include "github-actions-runners.fullname" . }}
{{- with .Values.autoscaling.scaleUpTriggers }}
name: {{ include "github-actions-runners.fullname" $ }}-{{ .name }}
{{- with .autoscaling.scaleUpTriggers }}
scaleUpTriggers:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
56 changes: 35 additions & 21 deletions charts/github-actions-runners/templates/runnerdeployment.yaml
Original file line number Diff line number Diff line change
@@ -1,46 +1,60 @@
{{- range .Values.runnerDeployments }}
---
{{- $enabled := printf "%t" .enabled }}
{{- if regexMatch "nil" $enabled }}{{- $enabled = "true" }}{{- end }}
{{- if (eq $enabled "true") }}
kind: RunnerDeployment
apiVersion: actions.summerwind.dev/v1alpha1
metadata:
name: {{ include "github-actions-runners.fullname" . }}
name: {{ include "github-actions-runners.fullname" $ }}-{{ .name }}
labels:
{{- include "github-actions-runners.labels" . | nindent 4 }}
github-actions-runner: {{ .name }}
{{- include "github-actions-runners.labels" $ | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
replicas: {{ .replicaCount | default $.Values.global.replicaCount }}
template:
metadata:
{{- with .Values.podAnnotations }}
{{- with .podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "github-actions-runners.selectorLabels" . | nindent 8 }}
github-actions-runner: {{ .name }}
{{- include "github-actions-runners.selectorLabels" $ | nindent 8 }}
spec:
serviceAccountName: {{ include "github-actions-runners.serviceAccountName" . }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: "{{ .Values.image.pullPolicy }}"
repository: "{{ .Values.config.githubRepository }}"
organization: "{{ .Values.config.githubOrganization }}"
{{- with .Values.config.labels }}
serviceAccountName: {{ include "github-actions-runners.fullname" $ }}-{{ .name }}
image: "{{ .image.repository | default $.Values.global.image.repository }}:{{ .image.tag | default $.Values.global.image.tag }}"
imagePullPolicy: "{{ .image.pullPolicy | default $.Values.global.image.pullPolicy }}"
{{- if .config.githubRepository }}
repository: "{{ .config.githubRepository }}"
{{- end }}
{{- if .config.githubOrganization }}
organization: "{{ .config.githubOrganization }}"
{{- end }}
{{- with .config.labels }}
labels:
{{- toYaml . | nindent 8 }}
{{- end }}
ephemeral: "{{ .Values.config.ephemeral }}"
dockerEnabled: "{{ .Values.config.dockerEnabled }}"
dockerMTU: "{{ .Values.config.dockerMTU }}"
dockerRegistryMirror: "{{ .Values.config.dockerRegistryMirror }}"
dockerdWithinRunnerContainer: "{{ .Values.config.dockerdWithinRunnerContainer }}"
ephemeral: "{{ .config.ephemeral | default $.Values.global.config.ephemeral }}"
dockerEnabled: "{{ .config.dockerEnabled | default $.Values.global.config.dockerEnabled }}"
dockerMTU: "{{ .config.dockerMTU | default $.Values.global.config.dockerMTU }}"
dockerRegistryMirror: "{{ .config.dockerRegistryMirror | default $.Values.global.config.dockerRegistryMirror }}"
dockerdWithinRunnerContainer: "{{ .config.dockerdWithinRunnerContainer | default $.Values.global.config.dockerdWithinRunnerContainer }}"
securityContext:
{{- toYaml .Values.securityContext | nindent 8 }}
{{- with .Values.nodeSelector }}
{{- toYaml .securityContext | nindent 8 }}
{{- with .nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
{{- with .affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
{{- with .tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
resources:
{{- toYaml .Values.resources | nindent 8 }}
{{- toYaml .resources | nindent 8 }}
{{- end }}
{{- end }}
16 changes: 12 additions & 4 deletions charts/github-actions-runners/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
{{- if .Values.serviceAccount.create -}}
{{- range .Values.runnerDeployments }}
---
{{- $enabled := printf "%t" .enabled }}
{{- if regexMatch "nil" $enabled }}{{- $enabled = "true" }}{{- end }}
{{- if (eq $enabled "true") }}
{{- if .serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "github-actions-runners.serviceAccountName" . }}
name: {{ include "github-actions-runners.fullname" $ }}-{{ .name }}
labels:
{{- include "github-actions-runners.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
github-actions-runner: {{ .name }}
{{- include "github-actions-runners.labels" $ | nindent 4 }}
{{- with .serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
150 changes: 81 additions & 69 deletions charts/github-actions-runners/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,85 +2,97 @@
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

replicaCount: 1

image:
repository: summerwind/actions-runner-dind
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: "v2.281.1-ubuntu-20.04"

imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""

serviceAccount:
# Specifies whether a service account should be created
create: true
# Annotations to add to the service account
annotations: {}
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name: ""
global:
replicaCount: 1
image:
repository: summerwind/actions-runner-dind
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: "v2.281.1-ubuntu-20.04"
config:
ephemeral: true
dockerEnabled: false
dockerMTU: 1500
dockerRegistryMirror: https://mirror.gcr.io/
dockerdWithinRunnerContainer: true

runnerDeployments:
- name: default
enabled: true
replicaCount: 1
image:
repository: summerwind/actions-runner-dind
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: "v2.281.1-ubuntu-20.04"

podAnnotations:
cluster-autoscaler.kubernetes.io/safe-to-evict: "true"
serviceAccount:
# Specifies whether a service account should be created
create: true
# Annotations to add to the service account
annotations: {}
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template

podSecurityContext: {}
# fsGroup: 2000
podAnnotations: {}

securityContext: {}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000
podSecurityContext: {}
# fsGroup: 2000

resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi
securityContext: {}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000

config:
# The runner restarts after running jobs, to ensure a clean and reproducible build environment
ephemeral: true
githubOrganization: ""
githubRepository: ""
# Runner Labels
labels: []
# true = A privileged docker sidecar container is included in the runner pod.
# false = A docker sidecar container is not included in the runner pod and you can't use docker.
# If set to false, there are no privileged container and you cannot use docker.
dockerEnabled: false
# Optional Docker containers network MTU
dockerMTU: 1500
# Optional Docker registry mirror
dockerRegistryMirror: https://mirror.gcr.io/
# false = Docker support is provided by a sidecar container deployed in the runner pod.
# true = No docker sidecar container is deployed in the runner pod but docker can be used within the runner container instead. The image summerwind/actions-runner-dind is used by default.
dockerdWithinRunnerContainer: true
resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi

config:
# The runner restarts after running jobs, to ensure a clean and reproducible build environment
ephemeral: true
githubOrganization: ""
githubRepository: ""
# Runner Labels
labels: []
# true = A privileged docker sidecar container is included in the runner pod.
# false = A docker sidecar container is not included in the runner pod and you can't use docker.
# If set to false, there are no privileged container and you cannot use docker.
dockerEnabled: false
# Optional Docker containers network MTU
dockerMTU: 1500
# Optional Docker registry mirror
dockerRegistryMirror: https://mirror.gcr.io/
# false = Docker support is provided by a sidecar container deployed in the runner pod.
# true = No docker sidecar container is deployed in the runner pod but docker can be used within the runner container instead. The image summerwind/actions-runner-dind is used by default.
dockerdWithinRunnerContainer: true

autoscaling:
enabled: false
scaleUpTriggers:
- githubEvent:
checkRun:
types: ["created"]
status: "queued"
amount: 1
duration: "5m"
nodeSelector: {}

nodeSelector: {}
tolerations: []

tolerations: []
affinity: {}

affinity: {}
autoscaling:
enabled: true
scaleUpTriggers:
- githubEvent:
checkRun:
types: ["created"]
status: "queued"
amount: 1
duration: "5m"
2 changes: 2 additions & 0 deletions ct.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
remote: origin
target-branch: master
chart-repos:
- actions-runner-controller=https://actions-runner-controller.github.io/actions-runner-controller
chart-dirs:
- charts

0 comments on commit 5879919

Please sign in to comment.