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