Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I create a namespace with kustomize?

Tags:

kustomize

I've a simple project that use kustomize like this:

base/
  namespace.yaml
  kustomization.yaml
  service.yaml

With kustomization.yaml is:

resources:
  - namespace.yaml
  - service.yaml
namespace: my_wanted_namespace

And namespace.yaml is:

apiVersion: v1
kind: Namespace
metadata:
  name: default

The problem is that when I do: kustomize build ./base

I've this:

apiVersion: v1
kind: Namespace
metadata:
  name: default

How can I have

apiVersion: v1
kind: Namespace
metadata:
  name: my_wanted_namespace

Thanks.

like image 827
Djabx Avatar asked Aug 21 '19 14:08

Djabx


1 Answers

If you want to create your namespace with kustomize, your kustomize file should look like this. It has to use the namespace.

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: my-wanted-namespace
resources:
- ./namespace.yml

And your namespace file should be a normal namespace deployment like this:

apiVersion: v1
kind: Namespace
metadata:
  name: my-wanted-namespace
like image 126
azak Avatar answered Oct 21 '22 08:10

azak