I'm working on a project where I use the command `kubectl delete -k ~/.local/share/tutor/env --ignore-not-found=true --wait` to clean up resources. However, some users have raised concerns that this command also removes their externally managed namespaces. I'm looking for a way to modify this command so that if users provide a specific argument, it will skip deleting the namespace. Any ideas?
3 Answers
So, you mentioned that path contains your docker-compose files, kustomization file, caddy configs, and all your Kubernetes YAML files. Understanding your setup is crucial for providing the best solution.
To start, it's important to understand what your command is doing. It appears you are deleting everything specified in your kustomization.yaml file. A good workaround could be to write a script that comments out the namespace entry in your kustomization.yaml before executing the delete command. Alternatively, you could manually remove the resources you actually want to delete instead.
Can you clarify what your cleanup command entails? What exactly does the path include? It would help to know your cleanup criteria better.

Yes, you would just need to comment out the namespace line in your resources section. The `delete -k` command won’t touch the namespace defined at the bottom. If you can't comment it out for some reason, manually deleting the resources (using a command like `kubectl delete all,configmap,secret,pvc,ingress,job -n openedx -l 'app.kubernetes.io/managed-by=tutor' --ignore-not-found=true --wait`) should work similarly.