hostPathVolume not mounting on Kubernetes pods(Dynamic Jenkins Agent)

28 views
Skip to first unread message

Mk

unread,
Dec 4, 2020, 10:49:37 PM12/4/20
to Jenkins Users
Environment:
Jenkins - Version 2.235.5 (LTS)
Kubernetes Jenkins Plugin - 1.27.7


K8s-Master & Worker Server Details:-
OS - CentOS Linux release 7.9.2009 (Core) & Kernal - 3.10.0-1160.6.1.el7.x86_64
Docker Version - 19.03.12
Client Version: v1.19.0
Server Version: v1.19.0


I am trying to mount a hostPathVolume through Jenkins Kubernetes-plugin podTemplate and when the pod gets kicked off via Jenkins master the path of my K8s worker not getting mounted on K8s pods(Jenkins Agent).

I have the below podTemplate

podTemplate(containers: [
containerTemplate(name: 'build', image: 'alpine/git', ttyEnabled: true, command: 'cat'),
containerTemplate(name: 'test', image: 'maven:3.3.9-jdk-8-alpine', command: 'cat', ttyEnabled: true),
],
volumes: [
hostPathVolume(mountPath: '/home/jenkins', hostPath: '/test-vol/abc/workspace'),
]
) {
node ("jenkins-node") {
stage('Code Checkout') {
checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false, timeout: 120]], submoduleCfg: [], userRemoteConfigs: [[url: 'ssh://userid@gerrit-server:29418/abc/repository']]])
}
}
node(POD_LABEL) {
stage('Build') {
container('build') {
sh label: '', script: '''cd /home/jenkins/Jenkins_Job/project/src/
mvn clean install'''
}
stage('Test') {
container('test') {
sh label: '', script: '''cd /home/jenkins/Jenkins_Job/project/src/
mvn test'''
}
}
}
}
}

I expect the volume to be mounted in my pod, I have tried with K8s v1.19.4 and Kubernetes Jenkins Plugin - 1.27.0 but same result. Not sure what is causing the problem on CentOS-7.9 K8s. Whereas the same is working perfectly on CentOS - 8.2.2004 (Core) & 4.18.0-193.14.2.el8_2.x86_64 kernal.

Ujjawal Khare

unread,
Dec 5, 2020, 8:15:41 AM12/5/20
to jenkins...@googlegroups.com
The issue may be because of kernel version. Old alpine seems to be having issue with it.

Can you try same on an older version of CentOS..?

Or try to use latest version of alpine.

Regards,
Ujjawal

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/73c67b12-bea5-4e9b-b51a-0acf83f1bd76n%40googlegroups.com.

Mohan

unread,
Dec 5, 2020, 8:36:51 AM12/5/20
to jenkins...@googlegroups.com
Acutally have tried with Ubuntu-16.04-LTS image aswell even in that also same issue.

Sure next will try with K8s host's native OS CentOS- 7.8(It was working earlier).

Ujjawal Khare

unread,
Dec 5, 2020, 8:40:06 AM12/5/20
to jenkins...@googlegroups.com
Great and if it again works on older CentOS then please try to update your alpine to latest version.

I am sure then it will start working on latest CentOS too.

We recently faced similar issue with elasticsearch 7 and then it got fixed after we updated Alpin.

Mohan

unread,
Dec 6, 2020, 11:56:31 PM12/6/20
to jenkins...@googlegroups.com
Thanks Ujjawal. I have upgraded my docker image from Ubuntu 16.04.6 LTS - 3.10.0-1160.6.1.el7.x86_64 to Ubuntu 16.04.7 to 3.10.0-1160.6.1.el7.x86_64 still didn't work. But it seems Kubernetes on CentOS-7.9 & with Kernal-3.10.0-1160.6.1.el7.x86_64 is having a kernel specific issue. So I have upgraded my native host's OS to CentOS-8.2 with - 4.18.0-193.28.1.el8_2.x86_64 kernel, Now my pipeline build is working fine.

Ujjawal Khare

unread,
Dec 7, 2020, 9:58:51 AM12/7/20
to jenkins...@googlegroups.com
Great...if you want it to work on other versions...then play with alpine version..(try with latest first...) your u are using in your docker container 

Reply all
Reply to author
Forward
0 new messages