亚洲激情专区-91九色丨porny丨老师-久久久久久久女国产乱让韩-国产精品午夜小视频观看

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

kubernetes中怎么安裝Jenkins

發布時間:2021-06-22 15:15:18 來源:億速云 閱讀:216 作者:Leah 欄目:大數據

本篇文章為大家展示了kubernetes中怎么安裝Jenkins,內容簡明扼要并且容易理解,絕對能使你眼前一亮,通過這篇文章的詳細介紹希望你能有所收獲。

1、k8s部署Jenkins

1)構建Jenkins鏡像,使用阿里云的構建鏡像Dockerfile如下:

FROM jenkins/jenkins #這個是官方鏡像,必須基于官方鏡像構建,否則安裝之后還是要更新,又報錯

USER root
#清除了基礎鏡像設置的源,切換成阿里云的jessie源
RUN echo '' > /etc/apt/sources.list.d/jessie-backports.list \
  && echo "deb http://mirrors.aliyun.com/debian jessie main contrib non-free" > /etc/apt/sources.list \
  && echo "deb http://mirrors.aliyun.com/debian jessie-updates main contrib non-free" >> /etc/apt/sources.list \
  && echo "deb http://mirrors.aliyun.com/debian-security jessie/updates main contrib non-free" >> /etc/apt/sources.list
#更新源并安裝缺少的包
RUN apt-get update && apt-get install -y libltdl7

ARG dockerGid=999

RUN echo "docker:x:${dockerGid}:jenkins" >> /etc/group \
USER jenkins

2)部署Jenkins鏡像

A、創建pv持久化存儲卷,本次用的是宿主機文件系統

apiVersion: "v1"
kind: "PersistentVolume"
metadata:
  name: jenkins-0
spec:
  capacity:
    storage: "10Gi"
  accessModes:
    - "ReadWriteMany"
  hostPath :
    path: /tmp
    volumeName: jenkins

B、創建賬戶

kubectl create -f service-account.yml

# In GKE need to get RBAC permissions first with
# kubectl create clusterrolebinding cluster-admin-binding --clusterrole=cluster-admin [--user=<user-name>|--group=<group-name>]

---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: jenkins
  namespace: default

---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
  name: jenkins
  namespace: default
rules:
- apiGroups: [""]
  resources: ["pods"]
  verbs: ["create","delete","get","list","patch","update","watch"]
- apiGroups: [""]
  resources: ["pods/exec"]
  verbs: ["create","delete","get","list","patch","update","watch"]
- apiGroups: [""]
  resources: ["pods/log"]
  verbs: ["get","list","watch"]
- apiGroups: [""]
  resources: ["secrets"]
  verbs: ["get"]

---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: RoleBinding
metadata:
  name: jenkins
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: jenkins
subjects:
- kind: ServiceAccount
  name: jenkins
  namespace: default
  
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
  name: jenkinsClusterRole
  namespace: default
rules:
- apiGroups: [""]
  resources: ["pods"]
  verbs: ["create","delete","get","list","patch","update","watch"]
- apiGroups: [""]
  resources: ["pods/exec"]
  verbs: ["create","delete","get","list","patch","update","watch"]
- apiGroups: [""]
  resources: ["pods/log"]
  verbs: ["get","list","watch"]
- apiGroups: [""]
  resources: ["secrets"]
  verbs: ["get"]

---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: RoleBinding
metadata:
  name: jenkinsClusterRuleBinding
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: jenkinsClusterRole
subjects:
- kind: ServiceAccount
  name: jenkins
  namespace: default

C、創建Jenkins服務

kubectl create -f jenkins.yml

# jenkins

---
apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
  name: jenkins
  namespace: default
  labels:
    name: jenkins
spec:
  serviceName: jenkins
  replicas: 1
  updateStrategy:
    type: RollingUpdate
  template:
    metadata:
      name: jenkins
      labels:
        name: jenkins
    spec:
      terminationGracePeriodSeconds: 10
      serviceAccountName: jenkins
      imagePullSecrets:
            - name: registry-secret
      containers:
        - name: jenkins
          # image: jenkins/jenkins:lts-alpine
          # image: chadmoon/jenkins-docker-kubectl:latest h2kkan/jenkins-docker
          image: registry.cn-shanghai.aliyuncs.com/pml/jenkins:v1.0
          imagePullPolicy: Always
          ports:
            - containerPort: 8080
            - containerPort: 50000
          resources:
            limits:
              cpu: 1
              memory: 1Gi
            requests:
              cpu: 0.5
              memory: 500Mi
          env:
            - name: LIMITS_MEMORY
              valueFrom:
                resourceFieldRef:
                  resource: limits.memory
                  divisor: 1Mi
            - name: JAVA_OPTS
              # value: -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap -XX:MaxRAMFraction=1 -XshowSettings:vm -Dhudson.slaves.NodeProvisioner.initialDelay=0 -Dhudson.slaves.NodeProvisioner.MARGIN=50 -Dhudson.slaves.NodeProvisioner.MARGIN0=0.85
              value: -Xmx800m -XshowSettings:vm -Dhudson.slaves.NodeProvisioner.initialDelay=0 -Dhudson.slaves.NodeProvisioner.MARGIN=50 -Dhudson.slaves.NodeProvisioner.MARGIN0=0.85
          volumeMounts:
            - name: jenkins-home
              mountPath: /var/jenkins_home
            - name: docker
              mountPath: /usr/bin/docker
            - name: docker-sock
              mountPath: /var/run/docker.sock
          securityContext:
            privileged: true
      volumes:
        - name: docker
          hostPath:
            path: /usr/bin/docker
        - name: docker-sock
          hostPath:
            path: /var/run/docker.sock
  volumeClaimTemplates:
  - metadata:
      name: jenkins-home
      # annotations:
      #   volume.beta.kubernetes.io/storage-class: anything
    spec:
      accessModes: [ "ReadWriteOnce" ]
      resources:
        requests:
          storage: 1Gi

---
apiVersion: v1
kind: Service
metadata:
  name: jenkins
  namespace: default
  annotations:
    # ensure the client ip is propagated to avoid the invalid crumb issue (k8s <1.7)
    # service.beta.kubernetes.io/external-traffic: OnlyLocal
spec:
  type: NodePort
  selector:
    name: jenkins
  # k8s 1.7+
  externalTrafficPolicy: Local
  ports:
    -
      name: http
      port: 80
      targetPort: 8080
      protocol: TCP
    -
      name: agent
      port: 50000
      protocol: TCP

2、登錄并配置Jenkins

1)登錄咋說呢,上圖吧

找到服務端口

kubernetes中怎么安裝Jenkins

2)瀏覽器輸入node的ip加上端口,諸如:http://192.168.16.131:32453,就可以了

3)裝插件,kubernetes plugin

4)配憑據,一個是登錄gitee的(下代碼),一個是登錄docker倉庫的(pull/push鏡像),還一個是ssh登錄k8s的(deploy)

kubernetes中怎么安裝Jenkins

3、找個demo項目吧

看到這了,star/fork一下行不行,看提交記錄就知道差點搞瘋了!!!

https://gitee.com/chenqq/petclinic/

4、配下流水線

kubernetes中怎么安裝Jenkins

kubernetes中怎么安裝Jenkins

5、enjoy it!!!

kubernetes中怎么安裝Jenkins

kubernetes中怎么安裝Jenkins

如果持久化存儲卷聲明一直在pending,參考如下,重新設置狀態:

{
  "kind": "PersistentVolumeClaim",
  "apiVersion": "v1",
  "metadata": {
    "name": "jenkins-home-jenkins-0",
    "namespace": "default",
    "selfLink": "/api/v1/namespaces/default/persistentvolumeclaims/jenkins-home-jenkins-0",
    "uid": "e0e85f5b-b64b-11e9-acc8-000c29e92529",
    "resourceVersion": "649259",
    "creationTimestamp": "2019-08-04T00:07:42Z",
    "labels": {
      "name": "jenkins"
    },
    "annotations": {
      "pv.kubernetes.io/bind-completed": "yes",
      "pv.kubernetes.io/bound-by-controller": "yes"
    },
    "finalizers": [
      "kubernetes.io/pvc-protection"
    ]
  },
  "spec": {
    "accessModes": [
      "ReadWriteOnce"
    ],
    "resources": {
      "requests": {
        "storage": "1Gi"
      }
    },
    "volumeName": "jenkins-1",
    "volumeMode": "Filesystem",
    "dataSource": null
  },
  "status": {
    "phase": "Bound",
    "accessModes": [
      "ReadWriteOnce"
    ],
    "capacity": {
      "storage": "10Gi"
    }
  }
}

上述內容就是kubernetes中怎么安裝Jenkins,你們學到知識或技能了嗎?如果還想學到更多技能或者豐富自己的知識儲備,歡迎關注億速云行業資訊頻道。

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

德令哈市| 中方县| 观塘区| 屯留县| 新田县| 连江县| 安龙县| 梨树县| 昌宁县| 阿合奇县| 海林市| 云龙县| 介休市| 确山县| 林芝县| 永济市| 乾安县| 茌平县| 永丰县| 瓮安县| 江孜县| 枣阳市| 太康县| 滨州市| 松阳县| 泽普县| 闽侯县| 任丘市| 会理县| 湖北省| 洛浦县| 南城县| 揭东县| 南和县| 桂东县| 吴旗县| 集贤县| 阜南县| 屯昌县| 怀安县| 襄汾县|