Is there a way to pass the claim as VolumeClaimTemplate and then provide its values to the pipeline so those are used when the PipelineRun is created at the execution of the pipeline instead of a PVC?

I have this VolumeClaimTemplate (see the image) and need to pass its details through the tkn start pipeline-name CLI command: VolumeClaimTemplate

My entire CLI command is as next:

tkn pipeline start run-tests-portal-with-report --showlog \
 -w name=shared-data,claimName=VolumeClaimTemplate,storageClassName=default-netapp-disk,accessModes=ReadWriteOnce,storage=1Gi,volumeMode=Filesystem \
 -w name=git-credentials,secret=gh-token \
 -p repo-url=https://github.com/my-project-url \
 -p revision=PRJT-123

Now this is the error I am getting in openshift:

message: >- pod status "PodScheduled":"False"; message: "0/12 nodes are available: 12 persistentvolumeclaim "VolumeClaimTemplate" not found. preemption: 0/12 nodes are available: 12 Preemption is not helpful for scheduling."

I understand the issue, but how do I tell it through the CLI that 'use this VolumeClaimTemplate' where the 'StorageClass is default-netapp-disk' with the other details (though when I manually select the storage class in the UI it automatically sets the access mode, size and volume mode) and then it'll use it to create the PersistentVolume at runtime within the PipelineRun?

I hope this is explanatory enough, Is this even doable?

I've tried many things and could not find a solution, I am not even sure this is doable.

1

There are 1 answers

0
AlpHa03 On

The command that you provided will create an incorrect workspace in the PipelineRun that looks like this:

workspaces:
  - name: source
    persistantVolumeClaim:
      claimName: VolumeClaimTemplate

You need to use the volumeClaimTemplateFile option with the —workspace parameter when you use the tkn CLI like the following (https://github.com/tektoncd/cli/pull/1066):

tkn pipeline start pipeline-with-workspace --workspace name=myworkspace,volumeClaimTemplateFile=/path/to/pvc.yaml

Where pvc.yaml is the file that will be like that for your case:

spec:
  accessModes:
    - ReadWriteOnce
  volumeMode: Filesystem
  storageClassName: default-netapp-disk
  resources:
    requests:
      storage: 1Gi

By running the command the generated PipelineRun will be:

apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
  name: my-pipelinerun-name
spec:
  workspaces:
    - name: myworkspace
      volumeClaimTemplate:
        spec:
          accessModes:
            - ReadWriteOnce
          volumeMode: Filesystem
          storageClassName: default-netapp-disk
          resources:
            requests:
              storage: 1Gi    
pipelineRef:
    name: pipeline-with-workspace