This commit is contained in:
병준 박 2025-04-10 10:06:43 +00:00
parent 643a5f5677
commit f87d27ee0d

View File

@ -10,25 +10,20 @@ spec:
description: |
Whether to create a PersistentVolumeClaim (PVC).
Set to "true" to create a PVC. Set to "false" to skip creation.
- name: pvcSize
type: string
default: "1Gi"
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: |
The name of the created PVC. If pvcEnable is false, this will be an empty string.
steps:
- name: maybe-create-pvc
image: bitnami/kubectl:latest
@ -41,30 +36,25 @@ spec:
PVC_NAME="before-pvc-${RAND}"
echo "Creating PVC: ${PVC_NAME}"
# Start writing the PVC YAML
cat <<EOF > /tmp/pvc.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: ${PVC_NAME}
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: $(params.pvcSize)
volumeMode: Filesystem
EOF
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: ${PVC_NAME}
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: $(params.pvcSize)
volumeMode: Filesystem
EOF
# Append pvcStorageClass if provided
if [ "$(params.pvcStorageClass)" != "" ]; then
echo " storageClassName: $(params.pvcStorageClass)" >> /tmp/pvc.yaml
fi
# Apply PVC
kubectl apply -f /tmp/pvc.yaml
# Write result
echo -n "${PVC_NAME}" > $(results.pvcName.path)
echo "PVC created: ${PVC_NAME}"
else