Home > Blockchain >  Jenkins installation on Kubernetes issue with volume conflict
Jenkins installation on Kubernetes issue with volume conflict

Time:02-11

I'm following this Link to setup Jenkins on Kubernetes cluster.

The environment information is mentioned below,

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

I have below yaml files.

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

PersistentVolume i want to use my master server local path, So in the volume-jenkins.yaml file I have updated path and values as below.

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

When i apply the yaml files, My jenkins pod remain in pending status always.

Jenkins Pod status:-

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

Jenkins Pod describe Status:-

# 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 describe details:-

# 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>

What is wrong with my yaml files? and let me know the way to solve the node conflict issue. Thanks in advance.

CodePudding user response:

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

Add nodeSelector and tolerations to your deployment spec:

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
        ...
  
  • Related