gitlab Runner installation and deployment

1. Install gitlab Runner

This demonstration is for centos 7.5 environment. Please adjust according to your own environment.

1)Online installation

#Install official image source

[root@k8s-node02 ~]# curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.rpm.sh | sudo bash

#yum install gitlab Runner

[root@k8s-node02 ~]# yum install gitlab-runner -y

2)Offline installation

  • gitlab Runner download address: https://packages.gitlab.com/runner/gitlab-runner
  • Server creation installation package location

    [root@k8s-node02 gitlab-runner]# mkdir -p /tools
  • Download gitlab-runner
    [root@k8s-node02 gitlab-runner]# cd /tools/
    [root@k8s-node02 tools]#ll
    total 0
    [root@k8s-node02 tools]# wget https://packages.gitlab.com/runner/gitlab-runner/packages/fedora/29/gitlab-runner-12.6.0-1.x86_64.rpm/download.rpm
    [root@k8s-node02 tools]#ll
    total 49860
    -rw-r--r-- 1 root root 51052604 Jan 19 22:45 gitlab-runner-12.6.0-1.x86_64.rpm
  • Install gitlab runner

    #Install git
    [root@k8s-node02 tools]# yum install git -y
    
    #rpm offline installation of gitlab runner requires dependence on git, so please install git in advance
    [root@k8s-node02 tools]# rpm -ivh gitlab-runner-12.6.0-1.x86_64.rpm
    Preparing... ################################# [100%]
    Updating/installing...
       1:gitlab-runner-12.6.0-1 ################################ [100%]</ pre></li><li>Tip: For the above two installations, please install according to actual conditions.</li><li>Specify gitlab-runner <pre>[root@k8s-node02 ~]# useradd staff
    
    [root@k8s-node02 ~]# gitlab-runner uninstall
    Runtime platform arch=amd64 os=linux pid=25137 revision=ac8e767a version=12.6.0
    
    [root@k8s-node02 ~]# gitlab-runner install --working-directory /home/staff --user staff
    Runtime platform arch=amd64 os=linux pid=25169 revision=ac8e767a version=12.6.0
    
    [root@k8s-node02 staff]# vim /etc/systemd/system/gitlab-runner.service
    [root@k8s-node02 staff]# cat /etc/systemd/system/gitlab-runner.service
    [Unit]
    Description=GitLab Runner
    After=syslog.target network.target
    ConditionFileIsExecutable=/usr/lib/gitlab-runner/gitlab-runner
    
    [Service]
    StartLimitInterval=5
    StartLimitBurst=10
    ExecStart=/usr/lib/gitlab-runner/gitlab-runner "run" "--working-directory" "/home/staff" "--config" "/etc/gitlab- runner/config.toml" "--service" "gitlab-runner" "--syslog" "--user" "staff"
    
    Restart=always
    RestartSec=120
    
    [Install]
    WantedBy=multi-user.target
  • Start gitlab service
    [root@k8s-node02 ~]# systemctl daemon-reload #Reload configuration
    [root@k8s-node02 tools]# /bin/systemctl start gitlab-runner #Start service
    [root@k8s-node02 tools]# /bin/systemctl enable gitlab-runner #Set up startup
    [root@k8s-node02 tools]# /bin/systemctl restart gitlab-runner #Restart service
  • Verify whether the service is started
    [root@k8s-node02 java_demo]# ps -ef |grep gitlab
    root 25339 1 0 01:16 ? 00:00:11 /usr/lib/gitlab-runner/gitlab-runner run --working-directory /home/staff --config /etc/gitlab-runner/config.toml -- service gitlab-runner --syslog --user staff
  • Set permissions
    [root@k8s-node02 ~]# chown -R staff.staff /home/gitlab-runner

3)gitlab runner registration service

  • After installing gitlab Runner, you can register a Runner for the warehouse in gitlab. The interactive command for registration is as follows:

    [root@k8s-node02 ~]# gitlab-runner register
  • We start registrationG it Lab Projects v
Admin Area
-Overview
Dashboard
Projects
Users
Groups
Jobs
Runners
Gitaly Servers
Groups v
More v
Admin Area Runners
A 'Runner' is a process which runs ajob. You can set up as many Runners as you need.
Runners can be placed on separate users, servers, even on your local machine.
Each Runner can be in one of the following states and/or belong to one of the following
Search or jump to...
Set up a shared Runner manually
1. Install GitLab Runner
2. Specify the following URL during the Runner setup: http://1g2 . 168.230 .133/
Q
0)
types:
group
specific
Iliéck
- Runner runs jobs from all unassigned projects
Runner runs jobs from all unassigned projects in its group
- Runner runs jobs from assigned projects
Runner cannot be assigned to other projects
Runner will not receive any new jobs
f] Runners
Recent searches v
Search or filter results...
Reset runners registration token
4. Start the Runner!
Created date
token
Runners currently online: O
    [root@k8s-node02 ~]# gitlab-runner register
    Runtime platform arch=amd64 os=linux pid=6245 revision=ac8e767a version=12.6.0
    Running in system-mode.
    
    #Enter the company's gitlab public network address
    Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/):
    http://192.168.200.133/
    
    #Enter the gitlab token, find the token in the third step, then select the fourth step and copy the token
    Please enter the gitlab-ci token for this runner:
    8sjydnrsPuSRhKiQTQky
    
    #Enter a name describing this runner
    Please enter the gitlab-ci description for this runner:
    [k8s-node02]: my-runner
    
    #Enter the runner tag
    Please enter the gitlab-ci tags for this runner (comma separated):
    my-tag,another-tag
    Registering runner... succeeded runner=8sjydnrs
    
    #Enter the environment of the runner executor
    Please enter the executor: custom, docker-ssh, parallels, kubernetes, docker-ssh + machine, docker, shell, ssh, virtualbox, docker + machine:
    shell
    Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!
  • Verify whether gitlab runner is registered successfully G it Lab Projects v
Admin Area
-Overview
Dashboard
Projects
Users
Groups
Jobs
Runners
Gitaly Servers
Monitoring
Messages
System Hooks
Groups v
More v
Admin Area Runners
(settings)
A 'Runner' is a process which runs ajob. You can set up as many Runners as you need.
Runners can be placed on separate users, servers, even on your local machine.
Each Runner can be in one of the following states and/or belong to one of the following
types:
Search or jump to...
Set up a shared Runner manually
1. Install GitLab Runner
2. Specify the following URL during the Runner setup: http:1/192 . 168.230 .133/
3. Use the following registration token during setup: 8sjydn rspuSRhKIQTQky
Reset runners registration token
4. Start the Runner!
Q
0)
group
specific
Iliéck
- Runner runs jobs from all unassigned projects
Runner runs jobs from all unassigned projects in its group
- Runner runs jobs from assigned projects
Runner cannot be assigned to other projects
Runner will not receive any new jobs
Recent searches v Search or filter results...
Type/State
shared
Runner token
Description
my-runner
Version
12.6.o
IP Address
192.168.200.134
Created date
ProjectsJabs
n/a
Tags
another-tag
my-tag
Last contact
in 5 hours
Runners currently online: 1
11

During verification, please refresh the interface, view it again, and verify
3) Summary of common commands of gitlab Runner

Order

describe

gitlab-runner run

Run a runner service

gitlab-runner register

Register a new runner

gitlab-runner start

Start service

gitlab-runner stop

Close service

gitlab-runner restart

Restart service

gitlab-runner status

Check the status of each runner

gitlab-runner unregister

Log out of a runner

gitlab-runner list

Show all running runners

gitlab-runner verify

Checks if a registered runner can connect to GitLab, but it does not verify if the runner is being used by the GitLab Runner service.