From 69a1c6ad735b0d6f97b9c01a68bc1892ac31ef49 Mon Sep 17 00:00:00 2001 From: Michele Cereda Date: Mon, 14 Oct 2024 18:08:48 +0200 Subject: [PATCH] chore(gitlab): improve readability --- snippets/gitlab/gitlab-runner.sh | 52 +++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/snippets/gitlab/gitlab-runner.sh b/snippets/gitlab/gitlab-runner.sh index 4f66a89..3311380 100644 --- a/snippets/gitlab/gitlab-runner.sh +++ b/snippets/gitlab/gitlab-runner.sh @@ -3,20 +3,45 @@ helm --namespace 'gitlab' upgrade --install --create-namespace --version '0.64.1' --repo 'https://charts.gitlab.io' \ 'gitlab-runner' -f 'values.gitlab-runner.yml' 'gitlab/gitlab-runner' -# register with token -gitlab-runner register --url 'https://gitlab.com/' --non-interactive --executor 'shell' --token 'glrt-…' -curl -X 'POST' https://gitlab.com/api/v4/user/runners -H 'PRIVATE-TOKEN: glpat-m-…' \ - -d 'runner_type=instance_type' -d "tag_list=small,instance" -d 'run_untagged=false' -# register with registration token: deprecated -gitlab-runner register --url 'https://gitlab.example.com' --registration-token 'abc…' -n \ - --name 'gitlab-aws-autoscaler' --executor 'docker+machine' --docker-image 'alpine' +diff -y <(helm show values 'gitlab/gitlab-runner' --version '0.64.2') <(helm show values 'gitlab/gitlab-runner' --version '0.68.1') + +# Run gitlab-runner exec docker \ --env 'AWS_ACCESS_KEY_ID=AKIA…' --env 'AWS_SECRET_ACCESS_KEY=FsN4…' --env 'AWS_REGION=eu-west-1' \ --env 'DOCKER_AUTH_CONFIG={ "credsStore": "ecr-login" }' \ --docker-volumes "$HOME/.aws/credentials:/root/.aws/credentials:ro" \ 'pulumi preview' + +# Register with token +gitlab-runner register --url 'https://gitlab.com/' --non-interactive --executor 'shell' --token 'glrt-…' +curl -fsX 'POST' https://gitlab.com/api/v4/user/runners -H 'PRIVATE-TOKEN: glpat-m-…' \ + -d 'runner_type=instance_type' -d "tag_list=small,instance" -d 'run_untagged=false' +# Register with registration token: deprecated +gitlab-runner register --url 'https://gitlab.example.com' --registration-token 'abc…' -n \ + --name 'gitlab-aws-autoscaler' --executor 'docker+machine' --docker-image 'alpine' + + +# Just list configured runners +gitlab-runner list -c '/etc/gitlab-runner/config.toml' + +# Check configured runners can connect to the main instance +gitlab-runner verify -c '/etc/gitlab-runner/config.toml' +# Also delete runners that have been removed from the main instance +gitlab-runner verify … --delete + +# Unregister offline runners +curl -fs 'https://gitlab.com/api/v4/runners/all?status=offline&per_page=100' -H 'PRIVATE-TOKEN: glpat-m-…' \ +| jq '.[].id' \ +| xargs -I 'runner_id' curl -fsX 'DELETE' "https://gitlab.com/api/v4/runners/runner_id" 'PRIVATE-TOKEN: glpat-m-…' + + +### +# docker+machine executor +# -------------------------------------- +### + docker-machine ls docker-machine inspect @@ -28,15 +53,12 @@ eval $(docker-machine env 'runner-hzfj7uiz-ec2-1721038998-d9d31b5a') docker-machine rm -y 'runner-r6mo9hn8-ec2-1721049931-49793fa7' -# Just list configured runners -gitlab-runner list -c '/etc/gitlab-runner/config.toml' -# Check configured runners can connect to the main instance -gitlab-runner verify -c '/etc/gitlab-runner/config.toml' -# Also delete runners that have been removed from the main instance -gitlab-runner verify … --delete - -diff -y <(helm show values 'gitlab/gitlab-runner' --version '0.64.2') <(helm show values 'gitlab/gitlab-runner' --version '0.68.1') +### +# docker-autoscaler executor +# instance executor +# -------------------------------------- +### # Install plugins from the OCI registry distribution gitlab-runner fleeting install