I was wondering if anyone has any ideas on the best way to create 200 namespaces within a cluster.
Ideally a simple bash loop to create kubectl create namespaces would be good.
-
Wouldn't you want to keep track of this in a Git repo?Jonas– Jonas2021-10-19 15:13:36 +00:00Commented Oct 19, 2021 at 15:13
Add a comment
|
2 Answers
You can dynamically create a YAML file using any programming language you are most comfortable with (bash or python), consisting of a list of k8s namespaces with the following format:
$ cat namespaces-list.yaml
---
apiVersion: v1
kind: List
items:
- apiVersion: v1
kind: Namespace
metadata:
name: namespace-list1
- apiVersion: v1
kind: Namespace
metadata:
name: namespace-list2
- apiVersion: v1
kind: Namespace
metadata:
name: namespace-list3
Then execute the following command to create them all in one shot! kubectl apply -f namespaces-list.yaml
Hope this helped!