Drone

Kube-runner: support mounting PersistentVolumeClaims in Kubernetes pipeline

In a k8s cluster, it is more practical to manage volumes using claims (PVC).

An example pipeline would look like:

kind: pipeline
type: kubernetes
name: default

steps:
- name: react build
  image: node
  volumes:
  - name: npm-cache
    path: /root/.npm
  commands:
  - npm build

volumes:
- name: npm-cache
  pvc: npm-cache-pvc

Thoughts or suggestions are welcome.

Hi @Elgarni, we just needed this feature aswell, so we have forked the repo and added some changes that allow to mount as readOnly an already existing PVC, that we use as shared storage between jobs. I would like to send this Pull Request but I’m not sure how to do it. I read the contributing guide and I understood that first a threat here is needed, isn’t it?

Yes, you’re right.

Can you please highlight some implementation details here, and also why you made it read-only?

@bradrydzewski Can you look at this

We are using Drone for some pipelines that need to access some heavy data that are already present outside the jobs, and we started to download these from a Minio instance, but the download jobs was around 11 min, so we thought that should be useful to mount as read only the PVC to run the jobs without wait to download all the data needed.

the .drone.yml should be something like below, where the already existing PVC is called received-data-claim

kind: pipeline
type: kubernetes
name: default

clone:
  disable: true

steps:
- name: write
  pull: if-not-exists
  image: alpine
  volumes:
  - name: shared
    path: /shared
  commands:
  - pwd
  - ls /shared

# once the pipeline finished, check the host machine
# to see if exists /tmp/drone/test/greetings.txt

volumes:
- name: shared
  claim:
    name: received-data-claim

The pull request is this https://github.com/drone-runners/drone-runner-kube/pull/28

1 Like