Kubernetes

How to create components in a namespace?

Difficulty: unrated

Source: bregman-arie/devops-exercises by Arie Bregman

Answer

One way is by specifying --namespace like this: kubectl apply -f my_component.yaml --namespace=some-namespace Another way is by specifying it in the YAML itself:

apiVersion: v1
kind: ConfigMap
metadata:
  name: some-configmap
  namespace: some-namespace

and you can verify with: kubectl get configmap -n some-namespace