Skip to content

Commit

Permalink
add gitlab runner chart
Browse files Browse the repository at this point in the history
  • Loading branch information
slamdev committed Aug 30, 2022
1 parent c6d2ebe commit 670517b
Show file tree
Hide file tree
Showing 9 changed files with 455 additions and 0 deletions.
12 changes: 12 additions & 0 deletions charts/gitlab-runner/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v2
name: gitlab-runner
description: |-
Helm chart to deploy [gitlab-runner](https://gitlab.com/gitlab-org/gitlab-runner).
type: application
version: 0.0.1
appVersion: v15.3.0
home: https://github.com/slamdev/helm-charts/tree/master/charts/gitlab-runner
icon: https://gitlab.com/uploads/-/system/project/avatar/250833/runner_logo.png?width=32
maintainers:
- name: slamdev
email: [email protected]
47 changes: 47 additions & 0 deletions charts/gitlab-runner/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# gitlab-runner

![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)

Helm chart to deploy [gitlab-runner](https://gitlab.com/gitlab-org/gitlab-runner).

**Homepage:** <https://github.com/slamdev/helm-charts/tree/master/charts/gitlab-runner>

## Maintainers

| Name | Email | Url |
| ---- | ------ | --- |
| slamdev | <[email protected]> | |

## Values

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| additionalContainers | list | `[]` | extra containers |
| additionalResources | list | `[]` | list of additional resources to create (are processed via `tpl` function) |
| affinity | object | `{}` | affinity for scheduler pod assignment |
| config | string | `"[[runners]]\nexecutor = \"shell\""` | gitlab-runner config |
| env | list | `[]` | additional environment variables for the deployment |
| fullnameOverride | string | `""` | full name of the chart. |
| image.pullPolicy | string | `"IfNotPresent"` | image pull policy |
| image.repository | string | `"gitlab/gitlab-runner"` | image repository |
| image.tag | string | `""` | image tag (chart's appVersion value will be used if not set) |
| imagePullSecrets | list | `[]` | image pull secret for private images |
| livenessProbe.httpGet.path | string | `"/debug/jobs/list"` | path for liveness probe |
| livenessProbe.httpGet.port | string | `"http-metrics"` | port for liveness probe |
| nameOverride | string | `""` | override name of the chart |
| nodeSelector | object | `{}` | node for scheduler pod assignment |
| podSecurityContext | object | `{}` | specifies security settings for a pod |
| readinessProbe.httpGet.path | string | `"/debug/jobs/list"` | path for readiness probe |
| readinessProbe.httpGet.port | string | `"http-metrics"` | port for readiness probe |
| replicaCount | int | `1` | number of replicas for gitlab-runner deployment. |
| resources | object | `{}` | custom resource configuration |
| securityContext | object | `{}` | specifies security settings for a container |
| service.ports | list | `[{"name":"http-metrics","port":80,"targetPort":"http-metrics"}]` | service ports |
| service.type | string | `"ClusterIP"` | service type |
| serviceAccount.annotations | object | `{}` | annotations to add to the service account |
| serviceAccount.create | bool | `false` | specifies whether a service account should be created |
| 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 |
| strategy | object | `{}` | deployment strategy |
| tolerations | list | `[]` | tolerations for scheduler pod assignment |
| volumeMounts | list | `[]` | additional volume mounts |
| volumes | list | `[]` | additional volumes |
81 changes: 81 additions & 0 deletions charts/gitlab-runner/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "gitlab-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 "gitlab-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 "gitlab-runner.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Common labels
*/}}
{{- define "gitlab-runner.labels" -}}
helm.sh/chart: {{ include "gitlab-runner.chart" . }}
{{ include "gitlab-runner.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}

{{/*
Selector labels
*/}}
{{- define "gitlab-runner.selectorLabels" -}}
app.kubernetes.io/name: {{ include "gitlab-runner.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end -}}

{{/*
Create the name of the service account to use
*/}}
{{- define "gitlab-runner.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{ default (include "gitlab-runner.fullname" .) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}

{{/*
Create the tag for the docker image to use
*/}}
{{- define "gitlab-runner.tag" -}}
{{- .Values.image.tag | default .Chart.AppVersion -}}
{{- end -}}


{{/*
gitlab-runner.rawResource will create a resource template that can be
merged with each item in `.Values.additionalResources`.
*/}}
{{- define "gitlab-runner.rawResource" -}}
metadata:
labels:
{{- include "gitlab-runner.labels" . | nindent 4 }}
{{- end }}
5 changes: 5 additions & 0 deletions charts/gitlab-runner/templates/additional-resources.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{{- $template := fromYaml (include "gitlab-runner.rawResource" .) -}}
{{- range $i, $t := .Values.additionalResources }}
---
{{ toYaml (merge (tpl $t $ | fromYaml) $template) -}}
{{- end }}
10 changes: 10 additions & 0 deletions charts/gitlab-runner/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "gitlab-runner.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "gitlab-runner.labels" . | nindent 4 }}
data:
config.template.toml: |-
{{- .Values.config | nindent 4 }}
121 changes: 121 additions & 0 deletions charts/gitlab-runner/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "gitlab-runner.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "gitlab-runner.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
{{- with .Values.strategy }}
strategy:
{{ toYaml . | nindent 4 }}
{{- end }}
selector:
matchLabels:
{{- include "gitlab-runner.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "gitlab-runner.selectorLabels" . | nindent 8 }}
annotations:
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "gitlab-runner.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
initContainers:
- name: registrator
image: "{{ .Values.image.repository }}:{{ include "gitlab-runner.tag" . }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
args:
- register
- --non-interactive
env:
{{- with .Values.env }}
{{- . | toYaml | nindent 12 }}
{{- end}}
- name: CONFIG_FILE
value: /opt/gitlab-runner-config/config.toml
- name: TEMPLATE_CONFIG_FILE
value: /opt/gitlab-runner-configmap/config.template.toml
- name: RUNNER_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
volumeMounts:
- name: configmap
mountPath: /opt/gitlab-runner-configmap
readOnly: true
- name: config
mountPath: /opt/gitlab-runner-config
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ include "gitlab-runner.tag" . }}"
args:
- run
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http-metrics
containerPort: 9252
livenessProbe:
{{- toYaml .Values.livenessProbe | nindent 12 }}
readinessProbe:
{{- toYaml .Values.readinessProbe | nindent 12 }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
env:
- name: CONFIG_FILE
value: /opt/gitlab-runner-config/config.toml
- name: LISTEN_ADDRESS
value: ":9252"
- name: RUNNER_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
{{- with .Values.env }}
{{- toYaml . | nindent 12 }}
{{- end }}
lifecycle:
preStop:
exec:
command:
- gitlab-runner
- unregister
- --all-runners
volumeMounts:
- name: config
mountPath: /opt/gitlab-runner-config
{{- with .Values.volumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- range .Values.additionalContainers }}
- {{ toYaml . | nindent 10 }}
{{- end}}
volumes:
- name: configmap
configMap:
name: {{ include "gitlab-runner.fullname" . }}
- name: config
emptyDir: { }
{{- with .Values.volumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
15 changes: 15 additions & 0 deletions charts/gitlab-runner/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "gitlab-runner.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "gitlab-runner.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
{{- with .Values.service.ports }}
ports:
{{- toYaml . | nindent 4 }}
{{- end }}
selector:
{{- include "gitlab-runner.selectorLabels" . | nindent 4 }}
13 changes: 13 additions & 0 deletions charts/gitlab-runner/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "gitlab-runner.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "gitlab-runner.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end -}}
Loading

0 comments on commit 670517b

Please sign in to comment.