I want to create multiple namespaces from the Kubernetes CLI (kubectl) without any YAML manifests:
kubectl create namespace app1,app2,app3
Can this be done?
kubectl expects exactly one namespace:
➜ / kubectl create ns
error: exactly one NAME is required, got 0
depending on your shell you could pack it into a loop. here's an example for bash and zsh:
➜ / foreach ns (ns1 ns2 ns3); kubectl create ns $ns; end
You could chain together 2 kubectl commands like so:
kubectl create ns app1 && kubectl create ns app2...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With