Permissions on disk in Gcloud for Jenkins

1/10/2018

How do I have to configure the permissions for a disk in gcloud: I have a kubernetes cluster. I created a persistent disk:

$ gcloud compute disks create --size 30GB jenkins-disk --zone europe-west1-c

content of my deployment.yaml:

volumeMounts:
- mountPath: /var/jenkins_home
  name: jenkins-storage
  volumes:
  - name: jenkins-storage
    gcePersistentDisk:
      pdName: jenkins-disk
      fsType: ext4

error:

touch: cannot touch '/var/jenkins_home/copy_reference_file.log': Permission denied

Do I need to give write access to my jenkins user to write to the disk? How do I have to configure this?

-- DenCowboy
docker
gcloud
google-cloud-platform
jenkins
kubernetes

1 Answer

3/28/2018

Use this image of Jenkins Instead of latest in your deployment https://hub.docker.com/r/wsimmonds/jenkins-kubernetes/

Description from this Image :

Trying to run the default Jenkins image (or jenkinsci/jenkins) with a persistent volume mounted to /var/jenkins_home will currently fail:

2016-06-10T13:46:55.617454157Z touch: cannot touch ‘/var/jenkins_home/copy_reference_file.log’: Permission denied 2016-06-10T13:46:55.617955276Z Can not write to /var/jenkins_home/copy_reference_file.log. Wrong volume permissions?

The reason? Kubernetes volumes are currently mounted with root ownership and Jenkins runs as "jenkins" by default (https://github.com/jenkinsci/docker/blob/master/Dockerfile). The temporary workaround runs Jenkins as root - I don't advise production use unless you know what you're doing and have full control of the code you are building.

-- kam bajwa
Source: StackOverflow