As far as i understood, the kubernetes api allows one to mount a subpath of a pvc into the container in the volumeMounts spec.
In my example i want to mount the pvc my-pvc, but in the subdirectory /my-subpath to /my-mount.
So the directory /my-subpath on my-pvc would be mounted in the container under /my-mount.
When using Kubernetes normally, this would look like follows if i understood the docs:
volumeMounts:
- mountPath: /my-mount
name: my-pvc
subPath: "my-subpath"My problem now is, that in the jenkins kubernetes plugin this doesn't seem to be possible.
If i understood the docs correctly, it seems that it is only possible to mount the root directory, i.e. /, of the pvc my-pvc to /my-mount in the container, since there is no subPath option: 
Is there something i am missing, or is it just not possible to do this?
It is not possible by available options of Jenkins Kubernetes plugin ATM. But still, you can achieve this by applying a raw pod template in Kubernetes cloud pod configuration.
Sample output
Started by user admin
Replayed #11
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline
[Pipeline] podTemplate
[Pipeline] {
[Pipeline] node
Still waiting to schedule task
‘hello-docker-j0rk6’ is offline
Agent hello-docker-j0rk6 is provisioned from template hello-docker
---
apiVersion: "v1"
kind: "Pod"
metadata:
annotations: {}
labels:
run: "hello-docker"
jenkins: "slave"
jenkins/label: "hello-docker"
name: "hello-docker-j0rk6"
spec:
containers:
- command:
- "cat"
image: "jenkins/jnlp-slave:3.27-1-alpine"
name: "hello-docker"
resources: {}
tty: true
volumeMounts:
- mountPath: "/app/logs"
name: "tmp"
subPath: "logs"
- mountPath: "/home/jenkins/agent"
name: "workspace-volume"
readOnly: false