2020-11-02

kubernetes集群jenkins安装文档

kubernetes集群jenkins安装文档

项目请参与github项目

https://github.com/JustCoWorker/kubernetes-cicd

1.jenkins 镜像构建

1.1cat Dockerfile

FROM jenkins/jenkins:ltsUSER rootARG dockerGid=978WORKDIR /usr/local#RUN wget apache-maven-3.3.9-bin.tar.gz ./RUN tar xzvf apache-maven-3.3.9-bin.tar.gzlsRUN cp -R apache-maven-3.3.9 /usr/local/binRUN export PATH=apache-maven-3.3.9/bin:$PATHRUN export PATH=/usr/local/bin/apache-maven-3.3.9/bin:$PATHRUN ln -s /usr/local/bin/apache-maven-3.3.9/bin/mvn /usr/local/bin/mvn#RUN ls -l /usr/local/binRUN echo $PATHRUN echo "docker:x:${dockerGid}:jenkins" >> /etc/group \USER jenkins

1.2构建镜像

git clone https://github.com/JustCoWorker/kubernetes-cicd.gitcd /usr/local/kubernetes-cicd/jenkinsdocker build -t harbor.demo.com/private/demo-jenkins:lts .docker push harbor.demo.com/private/demo-jenkins:lts

2.部署jenkins

2.1CentOS7 安装NFS

下载软件
yum install -y nfs-utils
新建挂在文件夹
mkdir -p /usr/local/nfs
修改文件夹权限
chmod a+rw /usr/local/nfs
配置NFS服务目录

vi /etc/exports

/usr/local/nfs *(rw,sync,no_subtree_check,no_root_squash)
rpcbind和nfs做开机启动
systemctl enable rpcbind.servicesystemctl enable nfs-server.service
启动服务
systemctl start rpcbind.servicesystemctl start nfs-server.service
查看共享状态
showmount -e showmount -e 192.168.1.157

2.2部署jenkins

namespace-ci.yml

apiVersion: v1kind: Namespacemetadata: name: ci

pv.yml

apiVersion: v1kind: PersistentVolumemetadata: name: jenkins namespace: cispec: capacity:  storage: 50Gi accessModes:  - ReadWriteMany persistentVolumeReclaimPolicy: Retain nfs:  path: /usr/local/nfs  server: 127.0.0.1

jenkins.yml

kind: PersistentVolumeClaimapiVersion: v1metadata: name: jenkins namespace: cispec: accessModes: - ReadWriteMany resources: requests:  storage: 50Gi---apiVersion: v1kind: ServiceAccountmetadata: name: jenkins namespace: ci---apiVersion: rbac.authorization.k8s.io/v1beta1kind: ClusterRoleBindingmetadata: name: jenkinsroleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: cluster-adminsubjects:- kind: ServiceAccount name: jenkins namespace: ci---apiVersion: extensions/v1beta1kind: Deploymentmetadata: name: jenkins namespace: cispec: replicas: 1 template: metadata:  labels:  k8s-app: jenkins spec:  serviceAccount: jenkins  containers:  - name: jenkins  image: harbor.demo.com/private/demo-jenkins:lts  imagePullPolicy: IfNotPresent  volumeMounts:  - mountPath: /var/jenkins_home   name: home  volumes:  - name: home   persistentVolumeClaim:   claimName: jenkins---apiVersion: v1kind: Servicemetadata: name: jenkins-svc namespace: cispec: ports: - port: 8077 targetPort: 8080 name: web - port: 50000 targetPort: 50000 name: slave selector: k8s-app: jenkins type: LoadBalancer

ingress 文件 jenkins-ingress.yaml

#ingressapiVersion: extensions/v1beta1kind: Ingressmetadata: name: jenkins-ingress namespace: ci annotations: nginx.ingress.kubernetes.io/ssl-redirect: "true" nginx.ingress.kubernetes.io/rewrite-target: / nginx.ingress.kubernetes.io/secure-backends: "true"spec: rules: - host: jenkins.demo.com  http:  paths:  - path: /  backend:   serviceName: jenkins-svc   servicePort: 8077

部署

 cd jenkins-yml/ kubectl create -f namespace-ci.yml kubectl create -f pv.yml kubectl create -f jenkins.yml kubectl create -f jenkins-ingress.yaml 

3.Jenkins 访问并安装插件

修改host文件,讲域名解析到157 访问 >cd /usr/local/nfs/updatescp default.json default_back.json$ sed -i 's/http:\/\/updates.jenkins-ci.org\/download/https:\/\/mirrors.tuna.tsinghua.edu.cn\/jenkins/g' default.json && sed -i 's/http:\/\/www.google.com/https:\/\/www.baidu.com/g' default.json

4.jenkins 插件安装

需要安装插件列表

1.kubernetes->配置k8s配置

2.Extended Choice Parameter ->参数化构建

3.Git Parameter->git 获取tag

4.Kubernetes Continuous Deploy->k8s部署

5.Parameterized Remote Trigger Configuration ->远程触发构建

6.user build vars->获取用户参数

7.SSHAgent->git 提交时使用

8.permissive script security ->健康检查脚本

9.Pipeline Utility Steps ->获取版本号

本文由博客群发一文多发等运营工具平台 OpenWrite 发布

原文转载:http://www.shaoqun.com/a/485960.html

燕文物流:https://www.ikjzd.com/w/2229

慧聪集团:https://www.ikjzd.com/w/1836

net a porter:https://www.ikjzd.com/w/2132


kubernetes集群jenkins安装文档项目请参与github项目https://github.com/JustCoWorker/kubernetes-cicd1.jenkins镜像构建1.1catDockerfileFROMjenkins/jenkins:ltsUSERrootARGdockerGid=978WORKDIR/usr/local#RUNwgetapache-maven-3.3
e邮宝:https://www.ikjzd.com/w/594.html?source=tagwish
adore:https://www.ikjzd.com/w/2202
海南户外旅游注意事项 :http://tour.shaoqun.com/a/55114.html
梵净山门票_贵州铜仁梵净山门票价格:http://tour.shaoqun.com/a/61994.html
亚马逊关键字抓取器推荐:https://www.ikjzd.com/tl/102495

No comments:

Post a Comment