From f78ccdff651fb1e2cf5b9e73b1f8b9c99a2554db Mon Sep 17 00:00:00 2001 From: BAK BYEONG JUN Date: Thu, 10 Apr 2025 09:22:57 +0000 Subject: [PATCH] init --- tasks/before-pipeline/task.yaml | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/tasks/before-pipeline/task.yaml b/tasks/before-pipeline/task.yaml index b69e4c9..102bf01 100644 --- a/tasks/before-pipeline/task.yaml +++ b/tasks/before-pipeline/task.yaml @@ -17,6 +17,13 @@ spec: description: | The requested size of the PVC (e.g., "1Gi", "5Gi"). + - name: pvcStorageClass + type: string + default: "" + description: | + The name of the StorageClass to use. Leave empty to use the default storage class. + + results: - name: pvcName description: | @@ -29,15 +36,13 @@ spec: #!/bin/sh set -e - echo "pvcEnable: $(params.pvcEnable)" if [ "$(params.pvcEnable)" = "true" ]; then - # Generate a random PVC name RAND=$(head /dev/urandom | tr -dc a-z0-9 | head -c 6) PVC_NAME="before-pvc-${RAND}" echo "Creating PVC: ${PVC_NAME}" - # Apply PVC manifest - cat < /tmp/pvc.yaml apiVersion: v1 kind: PersistentVolumeClaim metadata: @@ -51,10 +56,18 @@ spec: volumeMode: Filesystem EOF - # Output the PVC name as a Task result + # Append storageClassName if provided + if [ "$(params.storageClass)" != "" ]; then + echo " storageClassName: $(params.storageClass)" >> /tmp/pvc.yaml + fi + + # Apply PVC + kubectl apply -f /tmp/pvc.yaml + + # Write result echo -n "${PVC_NAME}" > $(results.pvcName.path) - echo "PVC creation complete: ${PVC_NAME}" + echo "PVC created: ${PVC_NAME}" else echo "PVC creation skipped (pvcEnable=false)" echo -n "" > $(results.pvcName.path) - fi + fi \ No newline at end of file