无法使用官方指南将 Jenkins 部署到 Kubernetes。

huangapple go评论86阅读模式
英文:

Unable to deploy Jenkins to Kubernetes using official guide

问题

I'm here to provide the translated content:

我正在尝试使用官方指南在Kubernetes上安装Jenkins:Jenkins官方网站使用Helm v3安装Jenkins。环境为Linux/Minikube。

  1. 我创建了Jenkins的命名空间。
  2. 使用提供的yaml文件创建了持久卷(PV)。
  3. 创建了服务账户
  4. 使用以下命令进行安装:helm install jenkins -n jenkins -f jenkins-values.yaml jenkinsci/jenkins,其中的值也是官方提供的。

我仅根据指导中的建议提醒了Jenkins的值(在下面添加了值):

  1. storageClass: jenkins-pv
  2. ...
  3. serviceAccount:
  4. create: false

问题: Jenkins的Pod从未启动。
它说:“0/1个节点可用:1个节点未找到可用的持久卷来绑定。 抢占:0/1个节点可用:抢占对调度没有帮助…”

PV已创建:

  1. rage@ubuntu-virtual:~$ kubectl describe pv jenkins -n jenkins
  2. 名称:jenkins-pv
  3. 标签:无
  4. 注释:pv.kubernetes.io/bound-by-controller: yes
  5. 终结者:[kubernetes.io/pv-protection]
  6. StorageClassjenkins-pv
  7. 状态:Released
  8. Claimdefault/jenkins
  9. 回收策略:Retain
  10. 访问模式:RWO
  11. VolumeModeFilesystem
  12. 容量:5Gi
  13. 节点亲和性:无
  14. 消息:
  15. 来源:
  16. 类型:HostPath(裸主机目录卷)
  17. 路径:/data/jenkins-volume/
  18. HostPathType
  19. 事件:无

PVC显示:“等待Pod调度”:

  1. $ kubectl describe pvc jenkins -n jenkins
  2. 名称:jenkins
  3. 命名空间:jenkins
  4. StorageClassjenkins-pv
  5. 状态:Pending
  6. Volume
  7. 标签:app.kubernetes.io/component=jenkins-controller
  8. app.kubernetes.io/instance=jenkins
  9. app.kubernetes.io/managed-by=Helm
  10. app.kubernetes.io/name=jenkins
  11. helm.sh/chart=jenkins-4.3.23
  12. 注释:meta.helm.sh/release-name: jenkins
  13. meta.helm.sh/release-namespace: jenkins
  14. 终结者:[kubernetes.io/pvc-protection]
  15. 容量:
  16. 访问模式:
  17. VolumeModeFilesystem
  18. Used Byjenkins-0
  19. 事件:
  20. 类型 原因 年龄 来自 消息
  21. ---- ------ ---- ---- -------
  22. 正常 WaitForPodScheduled 38分钟 (x481次在160分钟内) persistentvolume-controller 等待Pod jenkins-0被调度
  23. 正常 WaitForPodScheduled 28分钟 (x26次在34分钟内) persistentvolume-controller 等待Pod jenkins-0被调度
  24. 正常 WaitForPodScheduled 2分钟35 (x81次在22分钟内) persistentvolume-controller 等待Pod jenkins-0被调度

Pod的描述:

  1. 事件:
  2. 类型 原因 年龄 来自 消息
  3. ---- ------ ---- ---- -------
  4. 警告 FailedScheduling 37 default-scheduler 0/1个节点可用:1个节点未找到可用的持久卷来绑定。 抢占:0/1个节点可用:1抢占对调度没有帮助..

请协助调查此问题。我猜这与PVC有关,但无法确定问题的具体原因。

更新:

我还尝试将nodeAffinity添加到我的PersistentVolume,但没有成功。我在这里放置了minikube,因为我是在本地开发。

  1. nodeAffinity:
  2. required:
  3. nodeSelectorTerms:
  4. - matchExpressions:
  5. - key: kubernetes.io/hostname
  6. operator: In
  7. values:
  8. - minikube

我还添加了claimRef,名称为Jenkins。Jenkins Helm安装会创建具有此名称的PVC。

  1. claimRef:
  2. name: jenkins
  3. namespace: jenkins
英文:

I'm trying to install Jenkins on Kubernetes with its official guide: at Jenkins's site, Install Jenkins with Helm v3. The environment is Linux/Minikube.

  1. I created namespace Jenkins
  2. Created Persistent Volume with the yaml provided
  3. Created service account
  4. Installed with helm install jenkins -n jenkins -f jenkins-values.yaml jenkinsci/jenkins where values are official too
    I only alerted Jenkins values as it was recommended in the instruction (added values below):
  1. storageClass: jenkins-pv
  2. ...
  3. serviceAccount:
  4. create: false

The issue: Jenkins pod never starts.
It says: “0/1 nodes are available: 1 node(s) didn’t find available persistent volumes to bind. preemption: 0/1 nodes are available: 1 Preemption is not helpful for scheduling…”

PV is created:

  1. rage@ubuntu-virtual:~$ kubectl describe pv jenkins -n jenkins
  2. Name: jenkins-pv
  3. Labels: <none>
  4. Annotations: pv.kubernetes.io/bound-by-controller: yes
  5. Finalizers: [kubernetes.io/pv-protection]
  6. StorageClass: jenkins-pv
  7. Status: Released
  8. Claim: default/jenkins
  9. Reclaim Policy: Retain
  10. Access Modes: RWO
  11. VolumeMode: Filesystem
  12. Capacity: 5Gi
  13. Node Affinity: <none>
  14. Message:
  15. Source:
  16. Type: HostPath (bare host directory volume)
  17. Path: /data/jenkins-volume/
  18. HostPathType:
  19. Events: <none>

PVC says: “WaitForPodScheduled”

  1. $ kubectl describe pvc jenkins -n jenkins
  2. Name: jenkins
  3. Namespace: jenkins
  4. StorageClass: jenkins-pv
  5. Status: Pending
  6. Volume:
  7. Labels: app.kubernetes.io/component=jenkins-controller
  8. app.kubernetes.io/instance=jenkins
  9. app.kubernetes.io/managed-by=Helm
  10. app.kubernetes.io/name=jenkins
  11. helm.sh/chart=jenkins-4.3.23
  12. Annotations: meta.helm.sh/release-name: jenkins
  13. meta.helm.sh/release-namespace: jenkins
  14. Finalizers: [kubernetes.io/pvc-protection]
  15. Capacity:
  16. Access Modes:
  17. VolumeMode: Filesystem
  18. Used By: jenkins-0
  19. Events:
  20. Type Reason Age From Message
  21. ---- ------ ---- ---- -------
  22. Normal WaitForPodScheduled 38m (x481 over 160m) persistentvolume-controller waiting for pod jenkins-0 to be scheduled
  23. Normal WaitForPodScheduled 28m (x26 over 34m) persistentvolume-controller waiting for pod jenkins-0 to be scheduled
  24. Normal WaitForPodScheduled 2m35s (x81 over 22m) persistentvolume-controller waiting for pod jenkins-0 to be scheduled

Pod's describe:

  1. Events:
  2. Type Reason Age From Message
  3. ---- ------ ---- ---- -------
  4. Warning FailedScheduling 37s default-scheduler 0/1 nodes are available: 1 node(s) didn't find available persistent volumes to bind. preemption: 0/1 nodes are available: 1 Preemption is not helpful for scheduling..

Please, help investigate to this problem. I quess its PVC-related, but can't catch where exactly the problem is.

UPDATE

Also I tried to add nodeAffinity to my PersistentVolume, with no success. I put minikube here, because I'm developing locally

  1. nodeAffinity:
  2. required:
  3. nodeSelectorTerms:
  4. - matchExpressions:
  5. - key: kubernetes.io/hostname
  6. operator: In
  7. values:
  8. - minikube

Also I added claimRef with name Jenkins. Jenkins Helm installation creates PVC with this name.

  1. claimRef:
  2. name: jenkins
  3. namespace: jenkins

答案1

得分: 2

  1. 问题终于解决了。
  2. 获得了实际的 Jenkins 存储声明,它是使用 Helm 图表部署的:
  3. > kubectl get pvc jenkins -n jenkins -o yaml
  4. 它声明:
  5. ```yaml
  6. resources:
  7. requests:
  8. storage: 8Gi

而我的存储大小较小:5Gi。这就是为什么 PVC 请求未被满足的原因。
非常奇怪,当我对 PVC/pod 运行 'describe' 命令时,Kubernetes 没有给出任何特别的通知。

因此,我调整了与 Jenkins Helm 图表一起提供的 values.yaml,以获取较小的大小:

  1. storageClass: jenkins-pv
  2. annotations: {}
  3. labels: {}
  4. accessMode: "ReadWriteOnce"
  5. size: "5Gi"

现在它按预期工作了。因此,在官方文档中与此情况相关的部分没有任何错误。

  1. <details>
  2. <summary>英文:</summary>
  3. Finally resolved the issue.
  4. Got actual Jenkins volume claim, which was deployed with Helm-chart:
  5. &gt; kubectl get pvc jenkins -n jenkins -o yaml
  6. It stated:
  1. resources:
  2. requests:
  3. storage: 8Gi
  1. And my volume size was lesser: 5Gi. Thats why PVC request was not satisfied.
  2. Very strange, that there wasn&#39;t any particular notice from Kubernetes about it when I did &#39;**describe**&#39; command for PVC/pod.
  3. So I adjusted values.yaml, provided with Jenkins Helm chart to acquire lesser size:

storageClass: jenkins-pv
annotations: {}
labels: {}
accessMode: "ReadWriteOnce"
size: "5Gi"

  1. Now it works as intended. So there is no glitches in the official documentation related to this case.
  2. </details>
  3. # 答案2
  4. **得分**: 0
  5. [Jenkins网站](https://www.jenkins.io/doc/book/installing/kubernetes/)上的PV的YAML文件具有以下的`nodeSelector`设置:
  6. ```yaml
  7. nodeAffinity:
  8. required:
  9. nodeSelectorTerms:
  10. - matchExpressions:
  11. - key: kubernetes.io/hostname
  12. operator: In
  13. values:
  14. - worker-node01

你已经将 worker-node01 替换为你的节点名称了吗?

英文:

The yaml of pv at jenkins's site has nodeSelector like below

  1. nodeAffinity:
  2. required:
  3. nodeSelectorTerms:
  4. - matchExpressions:
  5. - key: kubernetes.io/hostname
  6. operator: In
  7. values:
  8. - worker-node01

have you replaced worker-node01 to your nodeName?

huangapple
  • 本文由 发表于 2023年5月25日 00:30:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/76325671.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定