Jenkins 之 安装部署

一、基于linux操作系统安装jenkins(不作重点介绍)

1、下载Jenkins安装包
wget http://mirrors.jenkins.io/war/latest/jenkins.war
Jenkins  之  安装部署

2、安装tomcat与jdk(此步省略)
3、把jenkins.war放到TOMCAT下的webapps
Jenkins  之  安装部署

4、启动tomcat,加载jenkins下的war包
备注:初始密码/root/.jenkins/secrets/initialAdminPasswod

二、基于k8s安装jenkins

1、对应的yaml安装文件

apiVersion: v1
kind: Namespace
metadata:
  name: jenkins          #创建jenkins表空间
---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: jenkins             #创建一个jenkins serviceaccount ,并赋予cluster-admin权限
  namespace: jenkins
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
  name: jenkins-crb
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
- kind: ServiceAccount
  name: jenkins
  namespace: jenkins
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: jenkins-master           #用deployment管理jenkins容器
  namespace: jenkins
spec:
  replicas: 1
  selector:
    matchLabels:
      devops: jenkins-master
  template:
    metadata:
      labels:
        devops: jenkins-master
    spec:
      nodeSelector:
        jenkins: "true"          #固定在某台主机上运行
      serviceAccount: jenkins #Pod 需要使用的服务账号
      initContainers:            #初始化容器加载本地文件夹权限
      - name: fix-permissions
        image: busybox
        command: ["sh", "-c", "chown -R 1000:1000 /var/jenkins_home"]
        securityContext:
          privileged: true
        volumeMounts:
        - name: jenkinshome
          mountPath: /var/jenkins_home
      containers:
      - name: jenkins
        image: jenkinsci/blueocean:1.23.2
        imagePullPolicy: IfNotPresent
        ports:
        - name: http #Jenkins Master Web 服务端口
          containerPort: 8080
        - name: slavelistener #Jenkins Master 供未来 Slave 连接的端口
          containerPort: 50000
        volumeMounts:
        - name: jenkinshome
          mountPath: /var/jenkins_home
        env:
        - name: JAVA_OPTS
          value: "-Xms4096m -Xmx5120m -Duser.timezone=Asia/Shanghai -Dhudson.model.DirectoryBrowserSupport.CSP="
      volumes:
      - name: jenkinshome
        hostPath:
          path: /var/jenkins_home/
---
apiVersion: v1
kind: Service       #service服务
metadata:
  name: jenkins
  namespace: jenkins
spec:
  ports:
  - name: http
    port: 8080
    targetPort: 8080
  - name: slavelistener
    port: 50000
    targetPort: 50000
  type: ClusterIP
  selector:
    devops: jenkins-master
---
apiVersion: extensions/v1beta1
kind: Ingress               #ingress发布
metadata:
  name: jenkins-web
  namespace: jenkins
spec:
  rules:
  - host: jenkins.cedarhd.com
    http:
      paths:
      - backend:
          serviceName: jenkins
          servicePort: 8080
        path: /
上一篇:使用接口来统一控件的取值、赋值和初始化


下一篇:邻接矩阵 构造 有向/无向 图/网