version: 0.1.1
Created: 12.08.2022
Last edit: 13.09.2022
The current guide is the optional step and can be involved only after provided Deployment Marionette Exchange System
You should use the same VM for deployment as was used in the pointed "Deployment Marionette Exchange System on Stage" guide.
Also, you need a root level access to the operation system of your PC, basic knowledge on Git and SSH as well, an account on TuneX Gitlab (address: gitlab.tunex.io).
If you don't match some of these requirements please read the manual carefully and use the explanations provided as links to external resources.
Gitlab-runner is a tool for executing instructions from a special ".gitlab-ci.yml" file. In the scope of current guide Girlab-runner automates the rendering of compose and template files and restarting services on each change in the Marionette project. Of course, it make sense only after after finished initial deployment of the Marionette Exchange System
For more information about gitlab runners follow the source: https://docs.gitlab.com/runner .
1. Install Gitlab Runner for Deployment
If you are a client and can't perform the actions below yourself, or you are not sure experienced in this topic enough, please contact us and our support will execute this part on your behalf.
1.1. Take hint for install and register Group gitlab-runner on TuneX Gitlab
Note: The Group gitlab-runner can be used for any CI/CD jobs for each project of your Group on TuneX Gitab. That is the main reason to create one Group runner instead of several runners for each project inside your Group on TuneX Gitab.
1.1.1. Open Gitlab menu Settings -> CI/CD inside your Gitlab group on the TuneX Gitlab and push 'Expand' button for runners:
1.1.2. On expanded runners click "Take me there":
1.1.3. Get runners page and click there on "Register a group runners' and push "Show runner installation adn registration instructions":
1.1.4. Use window for next guide steps to install and register runner:
1.2. Connect to VM and install gitlab-runner
Run to connect the VM:
ssh root@[IP address]
where [IP address] - the address of the VM for deploy
You should got something like:
Below used "Download and install binary" from step 1.1.4
Install Gitlab runner (recommend binary install: https://docs.gitlab.com/runner/install/linux-manually.html#install-1 ):
curl -L --output /usr/local/bin/gitlab-runner "https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64"
Give permissions to execute gitlab-runner
Run next command to add execute permissions:
chmod +x /usr/local/bin/gitlab-runner
create a GitLab CI user:
useradd --comment 'GitLab Runner' --create-home gitlab-runner --shell /bin/bash
install and run as service:
gitlab-runner install --user=gitlab-runner --working-directory=/home/gitlab-runner gitlab-runner start
1.3. Add user gitlab-runner to sudoers and to docker group
usermod -aG sudo gitlab-runner
usermod -aG docker gitlab-runner
Enable sudo without password for gitlab-runner by next command:
visudo
!!! You should never edit /etc/sudoers with a regular text editor, such as Vim or nano, because they do not validate the syntax like the visudo editor
To the end of the opened /etc/sudoers file add this line:
gitlab-runner ALL=(ALL) NOPASSWD:ALL
e.g.:
and save changes
2. Register Group gitlab-runner
Connect to the VM again (in case you exit or loose connection):
ssh root@[IP address]
where [IP address] - the address of the VM for deploy
2.1. Register Group gitlab-runner on VM for deploy in TuneX Gitlab
Use "Command to register runner" from the step 1.1.4:
Here is command for register gitlab-runner:
gitlab-runner register --url https://gitlab.tunex.io/ --registration-token [Registration token]
where [Registration token] copied from "Command to register runner"
Just copy row from "Command to register runner", run it and answer the questions like on the screen:
For success working of the gitlab-runner for CI-CD task rename .bash_logout to .bash_logout.back in the runner home directory:
cd /home/gitlab-runner/ mv .bash_logout .bash_logout.back
Make sure you have .bash_logout.back inside /home/gitlab-runner folder, type command:
cd /home/gitlab-runner/ ls -lha
get similar to the screen:
Restart gitlab-runner service:
service gitlab-runner-restart
Check the status of gitlab-runner:
service gitlab-runner status
You should get green active (running) status:
Use "Ctrl+C" on the keyboard to exit the status window of gitlab-runner.
2.2. Check registration of the Group gitlab-runner on the TuneX Gitlab
2.2.1. Open Gitlab menu Settings -> CI/CD inside Your group and push 'Expand' button for runners:
2.2.2. On expanded runners click "Take me there":
2.2.3 Check the gitlab-runner is available in the list of Group runners
Here is an example of available gitlab-runner and pointed VM IP and answers during runner register:
3. Set Group gitlab-runner to CI/CD job and run pipeline for deploy
If you are a client and can't perform the actions below yourself, or you are not sure experienced in this topic enough, please contact us and our support will execute this part on your behalf.
3.1. Enter to your Gitlab group on the TuneX Gitlab and click on "Marionette-stage" project:
3.2. Open menu CI/CD -> Editor for project Marionette-stage:
3.3. Edit CI/CD file for "Marionette-stage" project
CI/CD editor opens the file ".gitlab-ci.yml" for editing, make sure it uses script "/root/marionette/deploy-stage" and the tags has "stage":
Note: Learn configuration options for your GitLab .gitlab-ci.yml file: https://gitlab.tunex.io/help/ci/yaml/index
Save commit if ".gitlab-ci.yml" have been changed:
3.4. Open menu CI/CD -> Pipelines for project Marionette-stage:
3.5. Run pipeline and check success deploy
Push button "Run pipeline":
On the opened page push again "Run pipeline":
After running pipile you'll get the process like:
Wait for the finish and get success result like:
4. Conclusion
You've successfully added gitlab-runner for deployment to your Group on TuneX Gitab.