3
votes

I am using the Kubernetes Jenkins plugin on an external master. The default disk size is limited to 10GB. Adding a pvc with the name jenkins-workspace, mounts the disk, but it is created with root user 0755 and doesn't allow jenkins user any access.

- Jenkins 2.104 master
- jenkinsci/jnlp slave
- kubernetes 1.7.4
- rhel 7.4

We have a customized jnlp slave, but I have even tried using the default that the plugin pulls in.

Can anybody point me to documentation or related article that shows how to add privileges for the pvc mount or dynamically add space after provisioning.

Our Jenkins master uses the Kubernetes cloud connection from the Configure System with a Kubernetes pod template either pointing to the default jnlp or using a container template to point to our customized jnlp slave in our local registry.

Cheers, Appreciate the help in advance

2
I used a couple of times to configure Jenkins agents through groovy scripts in order to increase memory and CPU resource.Muatik
for memory and CPU, the plugin provides ability to request or limit it. It is the disk space that is a challenge. If not explicitly mounted by "Add Volume", even if the PVC is named jenkins-workspace, it doesn't add the disk space. But an "Add Volume" adds it as root:root. I even tried creating a persistent volume with the following, still no luck:<br> annotations:<br> pv.beta.kubernetes.io/gid: "10000"<br>, which is the gid for jenkins user in the jnlp slavedskviator

2 Answers

0
votes

You can not set the permissions of the mounted volumes (fsGroup) nor the size of the PVC today. It is not implemented in https://github.com/jenkinsci/kubernetes-plugin/blob/master/src/main/java/org/csanchez/jenkins/plugins/kubernetes/volumes/PersistentVolumeClaim.java so it just uses the cluster defaults (

It will be possible using YAML once https://github.com/jenkinsci/kubernetes-plugin/pull/275 is implemented.

0
votes

It is possible to change the permission by using an init container, while defining the slave pod you can include one init container that mount the volume as root and change the permission to jenkins user.