current position:Home>CI/CD Jenkins containerized installation and deployment

CI/CD Jenkins containerized installation and deployment

2022-11-24 23:09:52ziye_ cotyledons

在这里插入图片描述

环境准备
docker安装
jenkins镜像安装


CI/CD

CI:持续集成
CD:连续交付


环境准备

It is recommended to read it before downloadingJenkinsHardware and software requirements section
Jenkins官方文档
Jenkins下载

虚拟机 docker configuration requirements
CentOSInstallation can jump VMware安装CentOS

CentOS 7.8+   // 查看CentOS版本命令  cat /etc/centos-release
最少1核  (推荐2核)
最少内存1.5G  (推荐2G)
最少硬盘20G  (推荐50G)

配置阿里云yum源

1.下载安装wget
yum install -y wget

2.备份默认的yum
mv /etc/yum.repos.d /etc/yum.repos.d.backup

3.设置新的yum目录
mkdir -p /etc/yum.repos.d

4.下载阿里yum配置到该目录中,选择对应版本
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

5.更新epel源为阿里云epel源
mv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.backup
mv /etc/yum.repos.d/epel-testing.repo /etc/yum.repos.d/epel-testing.repo.backup
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

6.重建缓存
yum clean all
yum makecache

查看系统内核版本:命令

uname -r

如果是 3.x You need to upgrade the kernel version,否则k8sCertain commands will report errors
在这里插入图片描述

升级系统内核

rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm
yum --enablerepo=elrepo-kernel install -y kernel-lt
grep initrd16 /boot/grub2/grub.cfg
grub2-set-default 0

重启系统
reboot

If the following content is displayed, the upgrade is successful(Version numbers may vary)
在这里插入图片描述
Now check the kernel version

uname -r

在这里插入图片描述

1.关闭防火墙 ---> I am in a virtual machine environment,Please consider the production environment as appropriate
systemctl stop firewalld

2.开机自动关闭防火墙
systemctl disable firewalld

3.关闭selinux
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux
setenforce 0

4.网桥过滤
vi /etc/sysctl.conf
在文末添加如下内容:
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-arptables = 1
net.ipv4.ip_forward=1
net.ipv4.ip_forward_use_pmtu = 0

在这里插入图片描述

5.生效命令
sysctl --system

6.命令补全,安装bash-completion
yum -y install bash-completion bash-completion-extras

7.使用bash-completion
source /etc/profile.d/bash_completion.sh

8.Install upload and download related components
yum -y install lrzsz

At this point the entire required environment has been prepared,You can stop the virtual machine first,进行快照备份.It is convenient to roll back in time if there is a problem later,Avoid repeating the above operations

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述


docker安装

如果不是root,Need to add before executing the command sudo

1.安装docker前置条件
yum install -y yum-utils device-mapper-persistent-data lvm2

2.Add the domestic Aliyun source
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

3.刷新源缓存
yum makecache fast

4.安装最新版docker:  ---> This process is affected by network speed,下载可能较慢
yum -y install docker-ce

5.启动docker服务
systemctl start docker

6.查看docker运行状态
systemctl status docker

在这里插入图片描述

安装阿里云镜像加速器
Accelerator address acquisition method
进入阿里云官网并登录
登录成功后,点击 控制台 ,选择 容器镜像服务
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
复制链接
在这里插入图片描述

1.安装阿里云镜像加速器
mkdir -p /etc/docker
tee /etc/docker/daemon.json <<-'EOF' { "registry-mirrors": ["复制自己的加速器地址"] } EOF
systemctl daemon-reload

2.重启docker服务
systemctl restart docker

3.设置docker开启自启
systemctl enable docker

4.查看docker是否安装成功
docker -v

在这里插入图片描述

至此docker安装完成
可以进行快照备份

可以通过 docker info 查看此时docker详细内容 (If the picture is too small, you can right-click to download it)

在这里插入图片描述


jenkins镜像安装

1.下载最新的jdk8 jenkins镜像
docker pull jenkins/jenkins:latest-jdk8

2.运行jenkins
docker run -itd --name jenkins -p 8080:8080 -p 50000:50000 -u root --restart=always jenkins/jenkins:latest-jdk8

3.查看容器启动日志,并查看jenkins初始化密码
docker logs -f jenkins

在这里插入图片描述
浏览器登录jenkins ip:8080
Paste the initialization password
在这里插入图片描述

选择 自定义安装插件
在这里插入图片描述
使用maven构建,So these two counter-elections
在这里插入图片描述

GitHub,反选
在这里插入图片描述
点击 安装
在这里插入图片描述

JenkinsThe containerized installation and deployment is complete!


其他章节 -> 跳转

end...

copyright notice
author[ziye_ cotyledons],Please bring the original link to reprint, thank you.
https://en.chowdera.com/2022/328/202211242301266183.html

Random recommended