登録したGitLab Runnerを削除する
GitLab Runnerの管理はランナーの管理に書かれています。インストール方法はGitLab Runnerのインストールに書かれていたりするのですが、GitLab Runnerの削除方法は見つけられませんでした。そこで今回はGitLab Runnerの削除方法をメモしておきます。
GitLab Runnerのインストール¶
GitLab Runnerをリポジトリからインストールするには以下のように実行します。
Debian/Ubuntu¶
curl -L "https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh" | sudo bash &&
sudo apt-get install -y gitlab-runner
CentOS/RHEL¶
curl -L "https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.rpm.sh" | sudo bash &&
sudo yum install -y gitlab-runner
GitLab Runnerの利用範囲¶
Runnerは利用可能な範囲に応じて以下の3種類、存在します。
- Project Runner
- Group Runner
- Instance Runner
いずれもRunnerとしての機能は同じですが、利用可能な範囲が異なります。利用可能な範囲を図示すると以下の通りです。
GitLab Runnerの登録¶
GitLab Runnerを登録する場合、前述の「利用可能範囲」ごとのメニューから「CI/CD→Runner」を選択して登録作業を行います。Instance Runnerを登録する場合はAdmin Areaから実施します。
GitLab Runnerの登録解除¶
GitLab Runnerの削除¶
登録されているGitLab Runnerを一覧表示するにはgitlab-runner list
を実行します。
# gitlab-runner list
Runtime platform arch=amd64 os=linux pid=5384 revision=cc489270 version=18.2.1
Listing configured runners ConfigFile=/etc/gitlab-runner/config.toml
runner1 Executor=docker Token=glrt-hNKX50QOlTYxoBwPT9amh286MQpwOjEKdDozCnU6MQ8.01.170fws0dn URL=https://gitlab.example.com
runner2 Executor=docker Token=glrt-hL69jUoTbHQu4sV5QZCTj286MQpwOjIKdDozCnU6MQ8.01.1717j43gk URL=https://gitlab.example.com
GitLab Runnerに問題が無いか、確認するにはgitlab-runner verify
を実行します。GitLab側で正常に登録された状態であれば「Valid」表示にあります。
# gitlab-runner verify
Runtime platform arch=amd64 os=linux pid=5401 revision=cc489270 version=18.2.1
Running in system-mode.
Verifying runner... is valid correlation_id=01K2A1XAE8QCBB13NTH7FPH4D6 runner=hNKX50QOl
Verifying runner... is valid correlation_id=01K2A1XANTMS7BKXYY0D4N97PN runner=hL69jUoTb
GitLab側で登録解除した状態でgitlab-runner verify
を実行すると「not valid」と表示されます。
# gitlab-runner verify
Runtime platform arch=amd64 os=linux pid=5482 revision=cc489270 version=18.2.1
Running in system-mode.
Verifying runner... is not valid correlation_id=01K2A24EHKYFB9Q0ZP7657FCGG runner=hNKX50QOl
Verifying runner... is valid correlation_id=01K2A24EPDC76VRWPNSEMPCYYX runner=hL69jUoTb
FATAL: Failed to verify runners
「not valid」なGitLab Runnerを削除するにはgitlab-runner verify --delete
を実行します。
# gitlab-runner verify --delete
Runtime platform arch=amd64 os=linux pid=5534 revision=cc489270 version=18.2.1
Running in system-mode.
Verifying runner... is not valid correlation_id=01K2A26S3DMWNNWH9X1ZSX5R6K runner=hNKX50QOl
Verifying runner... is valid correlation_id=01K2A26S9DH128ANB0E1P5KX18 runner=hL69jUoTb
Updated /etc/gitlab-runner/config.toml
再度、gitlab-runner list
を実行すると「not valid」だったGitLab Runnerが削除されていることが分かります。
# gitlab-runner list
Runtime platform arch=amd64 os=linux pid=5384 revision=cc489270 version=18.2.1
Listing configured runners ConfigFile=/etc/gitlab-runner/config.toml
runner1 Executor=docker Token=glrt-hNKX50QOlTYxoBwPT9amh286MQpwOjEKdDozCnU6MQ8.01.170fws0dn URL=https://gitlab.example.com
runner2 Executor=docker Token=glrt-hL69jUoTbHQu4sV5QZCTj286MQpwOjIKdDozCnU6MQ8.01.1717j43gk URL=https://gitlab.example.com
参考¶
# gitlab-runner --help
NAME:
gitlab-runner - a GitLab Runner
USAGE:
gitlab-runner [global options] command [command options] [arguments...]
VERSION:
18.2.1 (cc489270)
AUTHOR:
GitLab Inc. <support@gitlab.com>
COMMANDS:
list List all configured runners
run run multi runner service
register register a new runner
reset-token reset a runner's token
install install service
uninstall uninstall service
start start service
stop stop service
restart restart service
status get status of a service
run-single start single runner
unregister unregister specific runner
verify verify all registered runners
wrapper start multi runner service wrapped with gRPC manager server
fleeting manage fleeting plugins
artifacts-downloader download and extract build artifacts (internal)
artifacts-uploader create and upload build artifacts (internal)
cache-archiver create and upload cache artifacts (internal)
cache-extractor download and extract cache artifacts (internal)
cache-init changed permissions for cache paths (internal)
health-check check health for a specific address
proxy-exec execute internal commands (internal)
read-logs reads job logs from a file, used by kubernetes executor (internal)
help, h Shows a list of commands or help for one command
GLOBAL OPTIONS:
--cpuprofile value write cpu profile to file [$CPU_PROFILE]
--debug debug mode [$RUNNER_DEBUG]
--log-format value Choose log format (options: runner, text, json) [$LOG_FORMAT]
--log-level value, -l value Log level (options: debug, info, warn, error, fatal, panic) [$LOG_LEVEL]
--help, -h show help
--version, -v print the version