The main motive of this article is to solve real-world problems. Can you imagine the loss of Instagram, not only loss but also hate of a million users it receives if it is even down by a few seconds, so nobody would want that, right?

本文的主要目的是解决现实世界中的问题。 您能想象Instagram丢失,不仅丢失,而且即使它下降了几秒钟,也会收到一百万用户的仇恨,所以没人会想要的,对吗?

It can be solved by using automatic rollout of updates using Kubernetes and managing the build triggers by Jenkins.

可以通过使用Kubernetes自动发布更新并由Jenkins管理构建触发器来解决。

So let us get going, on how to solve this major issue in this easy way.

因此,让我们开始,以简单的方式解决这个重大问题。

我们的系统要求: (Our system requirements:)

  • 2 RHEL 8 VM’s (1 as docker server with Jenkins configured and the other as docker client)

    2个RHEL 8 VM (1个为配置Jenkins的Docker服务器,另一个为Docker客户端)

  • Jenkins(it should be updated as some plugins might not work with the outdated version)should have the following plugins installed

    Jenkins (应进行更新,因为某些插件可能不适用于过时的版本)应安装以下插件

1. Build Pipeline Plugin

1.构建管道插件

2. Docker Plugin

2. Docker插件

3.GitHub Plugin

3.GitHub插件

  • We need to create a Dockerfile with kubectl configured so that this image will run as a slave for Jenkins as well as SSH configured

    我们需要创建一个Dockerfile与配置,以便kubectl这个图像将作为詹金斯从属运行以及配置SSH

  • Minikube configured and it is running( to start do minikube start )

    配置了Minikube并且它正在运行(要开始执行minikube start)

First of all, we need to set up socket binding so as to allow the docker services of this VM to be used by others also. For this, we need to enable TCP support also. This is done by adding -H tcp://0.0.0.0:1234 in /usr/lib/systemd/system/docker.service file in the docker server.

首先,我们需要设置套接字绑定 ,以允许其他人也使用此VM的docker服务。 为此,我们还需要启用TCP支持。 这是通过在Docker服务器的/usr/lib/systemd/system/docker.service文件中添加-H tcp://0.0.0.0:1234来完成的。

vim /usr/lib/systemd/system/docker.service
change configuration of the docker services
更改Docker服务的配置

Now restart your docker services using:

现在使用以下命令重新启动您的docker服务:

systemctl daemon-reloadsystemctl restart docker

Now, a container image is created that has Linux and other basic configuration required to run Slave for Jenkins.

现在,将创建一个容器映像,该容器映像具有运行Slave for Jenkins所需的Linux和其他基本配置。

Step by step explanation of the Dockerfile are:

Dockerfile的分步说明如下:

  1. Use centos as the BaseOS使用centos作为BaseOS
  2. Install java安装java
  3. Install ssh安装ssh
  4. Install sudo command so as there are no issues in permissions安装sudo命令,以便权限中没有问题
  5. Set both the password and username as root, which will help in connect using ssh将密码和用户名都设置为root,这将有助于使用ssh进行连接
  6. Install the kubectl command安装kubectl命令
  7. Make the kubectl command executable使kubectl命令可执行
  8. Move the kubectl command to the /usr/local/bin location,so as to make it accessible from anywhere将kubectl命令移动到/ usr / local / bin位置,以便可以从任何地方访问它
  9. Create .kube directory in the /root folder在/ root文件夹中创建.kube目录
  10. Copy the config file, client.key,client.crt,ca.crt file to the /root/.kube directory. (The permission files are those of kubectl configured of your HostOS)将配置文件client.key,client.crt,ca.crt文件复制到/root/.kube目录。 (许可文件是您的HostOS配置的kubectl的许可文件)
kubernetes config file
kubernetes配置文件

11. Create /root/yml and copy the deployment.yml file in it.

11.创建/ root / yml并在其中复制deployment.yml文件。

deployment.yml
Deployment.yml

12. Generate the SSH key in the container and expose 22 port.

12.在容器中生成SSH密钥,并公开22端口。

Dockerfile with ssh and kubectl configured | shirsha30/sshd_cont:v12
配置了ssh和kubectl的Dockerfile | shirsha30 / sshd_cont:v12

The image can also be used from the docker hub:

该图像也可以从docker hub使用:

We also need to configure our cloud (Jenkins Master-Slave)

我们还需要配置我们的云(Jenkins Master-Slave)

To set up Jenkins as a Cloud server go to Jenkins>Manage Jenkins> Manage Nodes and Clouds> Configure Clouds. Now add Docker host details as follows:

要将Jenkins设置为云服务器,请转到Jenkins > 管理Jenkins>管理节点和云>配置云。 现在添加Docker主机详细信息,如下所示:

docker cloud
码头工人云
docker agent template
docker代理模板
docker agent template configured
配置的Docker代理模板

So let us begin with Job1 and what all it will do:

因此,让我们从Job1开始,它会做什么:

  1. Jenkins will pull code from the GitHub repository and store it in its workspace using Poll SCM (set at intervals of 1 minute). Instead of using Poll SCM, you can also do the same using GitHub hook triggers and ngrok, to get a brief about how to do, refer to this article:Jenkins将从GitHub存储库中提取代码,并使用Poll SCM(以1分钟为间隔设置)将其存储在其工作区中。 除了使用Poll SCM之外,您还可以使用GitHub钩子触发器和ngrok进行相同的操作,以获取有关操作方法的简要信息,请参阅本文:

2. The developer has also pushed the Dockerfile with the image(shirsha30/httpd_server:latest) dynamically for the application and copy the application code(index.html) into that corresponding docker image.

2.开发人员还为应用程序动态推送了带有映像( shirsha30 / httpd_server:latest )的Dockerfile ,并将应用程序代码(index.html)复制到相应的Docker映像中。

shirsha30/httpd_server:latest/ httpd_server:最新的Dockerfile
job1 configuration 1.0
job1配置1.0
job1 configuration 1.1
job1配置1.1
job1 configuration 1.2
job1配置1.2

The output of Job1:

Job1的输出:

Job1 output
Job1输出

Job2:

职位2:

  1. Job 2 will run on the successful completion of Job1.作业2将在作业1成功完成后运行。
  2. This job deploys Webserver on top of the Kubernetes cluster on the Dynamic Jenkins Slave node.该作业将Web服务器部署在Dynamic Jenkins从节点上的Kubernetes集群的顶部。
Job2 configuration 1.0
Job2配置1.0
Job2 configuration 1.1
Job2配置1.1
Job2 configuration 1.2
Job2配置1.2

You might get this error:

您可能会收到此错误:

Possible error
可能的错误
  • This error is if your plugins or Jenkins are out of date.如果您的插件或Jenkins已过时,则会出现此错误。
  • Minikube should be running in the base system. To check if it is running, run the command:Minikube应该在基本系统中运行。 要检查它是否正在运行,请运行以下命令:
minikube ip

If it is not running, then start the services using

如果未运行,请使用以下命令启动服务

minikube start
  • Or it may be because there is an error in your config file of Kubernetes. (check the cluster information by launching and going manually inside the docker container). The file name should be “config”. To check run the below command:或者可能是因为您的Kubernetes配置文件中存在错误。 (通过在docker容器内启动和手动检查集群信息)。 文件名应为“ config”。 要检查,请运行以下命令:
kubectl config view

Now all the errors are debugged.

现在,所有错误都已调试。

Initially when the job starts building it shows

最初,当作业开始构建时,它会显示

pending- ‘Jenkins’ doesn’t have label docker-agent ->docker agent offline->docker agent launching

待处理-'Jenkins'没有标签docker-agent-> docker agent offline-> docker agent launching

Jenkins’ doesn’t have label docker-agent
Jenkins没有标签docker-agent
->docker agent offline
->码头代理离线
->docker agent launching
->启动docker代理

The output of job2:

job2的输出:

The output showing container getting created, and then the port exposed.
输出显示正在创建容器,然后暴露了端口。
After 1st build
第一次构建后
The output showing rolling updates
输出显示滚动更新

Site updated using rollouts:

网站使用推广更新:

After rolling updates
滚动更新后

Build-pipeline view:

构建管道视图:

Build-pipeline view
构建管道视图

Refer the git repository for more information:

请参考git仓库以获取更多信息:

That’s all for everybody. Thank you!

这就是每个人的全部。 谢谢!

翻译自: https://medium.com/swlh/web-server-with-live-rolling-updates-using-dynamic-jenkins-slave-node-and-kubernetes-28b13b04731e


http://www.taodudu.cc/news/show-5423177.html

相关文章:

  • yeelink服务器稳定吗,一步步教你使用云端服务器yeelink远程监控
  • 基本算法(用 PASCAL 描述)
  • 交互设计的那些事(下)
  • 美创科技完成新一轮亿元级融资
  • 精彩回顾 | 金融服务数字化生态的开放与安全
  • 达摩院 2023 十大科技趋势发布
  • 方兴:从生产安全体系视角看数据安全
  • 湾区创见·网络安全大会数据安全及隐私保护专场精彩内容回顾
  • ”上帝“的数学定义,人工智能智商与等级划分研究最新进展
  • 2020年度网络安全十大潜力技术及五大市场前瞻
  • 干货 | 方兴:以风险为基础的数据安全持续治理体系
  • 对数据安全的思考(转载)
  • 云场景实践研究第60期:信号旗智能科技
  • 雾帜智能成功入选ISC 2021创新百强榜单
  • 全知科技CEO方兴:数据流动时代大数据风险是大数据安全的核心
  • “瓯江论数 数安中国”2022数据安全发展大会启幕,数据宝董事长汤寒林受邀发表演讲
  • SQL语句中‘相关子查询’与‘非相关子查询’有什么区别?
  • 雷达系统 学习笔记(二)
  • 相控阵天线(二):非规则直线阵列天线(稀布阵列、稀疏阵列、平方率分布阵列、含python代码)
  • 相关子查询非相关子查询概念
  • 《应用非线性控制》第二章——相平面分析 2.1 相平面分析的概念
  • 高级sql学习——相关子查询和非相关子查询!!!
  • 如何理解“凡所有相,皆是虚妄,若见诸相非相,即见如来”--短句摘抄
  • 嵌套查询:相关子查询和非相关子查询
  • SQL的相关子查询和非相关子查询
  • SQL子查询总结:相关子查询与非相关子查询有什么区别
  • 非相关子查询和相关子查询执行过程详解
  • 《天道》见相非相,即见因果,见相非相,即见如来
  • 雷达系统仿真——非相参累积和相参累积检测
  • 伺服电机常用参数设置_伺服这些参数的设置很重要!切记!切记!

使用动态jenkins从节点和kubernetes进行实时滚动更新的Web服务器相关推荐

  1. Docker Swarm(创建swarm集群,节点的升级降级,滚动更新,Portainer)

    Docker swarm 1.创建 Swarm 集群 2.部署swam监控 3.节点的降级升级 4.删除节点 5. 私有仓库的结合 6.滚动更新 滚动更新镜像版本 删除服务 7. 编写compose文 ...

  2. Kubernetes滚动更新(无中断平滑发布)

    Kubernetes支持名为Rolling Update的功能,允许您不间断地, 接近几乎无缝地平滑升级部署应用程序 ,即在不停止对外服务的前提下完成应用的更新. 什么是滚动更新? 为了应用升级部署时 ...

  3. 动态jenkins slave

    1.Jenkins CI/CD 背景介绍 持续构建与发布是我们日常工作中必不可少的一个步骤,目前大多公司都采用 Jenkins 集群来搭建符合需求的 CI/CD 流程,然而传统的 Jenkins Sl ...

  4. 基于K8s的动态Jenkins Slave构建实践

    前言 源于这篇文章分享的经验 基于 Kubernetes 的 Jenkins 构建集群实践,这里记录一下实践落地过程. 环境 这里Jenkins Master的安装没有采用容器镜像的方式,直接就是rp ...

  5. 【k8s实战一】Jenkins 部署应用到 Kubernetes

    [k8s实战一]Jenkins 部署应用到 Kubernetes 01 本文主旨 目标是演示整个Jenkins从源码构建镜像到部署镜像到Kubernetes集群过程. 为了简化流程与容易重现文中效果, ...

  6. Linux字符驱动中动态分配设备号与动态生成设备节点

    在编写Linux内核驱动程序的时候,如果不动态生成设备号的话,需要自己手动分配设备号,有可能你分配的设备号会与已有设备号相同而产生冲突.因此推荐自动分配设备号.使用下面的函数: int alloc_c ...

  7. ubuntu多节点安装kubernetes

    在ubuntu上面多节点安装kubernetes,假设有两台机器 master:192.168.1.84 minion:192.168.1.83 You wil now need to configu ...

  8. Jenkins X:基于Kubernetes的CI/CD平台

    背景 Jenkins自动化服务器一直都是DevOps工具链的重要组成部分,并且已发展成为开源持续集成和持续部署(CI&CD)软件的领导者.据不完全统计,截至2019年6月,已有将近26万的Je ...

  9. 两种常见挂载Jenkins slave节点的方法

    1.挂载slave节点的方法 在Jenkins的Master上,进入Mange node页面,可以管理node节点,例如新加.删除等操作. 其中, Name是节点名字: Description是节点描 ...

最新文章

  1. 设计模式-策略模式,观察者模式,装饰者模式,静态工厂模式,工厂方法模式
  2. python输出csv文件-更高效的Python CSV文件导出
  3. C语言程序设计 计算个人所得税 浙大版,《C语言及程序设计》实践参考——个人所得税计算器switch语句版...
  4. [深圳活动] OTT互联网机顶盒产品分享活动
  5. 算法练习day13——190401(前缀树、贪心策略拼接字符串使字典序最小)
  6. Next Permutation
  7. [MEGA DEAL]完整的Java编程训练营(94%折扣)
  8. 37 手游基于 Flink CDC + Hudi 湖仓一体方案实践
  9. 最in的一期,来自大厂的邀请|C课有道
  10. java中operationBox_Java使用PDFBox开发包实现对PDF文档内容编辑与保存
  11. Python常用小技巧(五)——批量读取json文件
  12. 接种新冠疫苗到实现完全免疫最快需要35天
  13. Streams AQ: qmn coordinator waiting for slave to start等待事件
  14. 分享一个带语音root的CM311-1a线刷包
  15. getc()、getchar()、getch() 和 getche() 的区别
  16. 5g网速究竟有多快?比4g快多少?
  17. python中哪些是无序_关于无序集合:无序集合 – 在python中设置
  18. Openshift概念
  19. 移动应用UI设计(上)
  20. 百度文库怎么引流,做百度文库有哪些技巧?

热门文章

  1. 在excel中实现汉字转换拼音全拼
  2. hive SQL实现占比、同比、环比计算(lag函数,lead函数)
  3. iShare·AD小技巧--在AD中如何快速的切换版层
  4. 游戏HTML翻翻乐,大班翻翻乐游戏教案
  5. win7 ftp服务器修改读写权限,局域网ftp服务器设置不同权限
  6. Pandarallel 一个能让 pandas 计算火力拉满的工具
  7. 详细解读:远程线程注入DLL到PC版微信
  8. MongoDB的安装及应用详解(未完待续)
  9. myeclipse 项目多 workingset 在packageExplor视图下进行
  10. Postgresql数据库介绍8——使用