Skip to main content
Version: 123.3

Remove stale resources of a cluster

Depending on how you uninstalled the PDS system, there might be stale PDS resources in the deployment target cluster. This topic provides commands to list and delete the stale resources.

Data service deployments

  • List resources:

    for CRD in $(kubectl api-resources --api-group=deployments.pds.io -o name); do
    echo "Resources $CRD:"
    kubectl get -A $CRD
    done
  • Delete resources:

    for NS in $(kubectl get ns -o jsonpath="{.items[*].metadata.name}"); do
    for NAME in $(kubectl -n $NS get database.deployments.pds.io -o name); do
    kubectl patch -n $NS $NAME --type=merge -p `{"metadata":{"finalizers":null}}`
    done
    done

    kubectl delete crd $(kubectl api-resources --api-group=deployments.pds.io -o name | tr '\n' ' ') --wait

Backups

Before you delete the backups, ensure you have a copy of data residing in backup targets associated with the backup custom resources.

  • List resources:

    kubectl get -A backups.backups.pds.io
  • Delete resources:

    for NS in $(kubectl get ns -o jsonpath="{.items[*].metadata.name}"); do
    for NAME in $(kubectl -n $NS get backups.backups.pds.io -o name); do
    kubectl patch -n $NS $NAME --type=merge -p `{"metadata":{"finalizers":null}}`
    done
    done

    kubectl delete crd backups.backups.pds.io --wait

Cluster roles and role bindings

  • List resources:

    kubectl get clusterrole -l pds/environment
    kubectl get clusterrolebinding -l pds/environment
  • Delete resources:

    kubectl delete clusterrole -l pds/environment
    kubectl delete clusterrolebinding -l pds/environment

Storage classes

  • List resources:

    kubectl get storageclass -l pds/environment
  • Delete resources:

    kubectl delete storageclass -l pds/environment 

Data volumes

  • List resources:

    kubectl get pvc -A -l pds/environment
    kubectl get pv $(kubectl get pvc -A -l pds/environment -o=jsonpath=`{.items[*].spec.volumeName}`)
  • Delete resources:

    for PV in $(kubectl get pvc -A -l pds/environment -o=jsonpath=`{.items[*].spec.volumeName}`); do
    kubectl patch pv $PV -p `{"spec":{"persistentVolumeReclaimPolicy":"Delete"}}`
    done

    kubectl delete pvc -A -l pds/environment
  • Review remaining volumes and delete unreleased volumes:

    kubectl get pv