Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ephemeral helm chart #65

Merged
merged 13 commits into from
Jun 26, 2024
8 changes: 8 additions & 0 deletions .github/linters/.jscpd.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"absolute": true,
"ignore": [
"**/chart/templates/scaled-job.yaml"
],
"reporters": ["consoleFull"],
"threshold": 0
}
4 changes: 2 additions & 2 deletions chart/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ apiVersion: v2
name: actions-runner
description: Deploy GitHub Actions self-hosted runner
type: application
version: 2.317.0
appVersion: 2.317.0
version: 2.317.0-1
appVersion: 2.317.0-1
icon: https://upload.wikimedia.org/wikipedia/en/thumb/4/4a/Ministry_of_Justice_logo_%28United_Kingdom%29.svg/611px-Ministry_of_Justice_logo_%28United_Kingdom%29.svg.png
maintainers:
- name: moj-data-platform-robot
Expand Down
2 changes: 2 additions & 0 deletions chart/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if not .Values.ephemeral.enabled }}
---
apiVersion: apps/v1
kind: Deployment
Expand Down Expand Up @@ -45,3 +46,4 @@ spec:
value: {{ .Values.github.runner.labels | quote }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- end }}
82 changes: 82 additions & 0 deletions chart/templates/scaled-job.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{{- if .Values.ephemeral.enabled }}
---
apiVersion: keda.sh/v1alpha1
kind: TriggerAuthentication
metadata:
name: {{ .Release.Name }}-github-trigger-auth
spec:
secretTargetRef:
- parameter: personalAccessToken
name: {{ .Release.Name }}-github-token
key: token
---
apiVersion: keda.sh/v1alpha1
kind: ScaledJob
metadata:
name: {{ include "actions-runner.fullname" . }}
labels:
{{- include "actions-runner.labels" . | nindent 4 }}
spec:
jobTargetRef:
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "actions-runner.labels" . | nindent 8 }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
serviceAccountName: {{ include "actions-runner.serviceAccountName" . }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
env:
- name: EPHEMERAL
value: "true"
- name: GITHUB_REPOSITORY
value: {{ .Values.github.organisation }}/{{ .Values.github.repository }}
- name: RUNNER_LABELS
value: {{ .Values.github.runner.labels | quote }}
- name: GITHUB_TOKEN
valueFrom:
secretKeyRef:
name: {{ .Release.Name }}-github-token
key: token
{{- if .Values.ephemeral.karpenter.enabled }}
restartPolicy: Never
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: compute.analytical-platform.service.justice.gov.uk/karpenter-node-pool
operator: In
values:
- {{ .Values.ephemeral.karpenter.nodePool }}
tolerations:
- key: compute.analytical-platform.service.justice.gov.uk/karpenter-node-pool
operator: "Equal"
value: {{ .Values.ephemeral.karpenter.nodePool }}
effect: "NoSchedule"
{{- end }}
successfulJobsHistoryLimit: 0
minReplicaCount: 0
maxReplicaCount: {{ .Values.ephemeral.keda.maxReplicaCount }}
pollingInterval: {{ .Values.ephemeral.keda.pollingInterval }}
triggers:
- type: github-runner
metadata:
owner: {{ .Values.github.organisation }}
repos: {{ .Values.github.repository }}
labels: {{ .Values.github.runner.labels | quote }}
runnerScope: "repo"
authenticationRef:
name: {{ .Release.Name }}-github-trigger-auth
{{- end }}
19 changes: 14 additions & 5 deletions chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ replicaCount: 1
image:
pullPolicy: IfNotPresent
repository: ghcr.io/ministryofjustice/analytical-platform-actions-runner
tag: 2.317.0
tag: 2.317.0-1

imagePullSecrets: []

Expand All @@ -26,15 +26,24 @@ securityContext:

resources:
limits:
cpu: 1000m
memory: 4000Mi
cpu: 1
memory: "5Gi"
requests:
cpu: 500m
memory: 2000Mi
cpu: 2
memory: "7Gi"

github:
organisation:
repository:
token:
runner:
labels:

ephemeral:
enabled: false
karpenter:
enabled: false
nodePool: "general-on-demand"
keda:
maxReplicaCount: 5
pollingInterval: 30