筆者所搭建的CICD平台由Jenkins、GitLab、Ansible構成,本篇將講述搭建步驟
本部分CICD的部署分為以下幾個階段
1、主機准備。
2、安裝前預配置。准備相應的系統配置與軟件依賴。
3、執行安裝。
4、安裝后配置。添加相應的組件以及修改配置。如導入模板等。
一、主機准備
Centos7.2
配置:內存大於4G。(其中Jenkins占1.5G、Gitlab占2G)
8080、10080、10022、50000端口未使用
二、安裝前預配置
1、添加阿里yum源(如果已配置了yum源此步可以跳過)
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
wget -O /etc/yum.repos.d/CentOS-Base.repohttp://mirrors.aliyun.com/repo/Centos-7.repo
yum clean all
yum makecache
2、安裝docker
yum install -y docker
3、安裝docker-compose(docker編排工具)
yum install -y docker-compose
4、安裝ansible
yum install -y ansible
5、安裝git
yum install -y git
備注:docker建議使用1.12.6或以上版本、docker-compose建議使用1.17或以上版本、ansible建議使用2.4或以上版本。
三、執行安裝
mkdir /home/jenkins
chmod +777 /home/jenkins
cd ~
https://github.com/hqh546020152/cicd_install_blog.git
cd cicd_install_blog
vi +53 docker-compose-gitlab.yml 該53行的IP修改為本機IP
部署Jenkins
docker-compose -f "docker-compose-jenkins.yml" up -d
部署gitlab(預計5分鍾完成)
docker-compose -f "docker-compose-gitlab.yml" up -d
驗證:
訪問Jenkins:http://HOST:8080

訪問GitLab:http://HOST:10080

四、安裝后配置
GitLab設置完root即可使用了
Jenkins以上展示的為初始化的頁面,安裝如下
1、cat /home/jenkins/secrets/initialAdminPassword 獲取驗證密碼並填入初始化頁面中
2、進入選擇插件安裝界面,選擇第一個(Install suggested plugins)
3、設置管理員賬號 admin/passwd
4、進入管理頁面

到此搭建CICD平台就搭建完畢了。