Search code examples
dockerkuberneteskubectl

Create a kubernetes namespace using config instead of API


The only way to create a new namespace according to documentation here is to make an API request

curl -v -X POST -d'{"apiVersion":"v1","kind":"Namespace","metadata":{"name":"kube-system"}}' -H "Content-Type: application/json" "http://127.0.0.1:8080/api/v1/namespaces"

Is there any way to do the same using config or cloud-config?


Solution

  • As Timo mentioned, you can use kubectl create namespace NAME to create a namespace using the command line client. You can also put the following into a yaml file and use kubectl create -f namespace.yaml to create a namespace:

    apiVersion: v1
    kind: Namespace
    metadata:
      name: kube-system