#!/usr/bin/env bash

export NFS_SER=192.168.81.119
export NFS_DIR="/data/gitee"
export NAME=$1
export SIZE=${2:-10}
export CLASS_NAME="''"

if [ -z $NAME ]
then
	echo "Usage: $(basename $0 .sh) NAME SIZE"
	exit 67
fi


cat> ./output/${NAME}.yaml <<EOF
apiVersion: v1
kind: PersistentVolume
metadata:
  name: $NAME-pv
spec:
  storageClassName: ${CLASS_NAME}
  capacity:
    storage: ${SIZE}Gi
  accessModes:
    - ReadWriteMany
  persistentVolumeReclaimPolicy: Retain
  nfs:
    server: $NFS_SER
    path: "$NFS_DIR"

---

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: $NAME-pvc
spec:
  storageClassName: ${CLASS_NAME}
  accessModes:
    - ReadWriteMany
  volumeMode: Filesystem
  volumeName: $NAME-pv
  resources:
    requests:
      storage: ${SIZE}Gi
EOF

