环境介绍:

说明 节点 ip 系统
Gitlab Server git.ds.com 10.0.1.179 CentOS 7.5.1804
Gitlab Runner   10.0.1.178 CentOS 7.5.1804
Docker Registry Harbor harbor.ds.com 10.0.1.183 CentOS 7.5.1804

关于 gitlab server和Harbor的安装这里就表述了。

一、gitlab runner的安装 (gitlab 10版本的)

1、根据具体的系统环境下载对应的二进制执行文件

1
2
3
4
5
6
7
8
# Linux x86-64
sudo wget -O /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64
 
# Linux x86
sudo wget -O /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-386
 
# Linux arm
sudo wget -O /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-arm

通过下面的地址你可以找到左右版本的二进制文件

https://docs.gitlab.com/runner/install/bleeding-edge.html#download-any-other-tagged-release

2、给刚下载的二进制执行文件添加执行权限

1
sudo chmod +x /usr/local/bin/gitlab-runner

3、安装docker

1
curl -sSL https://get.docker.com/ | sh

4、创建一个gitlab ci用户

1
useradd --comment 'GitLab Runner' --create-home gitlab-runner --shell /bin/bash

5、将gitlab ci用户添加到docker运行用户的组里面

1
usermod -aG root gitlab-runner

由于我的docker是用root用户运行的所以我这边将gitlab-runner用户加到root的组里面了。

6、开始运行GitLab-Runner

1
2
gitlab-runner install --user=gitlab-runner --working-directory=/home/gitlab-runner
gitlab-runner start

二、注册Runners

1、打开gitlab页面找到runners的注册令牌

2、去gitlab runner的节点上做注册动作

1
gitlab-runner register
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
[root@DS-VM-Node_10_0_1_178 ~]$ gitlab-runner register
Running in system-mode.
 
Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/):
http://git.ds.com
Please enter the gitlab-ci token for this runner:
Fx1jQzBW5ZJoxz157KEU
Please enter the gitlab-ci description for this runner:
[DS-VM-Node_10_0_1_178.dwhd.org]:
Please enter the gitlab-ci tags for this runner (comma separated):
myrunner_10_0_1_178_2
Whether to run untagged builds [true/false]:
[false]: true
Whether to lock the Runner to current project [true/false]:
[true]: true
Registering runner... succeeded                     runner=Fx1jQzBW
Please enter the executor: docker-ssh+machine, kubernetes, docker-ssh, shell, virtualbox, docker+machine, docker, parallels, ssh:
shell
Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!
[root@DS-VM-Node_10_0_1_178 ~]$

3、重启一下runner使之生效

1
gitlab-runner restart

4、去gitlab上检查
能发现到一个刚注册的runner

5、将这个runner指定到指定项目上去

三、测试

新建了一个gitlab项目。

git clone https://github.com/lvelvis/ngx-docker.git

k8s Gitlab CI/CD 之自动编译Docker镜像并推送到指定的Registry的更多相关文章

  1. 利用 Maven 创建 Docker 镜像并且推送到私有注册中心

    利用 Maven 命令生成项目框架 mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -Darchetype ...

  2. 03.pipeline实现项目自动编译docker镜像自动打包

    https://jenkins.io/zh/doc/book/pipeline/ 官方教程,可以中文.Jenkinsfile就是把pipeline内容保存到文件,然后提交到svn等版本控制库中.安装b ...

  3. 使用Jenkins自带功能(不用shell)构建Docker镜像并推送到远程仓库

    意义: 一开始实现这个目的是在Jenkins中使用的shell脚本,也就是如下的这个: bash # 进入到生成jar包的根目录 cd ${WORKSPACE}/${module_filename} ...

  4. 【OF框架】在Visual Studio中发布Docker镜像,推送镜像到Azure容器注册表

    准备 拥有Azure账号,已经创建 Azure容器注册表,获得注册表地址.账号.密码 本地已经在Visual Studio登录Azure账号. 本地已经拥有Docker环境 注意:首次发布Docker ...

  5. Docker 镜像的推送(六)

    目录 一.为镜像命名 二.推送到官方 Docker Hub 1.首先得在 Docker Hub 上注册一个账号. 2.在 Docker Host 上登录 3.修改镜像命名 4.镜像上传 5.登录查看上 ...

  6. 使用maven插件dockerfile-maven-plugin生成Docker镜像并推送到镜像仓库

    1.引入maven插件 <build> <plugins> <plugin> <groupId>com.spotify</groupId> ...

  7. 实践分享!GitLab CI/CD 快速入门

    用过 GitLab 的同学肯定也对 GitLab CI/CD 不陌生,GitLab CI/CD 是一个内置在 GitLab 中的工具,它可以帮助我们在每次代码推送时运行一系列脚本来构建.测试和验证代码 ...

  8. GitLab CI/CD的官译【原】

    CI / CD方法简介 软件开发的持续集成基于自动执行脚本,以最大限度地减少在开发应用程序时引入错误的可能性.从新代码的开发到部署,它们需要较少的人为干预甚至根本不需要干预. 它涉及在每次小迭代中不断 ...

  9. .Net Core自动化部署系列(三):使用GitLab CI/CD 自动部署Api到Docker

    之前写过使用Jenkins实现自动化部署,最近正好没事研究了下GitLab的自动化部署,顺便记录一下. 使用GitLab部署我们需要准备两件事,第一个起码你得有个GitLab,自己搭建或者使用官方的都 ...

随机推荐

  1. React Native - 使用Geolocation进行定位(获取当前位置、监听位置变化)

    1,getCurrentPosition()方法介绍 static getCurrentPosition(geo_success, geo_error?, geo_options? 该方法用于获取当前 ...

  2. Python中字典的相关操作

    1. Python类似于Java中的哈希表,只是两种语言表示的方式是不一样的,Python中的字典定义如下: 在Python中是一种可变的容器模型,它是通过一组键(key)值(value)对组成,这种 ...

  3. vue中用v-for循环出出来的div下面的span不给宽度也能相对于div居中

    效果图 1.html <div> <div v-on:mousemove="dataDetails($event, item)" v-on:mouseleave= ...

  4. eas之创建一个UI界面并对其操作

    private void BranchAddNew(ActionEvent e) {       UIContext uiContext = new UIContext(this);       ui ...

  5. 03-Linux命令基础-第03天(makefile、静态库、动态库、gdb调试工具)

    01- 复习 tar tvf xxx 查看压缩包内容 区分前后台: 是否能和用户交互 Vmware选桥接模式 会给系统虚拟一个和外部相同网段的ip 02- vim扩展操作 因为不是做嵌入式开发的 所以 ...

  6. vue: This relative module was not found

    这是今天运行vue项目报的一个错误,特地在此记录一下. 错误信息如下: ERROR Failed to compile with 1 errors This relative module was n ...

  7. [51Nod 1218] 最长递增子序列 V2 (LIS)

    传送门 Description 数组A包含N个整数.设S为A的子序列且S中的元素是递增的,则S为A的递增子序列.如果S的长度是所有递增子序列中最长的,则称S为A的最长递增子序列(LIS).A的LIS可 ...

  8. Deepin & ROMS 安装详细流程

    按照这个过程,完美安装,当然并不能排除会出现其他的问题.如果遇到了,那就老老实实上网搜吧.

  9. Codeforces 805D/804B - Minimum number of steps

    传送门:http://codeforces.com/contest/805/problem/D 对于一个由‘a’.‘b’组成的字符串,有如下操作:将字符串中的一个子串“ab”替换成“bba”.当字符串 ...

  10. Solr数据不同步

    Solr配置了集群,本地有253和254,2个独立的Solr服务.  同一个页面的图片,刷新2次,图片地址不一样,最后查明,后台数据源Solr1和Solr2的数据不一致.    第1步推测:本地缓存, ...