Remove–PersistentVolumeClaim - anongitmous/k8sShell GitHub Wiki
Remove the Kubernetes persistent volume claim resource(s).
Syntax
Remove-PersistentVolumeClaim
[-PersistentVolumeClaims] <Mtf.Kubernetes.Models.V1K8sPersistentVolumeClaim[]>
[<K8sShellRemoveParameters>]
[<K8sShellCommonCore>]
[<CommonParameters>]
Description
Removes persistent volume claim resource objects from the cluster.
See the example output.
Examples
ℹ️ See A Note about the Examples
1. Delete all persistent volume claims from the currently-active cluster
Get-PersistentVolumeClaims | Remove-PersistentVolumeClaim
- The results from Get–PersistentVolumeClaims are piped into Remove-PersistentVolumeClaim
- If there is no currently active namespace (i.e. namespace is
$nullor an empty string''), then this would delete all persistent volume claims from all namespaces.- Using aliasing, the above can be shortened to
ksgpvc | ksrpvc
2. Delete the persistent volume claim named 'my_pv_claim'
Get-PersistentVolumeClaims | Where-Object {$_.Name -match 'my_pv_claim'} | Remove-PersistentVolumeClaim
- To do a trial run, utilize the
-DryRun Alloption:
Get-PersistentVolumeClaims | Where-Object {$_.Name -match 'my_pv_claim'} | Remove-PersistentVolumeClaim -DryRun All- Using aliasing, the previous can be shortened to
ksgpvc | ? {$_.Name -match 'my_pv_claim'} | ksrpvc -DryRun All
3. Delete all persistent volume claims that are not bound
Get-PersistentVolumeClaims | Where-Object {$_.Status -notmatch 'bound'} | Remove-PersistentVolumeClaim
- To do a trial run, utilize the
-DryRun Alloption:
Get-PersistentVolumeClaims | Where-Object {$_.Status -notmatch 'bound'} | Remove-PersistentVolumeClaim -DryRun All- Using aliasing, the previous can be shortened to
ksgpvc | ? {$_.Status -notmatch 'bound'} | ksrpvc -DryRun All
Parameters
-PersistentVolumeClaims
- Specifies the persistent volume claim(s) to delete.
| Type: | Mtf.Kubernetes.Models.V1K8sPersistentVolumeClaim[] |
| Aliases: | |
| Position: | 0 |
| Default value: | None |
| Accept pipeline input: | True |
| Accept wildcard characters: | False |
See Remove Parameters
See Common Parameters/Non-namespaced Core Context
Inputs
- Mtf.Kubernetes.Models.V1K8sPersistentVolumeClaim
You can pipe persistent volume claim object(s) to this cmdlet.
Outputs
Mtf.Kubernetes.K8sWrapperCommon.K8sObjectDeleterResponse<k8s.Models.V1PersistentVolumeClaim>
Example
(the DryRun parameter was used here)
Notes
K8sShell includes the following alias for Remove-PersistentVolumeClaim:
- ksrpvc