04: CI (continuous integration) / CD (continuous delivery / continuous deployment)

1.1 continuous integration, continuous delivery Introduction

    Reference blog: https://www.cnblogs.com/cay83/p/8856231.html

  1, the traditional delivery

      1. The development and delivery cycle is very long traditional software, from design requirements analysis, systems, writing test cases, system development, unit testing, assembly and testing to deliver debugging.

      2. every delivery, upgrade, are required to provide basic hardware and software environment, software code, documentation and software manuals.

      3. engineers are rehearsed many times before in accordance with the process of shining Deployment Guide system, step-by-step assembly hardware, install software, go astray, we must be rolled back in accordance with the corresponding contingency plans.

            

  2, technical engineers and the daily pain points

      1) project, built code libraries, application resources, pull branches write code, the FBI testing, release the line, set up monitoring points, quality and efficiency analysis and summary, etc.

      2) These activities are present in different platforms, kept repeating every day, and each team need to keep communicating, keep doing R & D platform and technology stack switch

      3) So we went back to a principle of continuous delivery, if there is one thing that you feel pain, then automate as soon as possible.

      4) to tease out the standardization of play, using efficient means of automation, using technology to solve these make us feel headaches.

      

  3, CI continuous integration and continuous delivery CD

       Continuous integration (Continuous Integration, CI): Code merger, build, deploy, test all together, continue to perform this procedure, and the results feedback (major output is a mirror image)

       Continuous deployment (the Continuous Deployment, CD) : add the product to the test environment deployment, pre-production environment, production environment

       持续交付(Continuous Delivery,CD): 将最终产品发布到生产环境,给用户使用

      

  4、产品线发布流程

      

  5、国内一些公司开发的轮子

      阿里云效/codepipeline:https://www.aliyun.com/product/codepipeline

      百度效率云:https://xiaolvyun.baidu.com/

      普元devops平台:http://www.primeton.com/products/devops/

  6、构建持续集成环境介绍

      

      

1.2 构建持续集成环境(搭建Harbor私有镜像仓库:192.168.56.14)

  1、安装Docker(192.168.56.14)

# 1)安装依赖包
yum install -y yum-utils device-mapper-persistent-data lvm2

# 2)添加Docker软件包源(否则doker安装的不是新版本)
yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo

# 3)安装Docker CE
yum install -y docker-ce

# 4)启动Docker服务并设置开机启动
systemctl start docker
systemctl enable docker

# 5)安装docker compose
curl -L https://github.com/docker/compose/releases/download/1.24.1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
docker-compose --version  # 测试docker-compose是否安装好

  2、安装Harbor(192.168.56.14)

'''安装Harbor镜像仓库'''
# 1、下载离线安装包
https://github.com/goharbor/harbor/releases

# 2、解压并配置访问地址'''
tar zxvf harbor-offline-installer-v1.8.1.tgz
cd /aaa/harbor
vi harbor.yml
'''
hostname = 192.168.56.14
harbor_admin_password = 123456
'''

# 3、准备配置
./prepare

# 4、导入镜像并启动
./install.sh

# 5、查看容器状态
docker-compose ps

安装完成后可以登录Harbor:http://192.168.56.14

  3、Git代码版本仓库 

'''在192.168.56.14安装git仓库 '''
# 1、安装Git
yum -y install git
# 2、创建Git用户并设置密码
useradd git
passwd git
# 3、创建仓库(下面三步git仓库已经创建完成)
su - git         # 切换到git用户
mkdir demo.git   # 在git用户家目录创建镜像仓库文件夹 demo.git
cd demo.git
git --bare init  # 初始化镜像仓库


'''在192.168.56.13中模拟拉取git代码进行测试 '''
# 4、模拟拉取并提交代码
yum -y install git
git clone git@192.168.56.14:/home/git/demo.git
touch test.py  # 创建一个文件模拟代码提交
git add .
git commit -m 'test'
git push origin master

# 5、配置客户端与Git服务器SSH免交互认证
ssh-keygen  # 生成秘钥
ssh-copy-id [email protected]  # 将私钥拷贝到git服务器
ssh [email protected]  # 在192.168.56.13测试免密登录192.168.56.14

 

 

 

 

 

 

 

 

 

 

 

1111111111111111

Guess you like

Origin www.cnblogs.com/xiaonq/p/11371395.html