Volume issue with kubernetes plugin in declarative way (1.6.0 and 1.9.2)

17 views
Skip to first unread message

Tristan FAURE

unread,
Aug 24, 2018, 8:42:22 AM8/24/18
to Jenkins Users
Hello

in my jenkins configuration admin GUI I have this volume definition :

Volumes
- Claim Name = nfsdata
Read Only = true
Mount path = /etc/ssl/certs

In scripted pipeline everything works perfectly

In declarative pipeline :
pipeline {
agent {
kubernetes {
label "${jedi}"
yaml """
spec:
containers:
- name: maven
image: maven:3-jdk-8
command:
- cat
tty: true
"""

When i check the generated yaml in kubernetes, the volume is mounted only on the jnlp container and not the maven one

I need to write this to make it work and I don't really like this :
yaml """
spec:
containers:
- name: maven
command:
- cat
tty: true
volumeMounts:
- mountPath: /etc/ssl/certs
name: volume-0
readOnly : true
"""

Thank you in advance

Tristan FAURE

Carlos Sanchez

unread,
Aug 24, 2018, 9:09:42 AM8/24/18
to Jenkins Users
On Fri, Aug 24, 2018 at 10:42 AM Tristan FAURE <faure....@gmail.com> wrote:
Hello

in my jenkins configuration admin GUI I have this volume definition :

Volumes
- Claim Name = nfsdata
Read Only = true
Mount path = /etc/ssl/certs

In scripted pipeline everything works perfectly

In declarative pipeline :
pipeline {
agent {
kubernetes {
label "${jedi}"
yaml """
spec:
containers:
- name: maven
image: maven:3-jdk-8
command:
- cat
tty: true
"""

When i check the generated yaml in kubernetes, the volume is mounted only on the jnlp container and not the maven one

how do you define that this pipeline uses the volume defined in the GUI? using Defaults Provider Template Name?
 

I need to write this to make it work and I don't really like this :
yaml """
spec:
containers:
- name: maven
command:
- cat
tty: true
volumeMounts:
- mountPath: /etc/ssl/certs
name: volume-0
readOnly : true
"""

Thank you in advance

Tristan FAURE

--
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/fc9b3c60-aa86-491e-acf9-d9c6b09ecc06%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tristan FAURE

unread,
Aug 24, 2018, 9:14:09 AM8/24/18
to jenkins...@googlegroups.com
Le ven. 24 août 2018 à 11:09, Carlos Sanchez <car...@apache.org> a écrit :


On Fri, Aug 24, 2018 at 10:42 AM Tristan FAURE <faure....@gmail.com> wrote:
Hello

in my jenkins configuration admin GUI I have this volume definition :

Volumes
- Claim Name = nfsdata
Read Only = true
Mount path = /etc/ssl/certs

In scripted pipeline everything works perfectly

In declarative pipeline :
pipeline {
agent {
kubernetes {
label "${jedi}"
yaml """
spec:
containers:
- name: maven
image: maven:3-jdk-8
command:
- cat
tty: true
"""

When i check the generated yaml in kubernetes, the volume is mounted only on the jnlp container and not the maven one

how do you define that this pipeline uses the volume defined in the GUI? using Defaults Provider Template Name?
I don't know if I answer the question. This pipeline is inside my jenkinsfile, I got the name analyzing my kubernetes cluster. The Volume mount has been defined using the administration GUI
 

I need to write this to make it work and I don't really like this :
yaml """
spec:
containers:
- name: maven
command:
- cat
tty: true
volumeMounts:
- mountPath: /etc/ssl/certs
name: volume-0
readOnly : true
"""

Thank you in advance

Tristan FAURE

--
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/fc9b3c60-aa86-491e-acf9-d9c6b09ecc06%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/8RnJ7fozEdo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CALHFn6M1tx684wFzNoHqiLZhHoySvM2V6JvcO%3DTz%3D7gUNkFrXQ%40mail.gmail.com.

Carlos Sanchez

unread,
Aug 24, 2018, 9:20:16 AM8/24/18
to Jenkins Users
this pipeline does not define any volume and it will not use any volume defined in the GUI. This definition is independent of what you configure in the GUI unless you use "Defaults Provider Template Name" in the GUI, but I don't recommend you to do so. 
I suggest you put the volume definition in the yaml for completion and reproducibility
 

Tristan FAURE

unread,
Aug 24, 2018, 9:23:00 AM8/24/18
to jenkins...@googlegroups.com
OK it makes sense, thank you for the answer

Reply all
Reply to author
Forward
0 new messages