Skip to content

Instantly share code, notes, and snippets.

@seitosan
Created January 22, 2021 16:15
Show Gist options
  • Save seitosan/b051470c852b9938fa65d34d569ea0bf to your computer and use it in GitHub Desktop.
Save seitosan/b051470c852b9938fa65d34d569ea0bf to your computer and use it in GitHub Desktop.
Remove all ressources on a namespace
param (
[string] $namespace="default",
[bool] $delete=0
)
$types=kubectl.exe api-resources --verbs=list --namespaced -o name
echo $namespace
foreach($type in $types)
{
echo $type; echo "###";
kubectl.exe get $type -n $namespace ;
if ($delete )
{
echo "will destroy all $type on $namespace"
kubectl.exe delete $type --all
}
echo "###";
}
@seitosan
Copy link
Author

This script allows you to delete all the resources present in a namespace given as a parameter.

It is possible to put it only in observation with the boolean delete left in default parameter (namely false)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment