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

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

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的值(在下面添加了值):

storageClass: jenkins-pv
...
serviceAccount:
  create: false

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

PV已创建:

rage@ubuntu-virtual:~$ kubectl describe pv jenkins -n jenkins
名称:jenkins-pv
标签:无
注释:pv.kubernetes.io/bound-by-controller: yes
终结者:[kubernetes.io/pv-protection]
StorageClass:jenkins-pv
状态:Released
Claim:default/jenkins
回收策略:Retain
访问模式:RWO
VolumeMode:Filesystem
容量:5Gi
节点亲和性:无
消息:
来源:
    类型:HostPath(裸主机目录卷)
    路径:/data/jenkins-volume/
    HostPathType:
事件:无

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

$ kubectl describe pvc jenkins -n jenkins
名称:jenkins
命名空间:jenkins
StorageClass:jenkins-pv
状态:Pending
Volume:
标签:app.kubernetes.io/component=jenkins-controller
               app.kubernetes.io/instance=jenkins
               app.kubernetes.io/managed-by=Helm
               app.kubernetes.io/name=jenkins
               helm.sh/chart=jenkins-4.3.23
注释:meta.helm.sh/release-name: jenkins
               meta.helm.sh/release-namespace: jenkins
终结者:[kubernetes.io/pvc-protection]
容量:
访问模式:
VolumeMode:Filesystem
Used By:jenkins-0
事件:
  类型    原因                 年龄                   来自                         消息
  ----    ------               ----                  ----                         -------
  正常  WaitForPodScheduled  38分钟 (x481次在160分钟内)  persistentvolume-controller  等待Pod jenkins-0被调度
  正常  WaitForPodScheduled  28分钟 (x26次在34分钟内)    persistentvolume-controller  等待Pod jenkins-0被调度
  正常  WaitForPodScheduled  2分钟35秒 (x81次在22分钟内)  persistentvolume-controller  等待Pod jenkins-0被调度

Pod的描述:

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

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

更新:

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

nodeAffinity:
required:
  nodeSelectorTerms:
  - matchExpressions:
    - key: kubernetes.io/hostname
      operator: In
      values:
      - minikube

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

claimRef:
name: jenkins
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):
storageClass: jenkins-pv
...
serviceAccount:
  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:

rage@ubuntu-virtual:~$ kubectl describe pv jenkins -n jenkins
Name:            jenkins-pv
Labels:          <none>
Annotations:     pv.kubernetes.io/bound-by-controller: yes
Finalizers:      [kubernetes.io/pv-protection]
StorageClass:    jenkins-pv
Status:          Released
Claim:           default/jenkins
Reclaim Policy:  Retain
Access Modes:    RWO
VolumeMode:      Filesystem
Capacity:        5Gi
Node Affinity:   <none>
Message:         
Source:
    Type:          HostPath (bare host directory volume)
    Path:          /data/jenkins-volume/
    HostPathType:  
Events:            <none>

PVC says: “WaitForPodScheduled”

$ kubectl describe pvc jenkins -n jenkins
Name:          jenkins
Namespace:     jenkins
StorageClass:  jenkins-pv
Status:        Pending
Volume:        
Labels:        app.kubernetes.io/component=jenkins-controller
               app.kubernetes.io/instance=jenkins
               app.kubernetes.io/managed-by=Helm
               app.kubernetes.io/name=jenkins
               helm.sh/chart=jenkins-4.3.23
Annotations:   meta.helm.sh/release-name: jenkins
               meta.helm.sh/release-namespace: jenkins
Finalizers:    [kubernetes.io/pvc-protection]
Capacity:      
Access Modes:  
VolumeMode:    Filesystem
Used By:       jenkins-0
Events:
  Type    Reason               Age                   From                         Message
  ----    ------               ----                  ----                         -------
  Normal  WaitForPodScheduled  38m (x481 over 160m)  persistentvolume-controller  waiting for pod jenkins-0 to be scheduled
  Normal  WaitForPodScheduled  28m (x26 over 34m)    persistentvolume-controller  waiting for pod jenkins-0 to be scheduled
  Normal  WaitForPodScheduled  2m35s (x81 over 22m)  persistentvolume-controller  waiting for pod jenkins-0 to be scheduled

Pod's describe:

Events:
  Type     Reason            Age   From               Message
  ----     ------            ----  ----               -------
  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

nodeAffinity:
required:
  nodeSelectorTerms:
  - matchExpressions:
    - key: kubernetes.io/hostname
      operator: In
      values:
      - minikube

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

   claimRef:
    name: jenkins
    namespace: jenkins

答案1

得分: 2

问题终于解决了。
获得了实际的 Jenkins 存储声明,它是使用 Helm 图表部署的:

> kubectl get pvc jenkins -n jenkins -o yaml

它声明:
```yaml
      resources:
      requests:
      storage: 8Gi

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

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

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

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


<details>
<summary>英文:</summary>

Finally resolved the issue.
Got actual Jenkins volume claim, which was deployed with Helm-chart:

&gt; kubectl get pvc jenkins -n jenkins -o yaml

It stated:
  resources:
  requests:
  storage: 8Gi
And my volume size was lesser: 5Gi. Thats why PVC request was not satisfied.
Very strange, that there wasn&#39;t any particular notice from Kubernetes about it when I did &#39;**describe**&#39; command for PVC/pod.

So I adjusted values.yaml, provided with Jenkins Helm chart to acquire lesser size:

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

Now it works as intended. So there is no glitches in the official documentation related to this case.

</details>



# 答案2
**得分**: 0

[Jenkins网站](https://www.jenkins.io/doc/book/installing/kubernetes/)上的PV的YAML文件具有以下的`nodeSelector`设置:

```yaml
nodeAffinity:
  required:
    nodeSelectorTerms:
    - matchExpressions:
      - key: kubernetes.io/hostname
        operator: In
        values:
        - worker-node01

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

英文:

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

  nodeAffinity:
    required:
      nodeSelectorTerms:
      - matchExpressions:
        - key: kubernetes.io/hostname
          operator: In
          values:
          - 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:

确定