jenkins+docker+git+etcd实现应用配置文件管理
两台机器:
一台机器安装gitlab: http://www.cnblogs.com/cjsblogs/p/8716932.html
另一台机器安装etcd+docker+jenkins
jenkins-docker: https://www.cnblogs.com/cjsblogs/p/8717602.html
防火墙端口启动;
firewall-cmd --zone=public --add-port=2379/tcp --permanent
firewall-cmd --zone=public --add-port=2380/tcp --permanent
firewall-cmd --reload
安装etcd:
yum install etcd -y
systemctl start etcd
安装setuptools
wget --no-check-certificate https://pypi.python.org/packages/69/56/f0f52281b5175e3d9ca8623dadbc3b684e66350ea9e0006736194b265e99/setuptools-38.2.4.zip#md5=e8e05d4f8162c9341e1089c80f742f64
unzip setuptools-38.2.4.zip
cd setuptools-38.2.4
python setup.py install
cd ..
安装pip
wget --no-check-certificate https://github.com/pypa/pip/archive/1.5.5.tar.gz
tar -xvf 1.5.5.tar.gz #解压文件
cd pip-1.5.5/
python setup.py install
安装python etcd模块:
pip install python-etcd
在git创建dev组,以及dev_etcd项目, 并且制作好的etcd脚本:
git目录如下:

etcdGet.py
#!/usr/bin/env python2.7
# -*- coding:utf-8 -*-
from __future__ import print_function import etcd
import sys
import os
import re
etcdCli=etcd.Client(host=sys.argv[1],port=2379)
f = open(sys.argv[3],'wb')
f.write(etcdCli.get('%s' % sys.argv[2]).value.encode('utf-8'))
f.close()
etcdPush.py
#!/usr/bin/env python2.7
# -*- coding:utf-8 -*-
from __future__ import print_function
import etcd
import sys
import time
import os
import re
reload (sys)
etcdCli=etcd.Client(host=sys.argv[1],port=2379)
def push(local_dir, top_path='/', with_local_path=False):
try:
for root, dirs, files in os.walk(local_dir):
if '.' not in dirs and '.' not in root:
for name in files:
file = os.path.join(root, name)
f = open(file)
content = f.read()
f.close()
if not with_local_path:
etcd_path = '/' + top_path.strip('/') + '/' + file[re.match(local_dir, file).end():].strip(
'/')
else:
etcd_path = '/' + top_path.strip('/') + '/' + file.strip('/')
print(etcd_path)
etcdCli.write(etcd_path, content)
except Exception as e:
etcd.EtcdException(e)
push(sys.argv[2],top_path=sys.argv[3])
etcdRead.py
#!/usr/bin/env python
import etcd
import sys
import time
import os
import re
reload (sys)
def getValue(host,port,location):
etcdCli=etcd.Client(host=host,port=port)
context=etcdCli.read(location).value
return context envValue=getValue(host=sys.argv[1],port=int(sys.argv[2]),location=sys.argv[3])
print(envValue)
getRegistryTagList.py
#!/usr/bin/env python2.7
import requests
import json
import sys def getRegistryTagList():
registry="http://harbor.xxx.com"
res=requests.get(registry+"/v2/")
assert res.status_code == 200 res=requests.get(registry+"/v2/_catalog?n=1000")
assert res.status_code == 200 repositories = res.json().get("repositories",[]) for repository in repositories:
res = requests.get(registry + "/v2/{}/tags/list".format(repository))
tags = res.json().get("tags",None)
if tags:
for tag in tags:
image = format(repository)
tag = format(tag)
if len(sys.argv) <2:
print (image+":"+tag)
else:
AppTargetName=sys.argv[1]
if image.endswith(AppTargetName):
print (image+":"+tag)
if __name__ == "__main__":
getRegistryTagList()
此处需要修改对应的私有docker仓库地址
healthyCheck.py
#!/usr/bin/env python
import requests,sys,os def healthyCheck():
if len(sys.argv) < 2: sys.exit("need 1 argument")
url = sys.argv[1]
try:
code = requests.get(url,timeout=1).status_code
if code >= 200 and code < 400:
print "healthy check ok , status_code:%s" % code
else:
print "healthy check not ok, status_code:%s" % code
sys.exit("healthy check not ok")
except Exception,e:
print "e"
if __name__ == "__main__":
healthyCheck()
import.sh
/opt/dev_etcd/etcdPush.py 172.16.5.113 appCfgs /xxx.com/instances
此处建立etcd推送的配置文件服务器以及路径
以上所有的脚本全部完毕
接下来需要在jenkins上创建job结合git的webhooks推送应用配置文件
jenkins创建job:


截图处创建git的webhooks能用到


以上git clone直接提交用户名和密码拉取git代码, 其中我的密码带有@符号, git clone无法识别@符号, 需要将@转义为%40故账号需要特殊处理:

最后在git上创建webhooks

综上全部创建完毕, 在jenkins上点击job立即构建测试吧
jenkins+docker+git+etcd实现应用配置文件管理的更多相关文章
- 基于 Jenkins+Docker+Git 的CI流程初探
在如今的互联网时代,随着软件开发复杂度的不断提高,软件开发和发布管理也越来越重要.目前已经形成一套标准的流程,最重要的组成部分就是持续集成(Continuous Integration,CI)及持续部 ...
- 从0到1体验Jenkins+Docker+Git+Registry实现CI自动化发布
一.前言 Jenkins是一款开源 CI&CD 软件,用于自动化各种任务,包括构建.测试和部署软件.Jenkins 支持各种运行方式,可通过系统包.Docker 或者通过一个独立的 Java ...
- Jenkins+Docker+Git+Registry
从0到1体验Jenkins+Docker+Git+Registry实现CI自动化发布 笔者:@拿着保温瓶的年轻人 目录: 一.前言 二.发布流程 三.环境准备 四.部署思路梳理 五.三台机器上操作 ...
- Jenkins+Docker+Git+Harbor流水线打包
Jenkins+Docker+Git+Harbor流水线打包 环境: CentOS Linux release 7.6.1810 (Core) 192.168.247.214 Jenkins+dock ...
- Jenkins+Docker+Git 自动化部署
Jenkins+Docker+Git 自动化部署图文教程 https://blog.csdn.net/qq_38252039/article/details/89791247 前言: 通过几天的学习和 ...
- Docker 搭建 etcd 集群配置
#关闭selinux.防火墙 systemctl stop firewalld.service systemctl disable firewalld.service firewall-cmd --s ...
- jenkins+docker+git+harbor构建及代码回滚(未完)
目录 一.部署 环境工作流程介绍 部署harbor 一.部署 前提环境说明 192.168.111.3 该机器为git本地仓库,及git远程仓库(git用户创建),及Harbor镜像仓库 192.16 ...
- jenkins+docker持续集成实验
在互联网时代,对于每一家公司,软件开发和发布的重要性不言而喻,目前已经形成一套标准的流程,最重要的组成部分就是持续集成(CI)及持续部署.交付(CD).本文基于Jenkins+Docker+Git实现 ...
- Jenkins 基于 Docker git JAVA CI/CD
准备两台机器 192.168.31.200 centos7 docker harbor git 192.168.31.201 centos7 docker jenkins maven git Ha ...
随机推荐
- 实现多列等高布局_flex布局
详情参见此篇博客 http://www.w3cplus.com/css/creaet-equal-height-columns 建议掌握方法四.五 其实,利用最新的flex布局 http://www. ...
- jetbrains 2019 激活 error 1653219 解决办法
我以前用PyCharm按照http://idea.lanyus.com/上的激活码直接可激活. 后来用到IDEA(最新版)了之后激活报错.错误代码为1653219. 后参考博客 解决办法: 把host ...
- HearthBuddy 复生 reborn
https://hearthstone.gamepedia.com/Reborn Reborn is an ability that causes a minion to be resummoned ...
- 表的操作管理和 MySQL 的约束控制
一.表的操作 1.表的基本概念 数据库与表之间的关系:数据库是由各种数据表组成的,数据表是数据库中最重要的对象,用来存储和操作数据的逻辑结构. 表由列和行组成,列是表数据的描述,行是表数据的实例. 表 ...
- centos6里面装zabbix(二)
第一步: 如果这一步的时候有错误,那么修改php.ini(/usr/local/php/etc/这个目录下),然后重启php这个配置文件. 第二步: 第三步: 第四步: 第五步: 第六步:做到这一步的 ...
- 创建使用Spring Boot
Spring Boot 创建项目 Spring Initializr 创建完成会自动下载 解压后 Idea导入 修改国内镜像 网络不够强的话停掉自动更新 build.gradle 加上 reposit ...
- SrpingMVC通过JSON注入from数据到实体自定义(LocalDateTime,LocalDate,Boolean类型)字段的序列化、反序列化方法
import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonProcessingExcept ...
- Linux学习—rpm包管理
前言 在linux上,一个软件通常由二进制程序,库文件,配置文件和帮助文件组成.其中: 二进制程序一般都放在/bin,/sbin,/usr/bin,/usr/sbin,/usr/local/bin和/ ...
- 四、VSCode调试vue项目
1.先决条件设置 你必须安装好 Chrome 和 VS Code.同时请确保自己在 VS Code 中安装了 Debugger for Chrome 扩展的最新版本. 在可以从 VS Code 调试你 ...
- STS中AOP的实现
1. 在pom.xml中加入aop依赖: <groupId>org.springframework.boot</groupId> <artifactId>sprin ...