Which image of the operator are you using? 1.8.0 version
Are you running Postgres Operator in production? yes
Hello everyone!
Could you add functionality to install a cluster with existing pv (the case when someone accidentally deleted the cluster but the pv disks remained). I made a script that can generate pvc from existing pv deleted cluster, which is then successfully mounted by the operator - I checked (it is important that the namespace, cluster name and TeamID match the old values)
#!/bin/bash
VOLUME_SIZE=$2
NAMESPACE=$3
if [[ -z $3 ]];then
echo No args
echo Use command for example:
echo $0 10Gi namespace "pv_id_1 pv_id_2 pv_id_3"
exit 1
fi
EGREP_STR=$(echo $2 | tr ' ' '|')
PVC=$(kubectl get pv|egrep $EGREP_STR)
if [[ -n $PVC ]];then
while IFS= read -r line
do
PV_NAME=$(echo $line|awk '{print $1}')
PVC_NAME=$(echo $line|awk '{print $6}'|cut -d '/' -f 2)
kubectl -n $NAMESPACE patch pv --type json -p '[{"op": "remove", "path": "/spec/claimRef"}]' $PV_NAME
cat <<EOF | kubectl -n $NAMESPACE apply -f -
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: ${PVC_NAME}
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: ${VOLUME_SIZE}
volumeName: ${PV_NAME}
EOF
break
done <<< "$PVC"
else
echo "PVC var is empy"
exit 1
fi
Hello everyone! Could you add functionality to install a cluster with existing pv (the case when someone accidentally deleted the cluster but the pv disks remained). I made a script that can generate pvc from existing pv deleted cluster, which is then successfully mounted by the operator - I checked (it is important that the namespace, cluster name and TeamID match the old values)