This commit is contained in:
병준 박 2025-04-10 09:22:57 +00:00
parent 7e5cab8a97
commit f78ccdff65

View File

@ -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 <<EOF | kubectl apply -f -
# Start writing the PVC YAML
cat <<EOF > /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