Skip to content

Commit 670517b

Browse files
committed
add gitlab runner chart
1 parent c6d2ebe commit 670517b

9 files changed

Lines changed: 455 additions & 0 deletions

File tree

charts/gitlab-runner/Chart.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: v2
2+
name: gitlab-runner
3+
description: |-
4+
Helm chart to deploy [gitlab-runner](https://gitlab.com/gitlab-org/gitlab-runner).
5+
type: application
6+
version: 0.0.1
7+
appVersion: v15.3.0
8+
home: https://github.com/slamdev/helm-charts/tree/master/charts/gitlab-runner
9+
icon: https://gitlab.com/uploads/-/system/project/avatar/250833/runner_logo.png?width=32
10+
maintainers:
11+
- name: slamdev
12+
email: valentin.fedoskin@gmail.com

charts/gitlab-runner/README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# gitlab-runner
2+
3+
![Version: 0.0.1](https://img.shields.io/badge/Version-0.0.1-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v15.3.0](https://img.shields.io/badge/AppVersion-v15.3.0-informational?style=flat-square)
4+
5+
Helm chart to deploy [gitlab-runner](https://gitlab.com/gitlab-org/gitlab-runner).
6+
7+
**Homepage:** <https://github.com/slamdev/helm-charts/tree/master/charts/gitlab-runner>
8+
9+
## Maintainers
10+
11+
| Name | Email | Url |
12+
| ---- | ------ | --- |
13+
| slamdev | <valentin.fedoskin@gmail.com> | |
14+
15+
## Values
16+
17+
| Key | Type | Default | Description |
18+
|-----|------|---------|-------------|
19+
| additionalContainers | list | `[]` | extra containers |
20+
| additionalResources | list | `[]` | list of additional resources to create (are processed via `tpl` function) |
21+
| affinity | object | `{}` | affinity for scheduler pod assignment |
22+
| config | string | `"[[runners]]\nexecutor = \"shell\""` | gitlab-runner config |
23+
| env | list | `[]` | additional environment variables for the deployment |
24+
| fullnameOverride | string | `""` | full name of the chart. |
25+
| image.pullPolicy | string | `"IfNotPresent"` | image pull policy |
26+
| image.repository | string | `"gitlab/gitlab-runner"` | image repository |
27+
| image.tag | string | `""` | image tag (chart's appVersion value will be used if not set) |
28+
| imagePullSecrets | list | `[]` | image pull secret for private images |
29+
| livenessProbe.httpGet.path | string | `"/debug/jobs/list"` | path for liveness probe |
30+
| livenessProbe.httpGet.port | string | `"http-metrics"` | port for liveness probe |
31+
| nameOverride | string | `""` | override name of the chart |
32+
| nodeSelector | object | `{}` | node for scheduler pod assignment |
33+
| podSecurityContext | object | `{}` | specifies security settings for a pod |
34+
| readinessProbe.httpGet.path | string | `"/debug/jobs/list"` | path for readiness probe |
35+
| readinessProbe.httpGet.port | string | `"http-metrics"` | port for readiness probe |
36+
| replicaCount | int | `1` | number of replicas for gitlab-runner deployment. |
37+
| resources | object | `{}` | custom resource configuration |
38+
| securityContext | object | `{}` | specifies security settings for a container |
39+
| service.ports | list | `[{"name":"http-metrics","port":80,"targetPort":"http-metrics"}]` | service ports |
40+
| service.type | string | `"ClusterIP"` | service type |
41+
| serviceAccount.annotations | object | `{}` | annotations to add to the service account |
42+
| serviceAccount.create | bool | `false` | specifies whether a service account should be created |
43+
| serviceAccount.name | string | `nil` | the name of the service account to use; if not set and create is true, a name is generated using the fullname template |
44+
| strategy | object | `{}` | deployment strategy |
45+
| tolerations | list | `[]` | tolerations for scheduler pod assignment |
46+
| volumeMounts | list | `[]` | additional volume mounts |
47+
| volumes | list | `[]` | additional volumes |
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
{{/* vim: set filetype=mustache: */}}
2+
{{/*
3+
Expand the name of the chart.
4+
*/}}
5+
{{- define "gitlab-runner.name" -}}
6+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
7+
{{- end -}}
8+
9+
{{/*
10+
Create a default fully qualified app name.
11+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
12+
If release name contains chart name it will be used as a full name.
13+
*/}}
14+
{{- define "gitlab-runner.fullname" -}}
15+
{{- if .Values.fullnameOverride -}}
16+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
17+
{{- else -}}
18+
{{- $name := default .Chart.Name .Values.nameOverride -}}
19+
{{- if contains $name .Release.Name -}}
20+
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
21+
{{- else -}}
22+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
23+
{{- end -}}
24+
{{- end -}}
25+
{{- end -}}
26+
27+
{{/*
28+
Create chart name and version as used by the chart label.
29+
*/}}
30+
{{- define "gitlab-runner.chart" -}}
31+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
32+
{{- end -}}
33+
34+
{{/*
35+
Common labels
36+
*/}}
37+
{{- define "gitlab-runner.labels" -}}
38+
helm.sh/chart: {{ include "gitlab-runner.chart" . }}
39+
{{ include "gitlab-runner.selectorLabels" . }}
40+
{{- if .Chart.AppVersion }}
41+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
42+
{{- end }}
43+
app.kubernetes.io/managed-by: {{ .Release.Service }}
44+
{{- end -}}
45+
46+
{{/*
47+
Selector labels
48+
*/}}
49+
{{- define "gitlab-runner.selectorLabels" -}}
50+
app.kubernetes.io/name: {{ include "gitlab-runner.name" . }}
51+
app.kubernetes.io/instance: {{ .Release.Name }}
52+
{{- end -}}
53+
54+
{{/*
55+
Create the name of the service account to use
56+
*/}}
57+
{{- define "gitlab-runner.serviceAccountName" -}}
58+
{{- if .Values.serviceAccount.create -}}
59+
{{ default (include "gitlab-runner.fullname" .) .Values.serviceAccount.name }}
60+
{{- else -}}
61+
{{ default "default" .Values.serviceAccount.name }}
62+
{{- end -}}
63+
{{- end -}}
64+
65+
{{/*
66+
Create the tag for the docker image to use
67+
*/}}
68+
{{- define "gitlab-runner.tag" -}}
69+
{{- .Values.image.tag | default .Chart.AppVersion -}}
70+
{{- end -}}
71+
72+
73+
{{/*
74+
gitlab-runner.rawResource will create a resource template that can be
75+
merged with each item in `.Values.additionalResources`.
76+
*/}}
77+
{{- define "gitlab-runner.rawResource" -}}
78+
metadata:
79+
labels:
80+
{{- include "gitlab-runner.labels" . | nindent 4 }}
81+
{{- end }}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{{- $template := fromYaml (include "gitlab-runner.rawResource" .) -}}
2+
{{- range $i, $t := .Values.additionalResources }}
3+
---
4+
{{ toYaml (merge (tpl $t $ | fromYaml) $template) -}}
5+
{{- end }}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: {{ include "gitlab-runner.fullname" . }}
5+
namespace: {{ .Release.Namespace }}
6+
labels:
7+
{{- include "gitlab-runner.labels" . | nindent 4 }}
8+
data:
9+
config.template.toml: |-
10+
{{- .Values.config | nindent 4 }}
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ include "gitlab-runner.fullname" . }}
5+
namespace: {{ .Release.Namespace }}
6+
labels:
7+
{{- include "gitlab-runner.labels" . | nindent 4 }}
8+
spec:
9+
replicas: {{ .Values.replicaCount }}
10+
{{- with .Values.strategy }}
11+
strategy:
12+
{{ toYaml . | nindent 4 }}
13+
{{- end }}
14+
selector:
15+
matchLabels:
16+
{{- include "gitlab-runner.selectorLabels" . | nindent 6 }}
17+
template:
18+
metadata:
19+
labels:
20+
{{- include "gitlab-runner.selectorLabels" . | nindent 8 }}
21+
annotations:
22+
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
23+
spec:
24+
{{- with .Values.imagePullSecrets }}
25+
imagePullSecrets:
26+
{{- toYaml . | nindent 8 }}
27+
{{- end }}
28+
serviceAccountName: {{ include "gitlab-runner.serviceAccountName" . }}
29+
securityContext:
30+
{{- toYaml .Values.podSecurityContext | nindent 8 }}
31+
initContainers:
32+
- name: registrator
33+
image: "{{ .Values.image.repository }}:{{ include "gitlab-runner.tag" . }}"
34+
imagePullPolicy: {{ .Values.image.pullPolicy }}
35+
args:
36+
- register
37+
- --non-interactive
38+
env:
39+
{{- with .Values.env }}
40+
{{- . | toYaml | nindent 12 }}
41+
{{- end}}
42+
- name: CONFIG_FILE
43+
value: /opt/gitlab-runner-config/config.toml
44+
- name: TEMPLATE_CONFIG_FILE
45+
value: /opt/gitlab-runner-configmap/config.template.toml
46+
- name: RUNNER_NAME
47+
valueFrom:
48+
fieldRef:
49+
fieldPath: metadata.name
50+
volumeMounts:
51+
- name: configmap
52+
mountPath: /opt/gitlab-runner-configmap
53+
readOnly: true
54+
- name: config
55+
mountPath: /opt/gitlab-runner-config
56+
containers:
57+
- name: {{ .Chart.Name }}
58+
securityContext:
59+
{{- toYaml .Values.securityContext | nindent 12 }}
60+
image: "{{ .Values.image.repository }}:{{ include "gitlab-runner.tag" . }}"
61+
args:
62+
- run
63+
imagePullPolicy: {{ .Values.image.pullPolicy }}
64+
ports:
65+
- name: http-metrics
66+
containerPort: 9252
67+
livenessProbe:
68+
{{- toYaml .Values.livenessProbe | nindent 12 }}
69+
readinessProbe:
70+
{{- toYaml .Values.readinessProbe | nindent 12 }}
71+
resources:
72+
{{- toYaml .Values.resources | nindent 12 }}
73+
env:
74+
- name: CONFIG_FILE
75+
value: /opt/gitlab-runner-config/config.toml
76+
- name: LISTEN_ADDRESS
77+
value: ":9252"
78+
- name: RUNNER_NAME
79+
valueFrom:
80+
fieldRef:
81+
fieldPath: metadata.name
82+
{{- with .Values.env }}
83+
{{- toYaml . | nindent 12 }}
84+
{{- end }}
85+
lifecycle:
86+
preStop:
87+
exec:
88+
command:
89+
- gitlab-runner
90+
- unregister
91+
- --all-runners
92+
volumeMounts:
93+
- name: config
94+
mountPath: /opt/gitlab-runner-config
95+
{{- with .Values.volumeMounts }}
96+
{{- toYaml . | nindent 12 }}
97+
{{- end }}
98+
{{- range .Values.additionalContainers }}
99+
- {{ toYaml . | nindent 10 }}
100+
{{- end}}
101+
volumes:
102+
- name: configmap
103+
configMap:
104+
name: {{ include "gitlab-runner.fullname" . }}
105+
- name: config
106+
emptyDir: { }
107+
{{- with .Values.volumes }}
108+
{{- toYaml . | nindent 8 }}
109+
{{- end }}
110+
{{- with .Values.nodeSelector }}
111+
nodeSelector:
112+
{{- toYaml . | nindent 8 }}
113+
{{- end }}
114+
{{- with .Values.affinity }}
115+
affinity:
116+
{{- toYaml . | nindent 8 }}
117+
{{- end }}
118+
{{- with .Values.tolerations }}
119+
tolerations:
120+
{{- toYaml . | nindent 8 }}
121+
{{- end }}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: {{ include "gitlab-runner.fullname" . }}
5+
namespace: {{ .Release.Namespace }}
6+
labels:
7+
{{- include "gitlab-runner.labels" . | nindent 4 }}
8+
spec:
9+
type: {{ .Values.service.type }}
10+
{{- with .Values.service.ports }}
11+
ports:
12+
{{- toYaml . | nindent 4 }}
13+
{{- end }}
14+
selector:
15+
{{- include "gitlab-runner.selectorLabels" . | nindent 4 }}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{{- if .Values.serviceAccount.create -}}
2+
apiVersion: v1
3+
kind: ServiceAccount
4+
metadata:
5+
name: {{ include "gitlab-runner.serviceAccountName" . }}
6+
namespace: {{ .Release.Namespace }}
7+
labels:
8+
{{- include "gitlab-runner.labels" . | nindent 4 }}
9+
{{- with .Values.serviceAccount.annotations }}
10+
annotations:
11+
{{- toYaml . | nindent 4 }}
12+
{{- end }}
13+
{{- end -}}

0 commit comments

Comments
 (0)