@@ -9,42 +9,64 @@ A gitlab runner implementation intended to bridge gitlab to
9
9
The lava gitlab runner only requires network (https) access to both the gitlab
10
10
server and the lava server(s), so can pretty much run anywhere.
11
11
12
- The runner requires a runner token to connect to the gitlab server and pick up
13
- jobs. The lava url and token are provided by the gitlab-ci jobs so don't have
14
- to be configured on the runner.
12
+ The runner requires a runner authentication token to connect to the gitlab
13
+ server and pick up jobs. The lava url and token are provided by the gitlab-ci
14
+ jobs so don't have to be configured on the runner.
15
+
16
+ ## Creating a new runner
17
+
18
+ A new runner must be created on the GitLab server. This can be done using the
19
+ [ runner creation API] ( https://docs.gitlab.com/ee/api/users.html#create-a-runner-linked-to-a-user ) ,
20
+ or manually in the GitLab
21
+ [ runner management web interface] ( https://docs.gitlab.com/ee/ci/runners/runners_scope.html ) .
22
+ Make sure to follow the runner creation with an authentication token workflow,
23
+ as the registration token workflow is deprecated.
24
+
25
+ One key parameter provided when creating the runner is ` run_untagged=false ` (or
26
+ leaving the ` Run untagged jobs ` box unchecked in the web interface), which will
27
+ make the runner * only* pickup jobs which matches its tags. This is important to
28
+ prevent the runner from picking up "normal" jobs which it will not be able to
29
+ process.
15
30
16
- ## Registering a new runner
31
+ When the runner is created GitLab provides an authentication token starting
32
+ with ` glrt- ` . This token should be provided to the runner for its GitLab
33
+ connection, along with a system ID that identifies the machine on which the
34
+ runner is executed.
17
35
18
- The runner cannot register itself with the gitlab server, so this has to be
19
- done by hand using the gitlab
20
- [ runner registration API ] ( https://docs.gitlab.com/ee/api/runners.html#register-a-new-runner ) .
36
+ The system ID should be a unique string. GitLab doesn't currently require any
37
+ particular formatting, but it is recommended to follow the way the official
38
+ ` gitlab- runner` creates system IDs:
21
39
22
- The registration token can be retrieved from the runners section in the Gitlab
23
- administration area. With that token the runner can be register using a curl
24
- command like:
25
- ```
26
- curl --request POST "https://GITLAB_URL/api/v4/runners" \
27
- --form "description=Lava runner" \
28
- --form "run_untagged=false" \
29
- --form "tag_list=lava-runner" \
30
- --form "token=REGISTRATION_TOKEN"
31
- ```
40
+ - Deriving it from the machine ID, found in ` /var/lib/dbus/machine-id ` or
41
+ ` /etc/machine-id ` , but concatenating the machine ID with the string
42
+ "gitlab-runner", taking the first 12 characters of its SHA256 hash in hex
43
+ form, and prepending it with ` s_ ` .
32
44
33
- As a response to this command a new token for the registered runner will be
34
- provided, this token should be provided to the runner for it's gitlab
35
- connection.
45
+ - Generating a random 12-character string using letters and digits
46
+ (` [a-z][A-Z][0-9] ` ), and prepending it with ` r_ ` .
36
47
37
- One thing to key parameter provided here is ` run_untagged=false ` , which will
38
- make the runner * only* pickup jobs which matches its tag. This is important to
39
- prevent the runner from picking up "normal" jobs which it will not be able to
40
- process.
48
+ In either case the system ID should be recorded in a persistent storage, along
49
+ with the authentication token, and be passed to the ` Runner::new() ` function.
50
+
51
+ The token can be verified using a curl command like:
52
+
53
+ ``` shell
54
+ curl --request POST " https://GITLAB_URL/api/v4/runners/verify" \
55
+ --form " token=AUTHENTICATION_TOKEN" \
56
+ --form " system_id=SYSTEM_ID"
57
+ ```
58
+
59
+ This step is optional. If performed, it will pre-register the system ID with
60
+ the GitLab server. Otherwise the system ID will be registered the first time
61
+ the runner pings for jobs.
41
62
42
63
## Running the runner from the source tree
43
64
44
65
The runner can be build using Cargo like any Rust program. To run it the url to
45
- the gitlab server and the token have to be either provided on the command line
46
- or in the ` GITLAB_URL ` and ` GITLAB_TOKEN ` environment variables. For example to
47
- run directly from source ` cargo run https://gitlab.myserver.org RUNNER_TOKEN ` .
66
+ the gitlab server, the token and the system ID have to be either provided on
67
+ the command line or in the ` GITLAB_URL ` , ` GITLAB_TOKEN ` and ` RUNNER_SYSTEM_ID `
68
+ environment variables. For example to run directly from source `cargo run
69
+ https://gitlab.myserver.org RUNNER_TOKEN SYSTEM_ID`.
48
70
49
71
## Running from a docker image
50
72
0 commit comments