diff --git a/charts/gitlab-runner-hetzner-autoscale/Chart.yaml b/charts/gitlab-runner-hetzner-autoscale/Chart.yaml index de604b5..be14c52 100755 --- a/charts/gitlab-runner-hetzner-autoscale/Chart.yaml +++ b/charts/gitlab-runner-hetzner-autoscale/Chart.yaml @@ -1,7 +1,7 @@ apiVersion: v1 description: gitlab-runner-hetzner-autoscale name: gitlab-runner-hetzner-autoscale -version: 0.0.8 +version: 0.0.9 appVersion: v0.1 keywords: - gitlab-runner diff --git a/charts/gitlab-runner-hetzner-autoscale/files/register.sh b/charts/gitlab-runner-hetzner-autoscale/files/register.sh deleted file mode 100644 index 6bc10d8..0000000 --- a/charts/gitlab-runner-hetzner-autoscale/files/register.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash - -# gitlab-runner data directory -DATA_DIR="/etc/gitlab-runner" -CONFIG_FILE=${CONFIG_FILE:-$DATA_DIR/config.toml} -CONFIG_TEMPLATE_FILE=${CONFIG_TEMPLATE_FILE:-/gitlab-runner-config/config.template.toml} -# custom certificate authority path -CA_CERTIFICATES_PATH=${CA_CERTIFICATES_PATH:-$DATA_DIR/certs/ca.crt} -LOCAL_CA_PATH="/usr/local/share/ca-certificates/ca.crt" - -update_ca() { - echo "Updating CA certificates..." - cp "${CA_CERTIFICATES_PATH}" "${LOCAL_CA_PATH}" - update-ca-certificates --fresh >/dev/null -} - -if [ -f "${CA_CERTIFICATES_PATH}" ]; then - # update the ca if the custom ca is different than the current - cmp --silent "${CA_CERTIFICATES_PATH}" "${LOCAL_CA_PATH}" || update_ca -fi - -# check variables for runner registration -if [[ -z "$REGISTRATION_TOKEN" ]]; then - echo "ERROR: missing env variable: REGISTRATION_TOKEN" - exit 1 -fi -if [[ -z "$CI_SERVER_URL" ]]; then - echo "ERROR: missing env variable: CI_SERVER_URL" - exit 1 -fi - -# register runner -gitlab-runner register \ - -n \ - --template-config=$CONFIG_TEMPLATE_FILE \ - --config=$CONFIG_FILE \ - --executor docker+machine \ - --locked \ - --docker-image=ruby:2.5 diff --git a/charts/gitlab-runner-hetzner-autoscale/templates/config.yaml b/charts/gitlab-runner-hetzner-autoscale/templates/config.yaml index 7542133..1010a65 100644 --- a/charts/gitlab-runner-hetzner-autoscale/templates/config.yaml +++ b/charts/gitlab-runner-hetzner-autoscale/templates/config.yaml @@ -14,7 +14,56 @@ stringData: CI_SERVER_URL: {{ .Values.runner.ciServerUrl | quote }} register.sh: | - {{ .Files.Get "files/register.sh" | indent 4 | trim }} + #!/bin/bash + + # gitlab-runner data directory + DATA_DIR="/etc/gitlab-runner" + CONFIG_FILE=${CONFIG_FILE:-$DATA_DIR/config.toml} + CONFIG_TEMPLATE_FILE=${CONFIG_TEMPLATE_FILE:-/gitlab-runner-config/config.template.toml} + # custom certificate authority path + CA_CERTIFICATES_PATH=${CA_CERTIFICATES_PATH:-$DATA_DIR/certs/ca.crt} + LOCAL_CA_PATH="/usr/local/share/ca-certificates/ca.crt" + + update_ca() { + echo "Updating CA certificates..." + cp "${CA_CERTIFICATES_PATH}" "${LOCAL_CA_PATH}" + update-ca-certificates --fresh >/dev/null + } + + if [ -f "${CA_CERTIFICATES_PATH}" ]; then + # update the ca if the custom ca is different than the current + cmp --silent "${CA_CERTIFICATES_PATH}" "${LOCAL_CA_PATH}" || update_ca + fi + + # check variables for runner registration + if [[ -z "$REGISTRATION_TOKEN" ]]; then + echo "ERROR: missing env variable: REGISTRATION_TOKEN" + exit 1 + fi + if [[ -z "$CI_SERVER_URL" ]]; then + echo "ERROR: missing env variable: CI_SERVER_URL" + exit 1 + fi + + REGISTER_ARGS="" + + {{ if .Values.runner.locked }} + REGISTER_ARGS="$REGISTER_ARGS --locked" + {{ end }} + + {{ if .Values.runner.tagList }} + REGISTER_ARGS="$REGISTER_ARGS --tag-list {{ join "," .Values.runner.tagList }} + {{ end }} + + # register runner + gitlab-runner register \ + -n \ + --template-config=$CONFIG_TEMPLATE_FILE \ + --config=$CONFIG_FILE \ + --executor docker+machine \ + --run-untagged="{{ .Values.runner.runUntagged }}" \ + --docker-image=ruby:2.5 \ + $REGISTER_ARGS \ config.template.toml: | # docker+machine based on gitlab.com shared runner config: diff --git a/charts/gitlab-runner-hetzner-autoscale/values.yaml b/charts/gitlab-runner-hetzner-autoscale/values.yaml index 52a2eae..f189dcb 100644 --- a/charts/gitlab-runner-hetzner-autoscale/values.yaml +++ b/charts/gitlab-runner-hetzner-autoscale/values.yaml @@ -10,6 +10,9 @@ hetzner: image: "ubuntu-22.04" runner: + locked: true + tags: [] + runUntagged: true registrationToken: "" ciServerUrl: "https://gitlab.com/"