rht-labs / labs-ci-cd

👻UNMAINTAINED - A collection of Red Hat Open Innovation Labs CI/CD components
Apache License 2.0
101 stars 70 forks source link

Add Persistent Volume Claim For Maven/OWASP Dependency Check Caching #195

Open InfoSec812 opened 6 years ago

InfoSec812 commented 6 years ago

Add a PVC to the CI/CD project which can be used as part of a containerTemplate in a Jenkinsfile so that Maven and OWASP Dependency Check data can be cached to improve build performance.

The Jenkinsfile changes would look like:

pipeline {
    agent {
        kubernetes {
            label 'jenkins-slave-cached'
            podTemplate {
                label 'jenkins-slave-cached'
                inheritFrom 'jenkins-slave-mvn'
                ttyEnabled true
                command 'cat'
                volumes: [
                    persistentVolumeClaim {
                        claimName 'maven-cache'
                        mountPath '/home/jenkins/.m2/repository'
                    }
                ]
            }
        }
    }
... SNIP ...
InfoSec812 commented 6 years ago

The PVC definition would look like:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  annotations:
    volume.beta.kubernetes.io/storage-class: glusterfs-storage
    volume.beta.kubernetes.io/storage-provisioner: kubernetes.io/glusterfs
  name: maven-cache
spec:
  accessModes:
  - ReadWriteMany
  resources:
    requests:
      storage: 5Gi
status:
  accessModes:
  - ReadWriteMany
  capacity:
    storage: 5Gi
makentenza commented 6 years ago

@InfoSec812 why are you enforcing the use of Gluster for this backend? Also hardcoding the storageclass name is not a good idea, we should leave this open as we do for other templates so the user can use their existing default storageclass if this exist or use any available PV

sherl0cks commented 5 years ago

@haithamshahin333 FYI