包含Harborjava的词条

博主:adminadmin 2022-11-26 03:05:07 65

本篇文章给大家谈谈Harborjava,以及对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。

本文目录一览:

Gitlab+Jenkins+Docker+Harbor+K8s集群搭建CICD平台

上帝借由各种途径使人变得孤独,好让我们可以走向自己。 ——赫尔曼·黑塞《德米安》

CI即为 持续集成(Continue Integration,简称CI) ,用通俗的话讲,就是 持续的整合版本库代码编译后制作应用镜像 。建立有效的持续集成环境可以减少开发过程中一些不必要的问题、 提高代码质量、快速迭代 等,

Jenkins :基于Java开发的一种持续集成工具,用于监控持续重复的工作,旨在提供一个开放易用的软件平台,使软件的持续集成变成可能。

Bamboo : 是一个企业级商用软件,可以部署在大规模生产环境中。

CD即持续交付Continuous Delivery和持续部署Continuous Deployment,用通俗的话说,即可以持续的部署到生产环境给客户使用,这里分为两个阶段,持续交付我理解为满足上线条件的过程,但是没有上线,持续部署,即为上线应用的过程

关于 CD环境 ,我们使用以前搭建好的 K8s集群 ,K8s集群可以实现应用的 健康 检测,动态扩容,滚动更新 等优点,关于K8s集群的搭建,小伙伴可以看看我的其他文章

拉取镜像,启动并设置开机自启

配置docker加速器

GitLab 不多介绍。一个基于Git的版本控制平台,,提供了Git仓库管理、代码审查、问题跟踪、活动反馈和wiki,当然同时也提供了

切记:这里的端口要设置成80,要不push项目会提示没有报错,如果宿主机端口被占用,需要把这个端口腾出来

external_url '’

gitlab_rails[‘gitlab_ssh_host’] = '192.168.26.55’

gitlab_rails[gitlab_shell_ssh_port] = 222

修改完配置文件之后。直接启动容器

相关的git命令

下面我们要配置私有的docker镜像仓库,用到的机器为:

这里仓库我们选择 harbor ,因为有web页面,当然也可以使用 registry

首先需要设置selinux、防火墙

安装并启动docker并安装docker-compose,关于docker-compose,这里不用了解太多,一个轻量的docker编排工具

解压harbor 安装包:harbor-offline-installer-v2.0.6.tgz,导入相关镜像

修改配置文件

harbor.yml:设置IP和用户名密码

./prepare ./install.sh

查看相关的镜像

访问测试

这里因为我们要在192.168.26.55(CI服务器)上push镜像到192.168.26.56(私仓),所有需要修改CI服务器上的Docker配置。添加仓库地址

修改后的配置文件

加载使其生效

CI机器简单测试一下

push一个镜像,可以在私仓的web页面查看

镜像jenkins拉取

这里为什么要改成 1000,是因为容器里是以 jenkins 用户的身份去读写数据,而在容器里jenkins 的 uid 是 1000,

更换国内清华大学镜像,Jenkins下载插件特别慢,更换国内的清华源的镜像地址会快不少

"" 替换为 ""

替换后查看

重启docker,获取登录密匙

需要修改jenkins绑定的docker的启动参数 , ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2376 -H fd:// --containerd=/run/containerd/containerd.sock

修改镜像库启动参数后需要重启docker

后面 gitlab 要和 jenkins 进行联动,所以必须要需要对 jenkins 的安全做一些设置,依次点击 系统管理-全局安全配置-授权策略,勾选"匿名用户具有可读权限"

添加 JVM 运行参数 -Dhudson.security.csrf.GlobalCrumbIssuerConfiguration.DISABLE_CSRF_PROTECTION=true 运行跨站请求访问

这里的话我们要通过jenkins上的kubectl客户端连接k8s,所以我们需要安装一个k8s的客户端kubectl,下载k8s客户端

然后拷贝kubeconfig 证书,k8s集群中查看证书位置,这里的证书是之前创建好的,小伙伴可以看看我之前的文章

命令测试没有问题

我们要部署 Nginx 来运行 hexo 博客系统, hexo 编译完后为一堆静态文件,所以我们需要创建一个 svc 和一个 deploy ,使用 SVC 提供服务,使用 deploy 提供服务能力,使用 Nginx+hexo的静态文件 构成的镜像

这里我们先用一个Nginx镜像来代替hexo博客的镜像

查看deployments和pod

访问测试没有问题,之后我们配置好jenkins上的触发器,直接替换就OK

我们通过 kubectl set 命令更新 deploy 的镜像时,获取的镜像是通过私仓获取的,所以需要在启动参数添加私仓地址

这里所有的节点都需要设置后重启docker

访问jenkins,接下来才是重点,我们要的jenkins上配置整个CICD流程,从而实现自动化

下面我们编译一下hexo,生成public的一个文件夹,然后上传gitlab

同时需要编写Dockerfile文件来创建镜像

帮忙翻译一下英文简历

抄上面的 自己删....- =

Person resume

Name sex male birth

Political appearance member nationality Chinese native place

State of health good height specialized electronic informationproject specialty

Seeks employment the intention: Electronic circuit,communication, semiconductor electronic device correlation domainengineering design, product development, production as well as sale,but also has work and so on simple operation and maintenance which thecomputer is connected. In addition also has the strong interest to themarket development and the product marketing.

Educational background: In September, 2004 -2008 year in June

Information science and engineering college 2004 levels ofelectronic information project undergraduate course

Foreign language proficiency: Smoothly through the universityEnglish four levels, is skilled in listens to, to say, to read, writeseach basic skill.

Specialized knowledge: First, is skilled in computer each basic skill,the familiar computer installment and the basic software and hardwaremaintenance, grasps computer knowledge and so on C language, Javaprogramming, database, network technology, microcomputer principletechnology and application.

Second, good grasps the electronic information correlation specializedcurriculum, for example: The monolithic integrated circuit, thecorrespondence principle, inserts the type system, the DSP technologyand the application, the signal and the linear system, the digitalsignal processing, digital picture processing, the circuit analysisfoundation, the simulation electron and the numeral electronictechnology, but also has the information theory, the photoelectricitytechnology, the high frequency electronic circuit, the automaticcontrol principle and so on.

Third, in addition usually also has studied independently correlationthe and so on marketing, management knowledge.

Experience: In September, 2007 operates privately the shop front inthe Qingdao straw braid handicraft city and the daily necessitieswholesale city to be the sales assistant, gains the exceed tenthousand Yuan in the short more than half months time for the company.

In August, 2007 works in the Qingdao software garden the practice, isresponsible for the software post-sale situation consultation, theservice, and good result.

In June, 2007 carries on the visit practice in the Qingdao sea lettergroup. Has understood the electronic products correlation productionprocess and the work experience. Through the practice, apply theory toreality, I the knowledge which studied to the oneself university inhave have been fuller, a clearer cognition and the experience,simultaneously also widened my field of vision, has opened up myaspect of knowledge.

In 2007 51 golds weeks work the practice in the Qingdao five-starelectric appliance chain store, are responsible for the cymbidiumvirens air conditioning sale, in Qingdao Haire, the sea letter airconditioning hold the bigger market share under the premise, stillobtained in several days to sell the air conditioning several result,obtained the department manager's affirmation.

2005-2006 year once held the post of literary committee member in theclass and grade, propagandizes and organizes committee member and soon many duties. Period organizes many times and plans each kind ofclass and grade to move, to the active class and grade atmosphere,deepened the schoolmate sentiment as well as promotes betweenschoolmate's exchange and unites the very good function.

2004-2005 year once was the microcomputer room and the teacher officeis the assistant in the courtyard, is responsible for the computersimple routine maintenance and the document records management; Alsoonce in the school literary arts mass organization's, the studentassociation propaganda department, the organization department and soon many organization held the post of the member and the clerk, didthe work to obtain teacher and leader's commending.

Reward situation: Once attained the study and the practicescholarship, as well as outstanding student title. The thoughtquality, the practice ability class and grade examines and critiquesobtains the high praise many times.

Self- appraisal: The manner honest code of honor, the thought arestraight. Works the enthusiasm, rigorous earnest, steadfast isdiligent, did not fear difficult, dares to endure hardship, has astronger sense of responsibility and the learning capability, as wellas certain innovation spirit.

Simultaneously also positively participates in inside and outside eachitem of school to move, has the good unity cooperation spirit, as wellas the stronger organization coordination and the communication humanrelations ability, accumulated many social practice experience.

Lives warmly optimistic, open-minded self-confident, the hobby sings,the literature, climbs a mountain, the swimming, the soccer and so on,the interest is widespread.

Contact method:

Handset:

Telephone:

Mail:

Address: Information institute 2,004 levels of electronic informationproject specialty

Zip code: 266100

Postscript: For me an opportunity, I can by hundred time ofdiligently repayments your firm.

Said good, was inferior to can complete! Believed: Your trust + Idiligently = our common success!

基于Kubernetes的持续部署方案

文章转载自Docker

方案概述

本技术方案为基于Kubernetes为核心的持续部署(下文简称CD)方案,可以满足开发方的程序级日志查看分析,运维方的快速扩容与日常运维分析,并且可以保证用户的服务体验。并且整套放在可以在资源利用率上进一步提升,在不降低服务可靠性的前提下降低资源使用成本。

使用场景分析

本方案适用于以Tomcat为容器的JavaWeb项目的持续部署过程,在Kubernetes方案中,所有的Node节点均采用统一配置,根据业务环境的需求进行节点数量的控制。

技术架构与选型

Kubernetes集群部署模式:Stacked etcd topology

Kubernetes的安装使用kubeadm安装为高可用集群,并选用Stacked etcd topology 模式。

详情参考。

Kubernetes生态技术选型:网络层面选型Weave

容器网络解决方案。Weave创建的虚拟网络可以将部署在多个主机上的容器连接起来。对容器来说,Weave就像一个巨大的以太网交换机,所有容器都被接入这个交换机,容器可以直接通信,无需 NAT 和端口映射。

原理详解:

Kubernetes生态技术选型:对外服务选型NodePort

Kubernetes目前支持NodePort、LoadBanlace、Ingress三种对外提供服务的模式,其中LoadBanlace需要云平台的支持,阿里云提供了解决方案,但腾讯云未找到,Ingress技术为新出技术。整体评估采用NodePort方式更为灵活,每个服务一个唯一的对外IP地址,并且使用Nginx进行负载均衡(采用Nginx主要为日志分析)。

介绍与使用方法:。

持续部署过程

各组件业务配置

Kubernetes业务配置

命名空间

在业务上,Kubernetes默认配置两套Namespace,分别为Master存放正式环境,Develop配置测试环境。

对外端口

正式环境Web端口以32001开始,测试环境以31001开始,且一一对应。

Master数据目录

K8s-Master下的data目录下为k8s-cd-config, k8s-cd-config目录存放各业务的yaml配置,二级目录为域名,三级目录划分Master(正式),Develop(测试),目录下以 版本号-构建ID-GITID.yaml 命名文件,时间最后一个即为当前线上的使用配置文件,为了运维方便,在二级目录同级内,生成一个软链连接到最新的正式与测试配置文件。注意,k8s-cd-config仅在其中一台Master中存在。

Node数据目录

节点下的/data一级目录下分Filebeat、Dockerlibs、Nodelogs,其中Dockerlibs存放Docker相关数据,Nodelogs目录通过volume的方式挂载入Kubernetes的Pod, Nodelogs下分Develop与Master目录,区分正式环境与测试环境,每个Master与Develop下分为accesslogs、devlogs、tomcatlogs分别存放访问日志,开发部日志,Tomcat日志,日志目录下为项目(域名),域名下为Pod名称目录。

注意事项 : 节点加入集群后,一定要下载手工下载kubernetes-dashboard-amd64镜像,防止dashboard所在节点挂掉以后dashboard无法在其他节点启动。

Harbor业务配置

业务分组

Harbor重定义其Registry的存储路径直接使用docker-compose安装。template 存放基础进项,各域名分组存放业务镜像。

镜像命名

分组下镜像以站点域名:版本号-类型-CDGITLAB为名称,并基于版本号确定不同的站点版本。

数据目录

Harbor数据目录统一存放在/data下。

备份策略

Harbor默认不设置备份,对于业务镜像无需进行备份,每次进行构建即可,对于模板类镜像,在Jenkins机器上均可以找到,若Harbor出现问题,则直接重建,并将Jenkins上的模板镜像进行重新push。

注意:为了业务的稳定性,Harbor由独立的服务运行(基于Docker),并不运行在Kubernetes内。

Jenkins业务配置

数据目录

Jenkins下的data目录分为dockerlibs、thinbackups、gitlab-files 、jks-cd-config。

Dockerlibs存放Docker相关文件,thinbackups存放每日的Jenkins备份,gitlab-files存放构建GitLab的文件(运维可以在此操作pull,push),jks-cd-config为jks构建目录。

Jenkins机使用/data/jks-cd-config目录存放构建内容,二级目录为域名,三级目录为版本号(以开发部版本号为准),三级目录下存放ROOT.war,四级目录为构建ID_GITID,目录下存放构建的原始数据。

节点每天进行images清理工作。

业务分组

Jenkins的分组分为template与各domain,template存放模板,domain以域名的形式存放正式项目:

新项目由运维手工创建,后续的秩序构建过程由开发部调用API完成。

构建参数

Jenkins构建时,需要传递三参数,1:程序版本号,2:类型:apply与delete,3:正式环境还是测试环境,正式环境为Master,测试环境为Develop,对应Kubernetes的Namespace。

此部分功能后期将通过开发部的构建凭条调用JenkinsAPI实现。

JenkinsAPI

APIDoc:

Token:

备份策略

Jenins安装ThinBackup插件,配置每小时进行一次全局备份,且最多保留10份,备份后数据传至异地。

注意:为了业务的稳定性,Jenkins由独立的服务运行,并不运行在Kubernetes内。

GitLab业务配置

业务分组

CD GitLab项目下分两个组template与各domain,template存放模板文件。例如:

Git分支

default下以域名划分项目,每个项目划分Master与Develop两个分支,分别存放正式环境与测试环境CD文件。

CD文件树

备份策略

GitLab使用gitlab-rake gitlab:backup:create进行每日定期备份,并传送至异地。

EFK与日志管理

Elasticsearch

ES数据通过索引仅保留近10天的数据,每日通过脚本方式进行数据删除。ES的数据保存在/data/elasticsearch目录下。

Filebeat

在每个Node节点启动一个Filebeat进程,用于日志的采集工作,filebeat分别监控:

其中,tomcatlogs日志需要进行特殊处理,进行多行合并,数据写入ES时,使用processors. Dissect进行目录名称截取,并使用域名作为ES的索引使用。

截取gy. wtype ( master或develop) , ltype(accesslogs 、tomcatlogs、devlogs),domain(xxx.gyyx.cn)。

Kibana

Kibana目前我们仅使用其discover节点,用于日志数据的查询,在配置方面。

Kibana配置使用“域名-*”方式进行配置,每次新增域名,需要在此进行手工配置。

Kibana使用discover查看时,默认展示一个域名下所有的日志,可以通过gy.wtype筛选选择查看测试环境还是正式环境,或者通过gy.ltype哪种日志类型。

容器资源监控

容器资源使用WeaveScope进行资源消耗监控。

福利

扫描添加我微信,备注“ 姓名+公司职位 ”,加入【 云计算学习交流群 】,和志同道合的朋友们共同打卡学习!

推荐阅读:

喜欢就点击“好看”吧

Ubuntu 16.04下Docker部署SpringBoot、Mysql、Redis、Nginx和Vue

本文以开源项目SpringBlade和Saber为例。

1、创建自定义网络

目的是将用到的服务都放到同一个网络段,以方便互相通信。

docker network create --subnet 172.19.0.0/16 mynetwork

2、Docker安装MySQL、Redis、Nginx

(1)安装MySQL

docker pull mysql:5.7.30

cd ~

mkdir docker/mysql/{conf,logs,data} -p

cd docker/mysql

docker run --name mysql_blade --network=mynetwork --ip=172.19.0.6 -p 3307:3306 -v PWD/logs:/var/log/mysql -v PWD/data:/data:rw -v $PWD/conf/redis.conf:/etc/redis/redis.conf:ro --privileged=true --name redis-6389 -d redis redis-server /etc/redis/redis.conf

(3)安装Nginx

将Saber发布到Nginx中要用到

docker pull nginx

2、Docker打包SpringBlade

3、Docker打包并发布Saber

(1)编写nginx.conf

cd Saber

touch nginx.conf,写入以下内容:

//nginx.conf开始

user root;

worker_processes 1;

error_log /var/log/nginx/error.log warn;

pid /var/run/nginx.pid;

events {

worker_connections 1024;

}

http {

include /etc/nginx/mime.types;

default_type application/octet-stream;

}

//nginx.conf结束

(2)修改env.js文件

baseUrl要与下面的SpringBlade容器的地址和端口匹配:

(3)编写Dockerfile

编写dockerfile并将其放到与dist同一目录:

FROM nginx

VOLUME /tmp

ENV LANG en_US.UTF-8

ADD ./dist/ /usr/share/nginx/html/

COPY./nginx.conf /etc/nginx/

EXPOSE 1889

EXPOSE 443

(4)打包并发布

cd ~

mkdir docker/saber/conf -p

cd docker/saber

cp ~/Saber/nginx.conf conf

yarn run build

docker build -t saber:1.0 .(注意最后的.)

docker run -itd --name saber --network=mynetwork --ip=172.19.0.8 -p 1889:1889 -v $PWD/conf:/mnt/ saber:1.0

4、Docker打包并发布SpringBlade

(1)pom.xml配置

/

docker.repostory10.10.0.127:10080/docker.repostory

docker.registry.nameblade/docker.registry.name

docker.image.tag0.0.1/docker.image.tag

docker.maven.plugin.version1.4.10/docker.maven.plugin.version

build

finalNameSpringBlade/finalName

resources

resource

directorysrc/main/resources/directory

/resource

resource

directorysrc/main/java/directory

includes

include* / .xml/include

/includes

/resource

/resources

pluginManagement

plugins

plugin

groupIdorg.springframework.boot/groupId

artifactIdspring-boot-maven-plugin/artifactId

version {project.build.finalName}/finalName

/configuration

executions

execution

goals

goalrepackage/goal

/goals

/execution

/executions

/plugin

plugin

groupIdcom.spotify/groupId

artifactIddockerfile-maven-plugin/artifactId

version {project.basedir}/contextDirectory

useMavenSettingsForAuthtrue/useMavenSettingsForAuth

repository {docker.registry.name}/ {docker.image.tag}/tag

buildArgs

JAR_FILEtarget/ {java.version}/source

target${java.version}/target

encodingUTF-8/encoding

compilerArgs

arg-parameters/arg

/compilerArgs

/configuration

/plugin

/plugins

/build

(2)yml配置

redis及mysql都要与前面的创建容器时的配置相同:

(3)创建私有仓库(利用Harbor)

在harbor管理界面创建项目blade,下面上传镜像的时候要加入项目路径。

(4)打包

mvn clean install dockerfile:build -Dmaven.test.skip=true

(5)上传到私有仓库

两种方式:

mvn dockerfile:push

或者docker push 10.10.0.127:10080/blade/springblade:0.0.1

然后在Harbor管理后台就可以看到镜像了。

要pull下来的话:

docker pull 10.10.0.127:10080/blade/springblade:0.0.1

(6)发布

cd ~

mkdir docker/blade/app -p

cd docker/blade

docker run -itd --name blade --network=mynetwork --ip=172.19.0.7 -p 9001:9001 -v $PWD/app:/mnt/ 10.10.0.127:10080/blade/springblade:0.0.1

至此,就可以通过localhost:1889来访问Saber了。

另外,我通过uri来区分多租户。例如localhost:1889是管理租户,localhost:1889/test是名为test的租户。这样就避免了在登录界面填写租户id。

关于Harborjava和的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。

The End

发布于:2022-11-26,除非注明,否则均为首码项目网原创文章,转载请注明出处。