How can I prevent namespace deletion with a kubectl command?

0
8
Asked By TechWizard42 On

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

Answered By ScriptingPro On

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.

Answered By CodeMaster99 On

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.

DevGuru88 -

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.

Answered By K8sNinja On

Can you clarify what your cleanup command entails? What exactly does the path include? It would help to know your cleanup criteria better.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.