I am running the kubernetes plugin for jenkins i k8s in AKS. When I run a build I see that the agent defaults this workspace dir to:
name: "my-jenkins-agent" tty: true - mountPath: "/home/jenkins/agent" name: "workspace-volume" readOnly: false env: - name: "JENKINS_AGENT_WORKDIR" value: "/home/jenkins/agent" volumes: - emptyDir: medium: "" name: "workspace-volume"
As I understand that means the files/folders used in the workspace during the build is stored in the emptyDir on the host node confirmed by (default):
workspaceVolume The type of volume to use for the workspace.
emptyDirWorkspaceVolume(default): an empty dir allocated on the host machine
dynamicPVC(): a persistent volume claim managed dynamically. It is deleted at the same time as the pod.
hostPathWorkspaceVolume(): a host path volume
nfsWorkspaceVolume(): a nfs volume
persistentVolumeClaimWorkspaceVolume(): an existing persistent volume claim by name.
Before experimenting with using a PVC or e.g. hostPathWorkspaceVolume I guess using the default (emptyDir) should be just fine? Or are there some best practices when it comes to configuring the workspace dir?
The reason I am asking is that I am seeing increased pod (jenkins agent) evictions errors like:
Status: Failed Reason: Evicted Message: The node was low on resource: ephemeral-storage. Container jnlp was using 156Ki, which exceeds its request of 0. Container docker was using 56Ki, which exceeds its request of 0.
and I assume that might have to do with using emptyDir as workspace location for all my builds (I regularly purge unused docker tags/volumes from the host nodes).
I would like to make sure that when a build starts its using a clean workspace but I would also like to avoid exhausting the disk capacity on my worker nodes (eventually leading to the pod evictions).
And looking at the defaults:
volumes: - emptyDir: medium: "" name: "workspace-volume"
does the medium field correspond to
emptyDir.medium described here (and “” string being the value meaning its NOT using RAM-backed filesystem):
Depending on your environment,
emptyDirvolumes are stored on whatever medium that backs the node such as disk or SSD, or network storage. However, if you set the
"Memory", Kubernetes mounts a tmpfs (RAM-backed filesystem) for you instead. While tmpfs is very fast, be aware that unlike disks, tmpfs is cleared on node reboot and any files you write count against your container’s memory limit.