0

我正在关注此链接以在 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文件有什么问题?并让我知道解决节点冲突问题的方法。提前致谢。

4

1 回答 1

2

...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
        ...
  
于 2022-02-10T11:19:01.723 回答