1
0

initial commit

This commit is contained in:
Vitali Quiering
2023-04-30 10:53:56 +02:00
commit d99c559f4f
9 changed files with 341 additions and 0 deletions

62
templates/_helpers.tpl Normal file
View File

@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "act_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 "act_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 "act_runner.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Common labels
*/}}
{{- define "act_runner.labels" -}}
helm.sh/chart: {{ include "act_runner.chart" . }}
{{ include "act_runner.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
{{/*
Selector labels
*/}}
{{- define "act_runner.selectorLabels" -}}
app.kubernetes.io/name: {{ include "act_runner.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{/*
Create the name of the service account to use
*/}}
{{- define "act_runner.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "act_runner.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

87
templates/deployment.yaml Normal file
View File

@@ -0,0 +1,87 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "act_runner.fullname" . }}
labels:
{{- include "act_runner.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "act_runner.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "act_runner.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "act_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 }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
env:
- name: DOCKER_HOST
value: "tcp://localhost:2375"
- name: DOCKER_TLS_CERTDIR
value: ""
- name: ACT_INSTANCE
value: {{ .Values.act_runner.instance }}
- name: ACT_TOKEN
valueFrom:
secretKeyRef:
name: {{ include "act_runner.fullname" . }}-secret
key: act-runner-token
- name: ACT_LABELS
value: {{ join "," .Values.act_runner.labels }}
volumeMounts:
- name: docker-data
mountPath: /shared
- name: {{ include "act_runner.fullname" . }}-pvc
mountPath: /opt/act_runner
- name: act-runner-dind
securityContext:
privileged: true
image: docker:23.0.0-dind
imagePullPolicy: IfNotPresent
env:
- name: DOCKER_DRIVER
value: "overlay2"
- name: DOCKER_TLS_CERTDIR
value: ""
volumeMounts:
- name: docker-data
mountPath: /shared
volumes:
- name: docker-data
emptyDir:
- name: {{ include "act_runner.fullname" . }}-pvc
persistentVolumeClaim:
claimName: {{ include "act_runner.fullname" . }}-pvc
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}

28
templates/hpa.yaml Normal file
View File

@@ -0,0 +1,28 @@
{{- if .Values.autoscaling.enabled }}
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "act_runner.fullname" . }}
labels:
{{- include "act_runner.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "act_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 }}

18
templates/pvc.yaml Normal file
View File

@@ -0,0 +1,18 @@
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ include "act_runner.fullname" . }}-pvc
labels:
{{- include "act_runner.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: "1024Mi"
storageClassName: {{ .Values.act_runner.storageclass }}

15
templates/secret.yaml Normal file
View File

@@ -0,0 +1,15 @@
---
{{- $token := .Values.act_runner.token | required ".Values.act_runner.token is required." -}}
apiVersion: v1
kind: Secret
metadata:
name: {{ include "act_runner.fullname" . }}-secret
labels:
{{- include "act_runner.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
data:
act-runner-token: {{ .Values.act_runner.token | b64enc }}

View File

@@ -0,0 +1,12 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "act_runner.serviceAccountName" . }}
labels:
{{- include "act_runner.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}