Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-65425

Add Volumesnapshot as option for Kubernetes pod workspace volume

    • Icon: New Feature New Feature
    • Resolution: Unresolved
    • Icon: Major Major
    • kubernetes-plugin
    • None
    • Jenkins: 2.277.2
      Kubernetes plugin: 1.29.2

      Since Kubernetes release 1.12 the idea of a volumesnapshot has existed, where the state of a persistent volume is captured so that it can be recreated in the future. This feature was released to beta in K8s 1.17 and GA in 1.20. 

      My use case is Yocto, where a majority of the embedded kernel does not change and only a relatively small number of applications are altered frequently. At the moment, using dynamic persistent volume claims, the entire kernel needs to be rebuilt every time, leading to complaints from developers about long build times. If I could capture a volume snapshot with a complete build of our image, then I could make use of Yocto's tools to handle incremental building and the like.

      In Jenkins, an additional option in the pod template Workspace Volume dropdown would be added called Volume Snapshot. When selected, the user would need to enter the name of the existing volume snapshot that would be used to create a dynamic persistent volume for builds using that pod template. Or feel free to choose a better implementation, since you are the experts.

          [JENKINS-65425] Add Volumesnapshot as option for Kubernetes pod workspace volume

          Aaron Borden added a comment -

          FYI, you can build your own by using a pod template with ephemeral volume specs and manually managing the VolumeSnapshot. This template uses an existing VolumeSnapshot named "git" to clone from. Imagine the VolumeSnapshot gets updated in a separate Jenkins job.

          apiVersion: v1
          kind: Pod
          metadata:
            name: debug
          spec:
            containers:
              - name: debug
                image: bitnami/git:latest
                command: [sleep, infinity]
                securityContext:
                  runAsUser: 1000
                volumeMounts:
                  - name: git
                    mountPath: /git
            volumes:
              - name: git
                ephemeral:
                  volumeClaimTemplate:
                    metadata:
                      labels:
                        type: git
                    spec:
                      dataSource:
                        name: git
                        kind: VolumeSnapshot
                        apiGroup: snapshot.storage.k8s.io
                      accessModes:
                        - ReadWriteOnce
                      resources:
                        requests:
                          storage: 1Gi

          Aaron Borden added a comment - FYI, you can build your own by using a pod template with ephemeral volume specs and manually managing the VolumeSnapshot. This template uses an existing VolumeSnapshot named "git" to clone from. Imagine the VolumeSnapshot gets updated in a separate Jenkins job. apiVersion: v1 kind: Pod metadata:   name: debug spec:   containers:     - name: debug       image: bitnami/git:latest       command: [sleep, infinity]       securityContext:         runAsUser: 1000       volumeMounts:         - name: git           mountPath: /git   volumes:     - name: git       ephemeral:         volumeClaimTemplate:           metadata:             labels:               type: git           spec:             dataSource:               name: git               kind: VolumeSnapshot               apiGroup: snapshot.storage.k8s.io             accessModes:               - ReadWriteOnce             resources:               requests:                 storage: 1Gi

            Unassigned Unassigned
            faroguy0 Ian Panzer
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: