Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating Multiple Namespaces from the Kubernetes Command Line Interface

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?

like image 871
P Ekambaram Avatar asked Oct 23 '25 04:10

P Ekambaram


2 Answers

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
like image 59
Markus Dresch Avatar answered Oct 25 '25 22:10

Markus Dresch


You could chain together 2 kubectl commands like so:

kubectl create ns app1 && kubectl create ns app2...
like image 45
Paul Back Avatar answered Oct 25 '25 22:10

Paul Back



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!