GitLab Runner understanding
How does GitLab Runner works:
PURPOSE: All documents are provided on this Blog just for educational purposes only. Please make sure that you run it in your test environment before to move on to production environment.
Note: Thanks to Aurora Wang to clear the concept!
GitLab is a web-based Git repository that provides free open and private repositories. In oterwords we can as a Version Management Tool.
GitLab Runner is an application that works with GitLab CI/CD to run jobs in a pipeline.
GitLab Runners participate in a distributed work-stealing algorithm. They continually poll a GitLab instance for jobs that match their tags, execute them, and communicate the progress and results back.
concurrent
= 4 is a global option, it won't cause you to have 4 parallel executions. And
limit is a runner option on how many executions the runner is doing.
In
other words, suppose that you have this config concurrent=4 and only one runner
defined with limit = 1. The maximum amount of executions you will do is 1,
because you have only one runner that can run only one subprocess at the same
time.
But
suppose that you have the same config (concurrent=4) but you have 10 different
runners running with limit=1. What this means is that only 4 of those runners
will run executions at the same time at any given time and, when they run, they
can spawn only one subprocess.
Concurrent: Limits how many jobs can run concurrently. The maximum number is all defined runners. 0
does not mean unlimited.
Limit: Limit how many jobs can be handled concurrently by this token. 0
(default) simply means don’t limit
limit=4
è (how many executions the same runner
can have)
Example1
:
STEPS:
1.
Set
the parameter as follow: Current setting is=>> concurrent=1. The new setting is =>> concurrent=4
(globally allows 4)
1. Create
4 runners 2. Edit
the limit parameter in each runner =>>
limit=13. It
could run 4 different runners parallel at the same time.
Example2:
1.
concurrent=4
(globally allows 4)2. Create
4 runners3.
Runner
1 è limit=3 (the same runner can run
parallel 3 times)4.
Runner
2 è limit=2 (the same runner can run
parallel 2 times)5.
Runner
3 è limit=1 (this runner can just run
one time =>> no parallel)6. Runner
4 è limit=4 (the same runner can run
parallel 4 times)
What this means is that only 4 of those
runners will run executions at the same time. Because we allow globally 4 concurrent
è [concurrent=4
(globally allows 4)].
Example3:
1.
concurrent=10
(globally allows 10)2.
Create
4 runners3.
Runner
1 è limit=3 (the same runner can run
parallel 3 times)4.
Runner
2 è limit=2 (the same runner can run
parallel 2 times)5.
Runner
3 è limit=1 (this runner can just run
one time =>> no parallel)6. Runner
4 è limit=4 (the same runner can run
parallel 4 times)
What
this means is that all 4 runners can have run 10 executions at the same time. Because
we allow globally 10 concurrent è [concurrent=10 (globally
allows 10)]. Each runner limit has different, but not much then 10.
If you want to make chane in your runner config. You need to do as follow:
vi /etc/gitlab-runner/config.toml
Change the concurrent and limit values.
Restart runner
gitlab-runner list
gitlab-runner verifygitlab-runner stopgitlab-runner restartgitlab-runner statusgitlab-runner start
-- Follwoing command stop your complete gitlab envoronment.
gitlab-ctl statusgitlab-ctl stopgitlab-ctl start
Hope this helps.
You can Create runner as follow:
You need registration token.
Go to on you GitLab Web Link:
Groups =>> Explore groups =>>{Choos a group}: Test-HowKnow =>> {on the left side}: Setting=>> CI/CD =>> Runners =>> Expand [you find there the registration tocken
gitlab-runner register -n --url [GitLab Server URL
]/
--limit 1 --registration-token [
registrationtoken] --executor docker --description
"Test Deployment"
--docker-image
"docker:latest"
--docker-privileged --docker-volumes /var/run/docker
/var/run/docker.sock