Refactor spec.config to use GitLab Runner configuration template
Refactor the spec.config
option in GitLab runner to use the GitLab Runner configuration template.
This approach gives the user a way to customize the GitLab Runner configuration giving them the ability customize a myriad of options.
To use the spec.config
field to setup build volumes. Use the example below as a guide.
$ cat > custom.config.toml << EOF
[[runners]]
[runners.kubernetes]
[runners.kubernetes.volumes]
[[runners.kubernetes.volumes.empty_dir]]
name = "empty_dir"
mount_path = "/var/configmap_1"
medium = "Memory"
EOF
$ oc create configmap custom-config-toml --from-file config.toml=custom.config.toml
configmap/custom-config-toml created
$ oc get cm custom-config-toml -o yaml | yq r - data
config.toml: |
[runners]]
[runners.kubernetes]
[runners.kubernetes.volumes]
[[runners.kubernetes.volumes.empty_dir]]
name = "empty_dir"
mount_path = "/var/configmap_1"
medium = "Memory"
$ oc get runner example -o yaml
apiVersion: apps.gitlab.com/v1beta2
kind: Runner
metadata:
creationTimestamp: "2021-02-25T19:37:03Z"
generation: 2
name: example
namespace: gitlab-runner-system
resourceVersion: "1338690"
selfLink: /apis/apps.gitlab.com/v1beta2/namespaces/gitlab-runner-system/runners/example
uid: 70eb13a5-aae8-4f2a-8198-cbdfbe3397ea
spec:
config: custom-config-toml
gitlabUrl: https://gitlab.com
imagePullPolicy: Always
tags: openshift, test
token: gitlab-dev-runner-secret
status:
phase: Running
registration: succeeded
$ oc exec -it example-runner-64fdb877fc-mz4sz -- cat /home/gitlab-runner/.gitlab-runner/config.toml | tail -n 10
pod_annotations_overwrite_allowed = ""
[runners.kubernetes.affinity]
[runners.kubernetes.pod_security_context]
[runners.kubernetes.volumes]
[[runners.kubernetes.volumes.empty_dir]]
name = "empty_dir"
mount_path = "/var/configmap_1"
medium = "Memory"
[runners.kubernetes.dns_config]
$
Closes #23 (closed)
Edited by Edmund Ochieng