02 Infrastructure/Gitlab - The Road to DevOps

Infrastructure/Gitlab - The Road to DevOps

Article Github address, welcome start: https://github.com/li-keli/DevOps-WiKi

The source code manager uses Gitlab. The new version (2018.4) of Gitlab has integrated many functions, including CI/CD, Issues, K8s cluster/Docker cluster operations, etc.

Install and deploy the Gitlab service on the node01 machine. Gitlab is used as a code hosting service, so you need to pay attention to configuration such as backup and disaster recovery.

Two installation methods:

Gitlab official source access is too slow, we choose domestic 清华大学镜像installation, first configure the source:

cat>/etc/yum.repos.d/gitlab-ce.repo<<EOF
[gitlab-ce]
name=Gitlab CE Repository
baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el\$releasever/
gpgcheck=0
enabled=1
EOF && \
yum makecache && \
yum install -y gitlab-ce

The installation of Gitlab is completed here, but some default configurations need to be adjusted at this time, such as email configuration , detailed email configuration, please refer to the official documentation to introduce the configuration.
After the configuration is complete, you can see the configuration results on the Gitlab Admin management page:

Mail configuration

In the collaborative development process of Gitlab, many rely on email communication, such as the execution result of Pipelines, the processing of Issues, and so on. Of course, we can also integrate third-party communication tools, such as DingTalk, based on the provided Webhook.

automatic backup

The warehouse needs daily automatic backup for disaster recovery. Gitlab itself already provides the function of backup export, so just configure a Job.

Add the following statement to Crontab:

0 5 * * 1 gitlab-rake gitlab:backup:create

The above code will be fully backed up at 5 am every week. After the backup is completed, a .tar package will be produced, which will be stored in by default /var/opt/gitlab/backups.
The storage location can be adjusted by modifying the configuration file, or it can be automatically uploaded to the dedicated NAS backup storage after the backup is completed.

gitlab_rails['backup_path'] = '/var/opt/gitlab/backups' # 修改此处即可

At this point, the basic configuration of Gitlab is completed, and the developer can submit the local git library to the server.

Mail configuration

Open the mail, edit the configuration file/etc/gitlab/gitlab.rb

gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.example.com"
gitlab_rails['smtp_port'] = 25
gitlab_rails['smtp_user_name'] = "[email protected]"
gitlab_rails['smtp_password'] = "****"
gitlab_rails['smtp_domain'] = "smtp.example.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_openssl_verify_mode'] = 'peer'

gitlab_rails['gitlab_email_from'] = '[email protected]'
gitlab_rails['gitlab_email_reply_to'] = '[email protected]'
 gitlab_rails['incoming_email_enabled'] = true
 gitlab_rails['incoming_email_address'] = "gitlab-incoming+%{key}@example.com"
 gitlab_rails['incoming_email_email'] = "[email protected]"
 gitlab_rails['incoming_email_password'] = "***"
 gitlab_rails['incoming_email_host'] = "mail.example.com"
 gitlab_rails['incoming_email_port'] = 25
 gitlab_rails['incoming_email_ssl'] = false
 gitlab_rails['incoming_email_start_tls'] = false
 gitlab_rails['incoming_email_mailbox_name'] = "inbox"
 gitlab_rails['incoming_email_idle_timeout'] = 60

After the configuration is complete, execute gitlab-ctl reconfigure && gitlab-ctl restart, reload the configuration

Email configuration test

On the GitLab server, execute gitlab-rails consoleenter the console, type the following command to test the mail

Notify.test_email('[email protected]', 'Message Subject', 'Message Body').deliver_now

In addition, due to the limited knowledge of the author himself, he is all groping, so not all practices are correct, or some practices will have better solutions. I hope readers will correct me. If you have any questions, please leave issues .

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324988793&siteId=291194637