Skip to Content
Skip Breadcrumb

You will find here some all day work tips for OpenShift Cluster this tips works also for the origin version.

get nodeport

oc get svc <your-service> -o jsonpath='{.spec.ports[?(@)].nodePort}'

get all released pv

oc get pv \
--template='{{range .items}}{{if eq .status.phase "Released" }}{{.metadata.name}}{{"\n"}}{{end}}{{end}}' \
--all-namespaces

The output.

pv020-volume
pv021-volume
pv022-volume
pv023-volume
pv025-volume
pv027-volume
pv034-volume
pv037-volume
pv038-volume
pv039-volume
pv042-volume
pv043-volume

Cleanup Released pvs

⚠ | You need jq to execute the following snipplet

for i in $(oc get pv --template='{{range .items}}{{if eq .status.phase "Released" }}{{.metadata.name}}{{"\n"}}{{end}}{{end}}' --all-namespaces ); 
do
  oc export pv $i -o json | jq 'del(.spec.claimRef)' > ${i}_no-claimRef.json
  oc delete pv $i && oc create -f ${i}_no-claimRef.json
  echo "rm -rf /mnt/$( echo $i|cut -d'-' -f1)/[a-z]*"
done

You can contact me for any further questions and orders