<p>I am playing with Kubernetes <em>really</em> for the first time, and have a brand new (empty) GKE cluster up on GCP.</p>
<p>I am going to play around with YAML Kustomize files and try to get a few services deployed there, but what I'm really looking for is a command (or set of <code>kubectl</code>/<code>gcloud</code> commands) to restore the GKE cluster to a totally &quot;new&quot; slate. This is because it's probably going to take several dozen (or more!) attempts at configuring and tweaking my YAML files until I get the configs and behavior down just right, and each time I mess up I want to start over with a completely &quot;clean&quot;/new GKE cluster. For reasons outside the scope of this question, deleting and recreating the GKE cluster really isn't a viable option.</p>
<p>My Kustomize files and deploment scripts will create Kubernetes operators, namespaces, persistent volumes (and claims), various services and all sorts of other resources. But I need to be able to drop/delete them all and bring the cluster back to the brand new state.</p>
<p>Is this possible, and if so, whats the process/command(s) involved? FWIW I have cluster admin permissions.</p>

hotmeatballsoup
<p>As mentioned by @dany L, Kubernetes Namespace will be the perfect option for deleting the resources. Create a custom namespace by using the command</p>
<pre><code>Kubectl create namespace custom-name 
</code></pre>
<p>and deploy all the resources(Deployment,ReplicaSet,Services etc.,) into the namespace.</p>
<p>To work with Namespace, you need to add <strong>--namespace flag</strong> to k8s commands.</p>
<p>For example:</p>
<pre><code>kubectl create -f deployment.yaml --namespace=custom-namespace
</code></pre>
<p>If you want to delete all of these resources, you just need to delete the custom namespace. By deleting the custom namespace, all the other resources would be deleted. Without it, ReplicaSet might create new pods when existing pods are deleted. Run the following command for deleting the namespace.</p>
<pre><code>kubectl delete namespace custom-name
</code></pre>
<p>To list down all the resources associated to a specific namespace, you can run the following command</p>
<pre><code>kubectl api-resources --verbs=list --namespaced -o name  | xargs -n 1 kubectl get --show-kind --ignore-not-found -n &lt;namespace&gt;
</code></pre>
<p>The kubectl api-resources enumerates the resource types available in your cluster. So we can use it by combining it with <strong>kubectl get</strong> to list every instance of every resource type in a Kubernetes namespace.</p>
<p>Refer to this <a href="https://www.studytonight.com/post/how-to-list-all-resources-in-a-kubernetes-namespace" rel="nofollow noreferrer">link</a> to list all the resources in a namespace.</p>
