Jenkins 在 Kubernetes 上的安装问题与卷冲突

Jenkins installation on Kubernetes issue with volume conflict

我正在按照此 Link 在 Kubernetes 集群上设置 Jenkins。

环境信息如下,

Environment:-

On-Premise Physical Server

# kubectl get nodes
NAME          STATUS   ROLES      AGE     VERSION
master-server Ready    master     2d23h   v1.19.16
node-server1  Ready    worker1    2d23h   v1.19.16
node-server2  Ready    worker2    2d23h   v1.19.16
node-server3  Ready    worker3    2d23h   v1.19.16

我有以下 yaml 个文件。

deploy-jenkins.yaml  
sa-jenkins.yaml  
service-jenkins.yaml  
volume-jenkins.yaml

PersistentVolume 我想使用我的 master 服务器本地路径,所以在 volume-jenkins.yaml 文件中我更新了 pathvalues 如下。

  local:
    path: /home/linux-user/kubernetes/jenkins
  nodeAffinity:
    required:
      nodeSelectorTerms:
      - matchExpressions:
        - key: kubernetes.io/hostname
          operator: In
          values:
          - master-server

当我应用 yaml 文件时,我的 jenkins pod 始终保持 pending 状态。

Jenkins Pod 状态:-

# kubectl get pods -n jenkins
NAME                       READY   STATUS    RESTARTS   AGE
jenkins-69b8564b9f-gm48n   0/1     Pending   0          102m

Jenkins Pod 描述状态:-

# kubectl describe pod jenkins-69b8564b9f-gm48n -n jenkins

Events:
  Type     Reason            Age                    From               Message
  ----     ------            ----                   ----               -------
  Warning  FailedScheduling  3m45s (x68 over 104m)  default-scheduler  0/4 nodes are available: 1 node(s) had taint {node-role.kubernetes.io/master: }, that the pod didn't tolerate, 3 node(s) had volume node affinity conflict.

PV描述详情:-

# kubectl describe pv jenkins-pv -n jenkins

Name:              jenkins-pv
Labels:            type=local
Annotations:       <none>
Finalizers:        [kubernetes.io/pv-protection]
StorageClass:      local-storage
Status:            Bound
Claim:             jenkins/jenkins-pvc
Reclaim Policy:    Retain
Access Modes:      RWO
VolumeMode:        Filesystem
Capacity:          10Gi
Node Affinity:
  Required Terms:
    Term 0:        kubernetes.io/hostname in [master-server]
Message:
Source:
    Type:  LocalVolume (a persistent volume backed by local storage on a node)
    Path:  /home/linux-user/kubernetes/jenkins
Events:    <none>

我的 yaml 文件有什么问题?并让我知道解决节点冲突问题的方法。提前致谢。

...i want to use my master server local path

nodeSelectortolerations 添加到您的部署规范中:

apiVersion: apps/v1
kind: Deployment
...
spec:
  ...
  template:
    ...
    spec:
      nodeSelector:
        node-role.kubernetes.io/master: ""
      tolerations:
      - key: node-role.kubernetes.io/master
        operator: Exists
      containers:
      - name: jenkins
        ...