diff --git a/charts/github-actions-runner/.helmignore b/charts/github-actions-runner/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/github-actions-runner/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/charts/github-actions-runner/Chart.yaml b/charts/github-actions-runner/Chart.yaml new file mode 100644 index 0000000..cbf2394 --- /dev/null +++ b/charts/github-actions-runner/Chart.yaml @@ -0,0 +1,8 @@ +apiVersion: v2 +name: github-actions-runner +description: A Helm chart for the github actions runner +type: application +version: 0.1.0 +appVersion: "2.283.3" +maintainers: + - name: 'bryopsida' diff --git a/charts/github-actions-runner/templates/NOTES.txt b/charts/github-actions-runner/templates/NOTES.txt new file mode 100644 index 0000000..4c2d9f2 --- /dev/null +++ b/charts/github-actions-runner/templates/NOTES.txt @@ -0,0 +1 @@ +1. You've launched github runners into the cluster. diff --git a/charts/github-actions-runner/templates/_helpers.tpl b/charts/github-actions-runner/templates/_helpers.tpl new file mode 100644 index 0000000..283b174 --- /dev/null +++ b/charts/github-actions-runner/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "github-actions-runner.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "github-actions-runner.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "github-actions-runner.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "github-actions-runner.labels" -}} +helm.sh/chart: {{ include "github-actions-runner.chart" . }} +{{ include "github-actions-runner.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "github-actions-runner.selectorLabels" -}} +app.kubernetes.io/name: {{ include "github-actions-runner.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "github-actions-runner.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "github-actions-runner.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/github-actions-runner/templates/deployment.yaml b/charts/github-actions-runner/templates/deployment.yaml new file mode 100644 index 0000000..faa71cc --- /dev/null +++ b/charts/github-actions-runner/templates/deployment.yaml @@ -0,0 +1,76 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "github-actions-runner.fullname" . }} + labels: + {{- include "github-actions-runner.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "github-actions-runner.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "github-actions-runner.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "github-actions-runner.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + env: + {{- if .Values.enterpriseUrl }} + - name: RUNNER_ENTERPRISE_URL + value: "{{ .Values.enterpriseUrl }}" + {{- end }} + {{- if .Values.organizationUrl }} + - name: RUNNER_ORGANIZATION_URL + value: "{{ .Values.organizationUrl }}" + {{- end }} + {{- if .Values.repositoryUrl }} + - name: RUNNER_REPOSITORY_URL + value: "{{ .Values.repositoryUrl }}" + {{- end }} + {{- if .Values.runnerLabels }} + - name: RUNNER_LABELS + value: "{{ join "," .Values.runnerLabels }}" + {{- end }} + {{- if .Values.token.secretName }} + - name: GITHUB_TOKEN + valueFrom: + secretKeyRef: + name: "{{ .Values.token.secretName }}" + key: "{{ .Values.token.secretKeyName }}" + {{- else }} + - name: GITHUB_TOKEN + value: "{{ .Values.token }}" + {{- end }} + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/charts/github-actions-runner/templates/hpa.yaml b/charts/github-actions-runner/templates/hpa.yaml new file mode 100644 index 0000000..6f0a1e6 --- /dev/null +++ b/charts/github-actions-runner/templates/hpa.yaml @@ -0,0 +1,28 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "github-actions-runner.fullname" . }} + labels: + {{- include "github-actions-runner.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "github-actions-runner.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/charts/github-actions-runner/templates/serviceaccount.yaml b/charts/github-actions-runner/templates/serviceaccount.yaml new file mode 100644 index 0000000..52aa257 --- /dev/null +++ b/charts/github-actions-runner/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "github-actions-runner.serviceAccountName" . }} + labels: + {{- include "github-actions-runner.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/charts/github-actions-runner/values.yaml b/charts/github-actions-runner/values.yaml new file mode 100644 index 0000000..03ce162 --- /dev/null +++ b/charts/github-actions-runner/values.yaml @@ -0,0 +1,39 @@ +# Default values for github-actions-runner. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 +image: + repository: ghcr.io/curium-rocks/ubuntu-actions-runner + pullPolicy: IfNotPresent + tag: "2a56fb140a42cc727cfafb8286cc265d504c7f68" +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" +serviceAccount: + create: false + annotations: {} + name: "" +organizationUrl: ~ +enterpriseUrl: ~ +runnerRepoUrl: ~ +runnerLabels: + - self-hosted + - linux + - ubuntu + - k8s +token: + secretName: github-token + secretKeyName: token +podAnnotations: {} +podSecurityContext: {} +securityContext: {} +resources: {} +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 +nodeSelector: {} +tolerations: [] +affinity: {}