Cloud Infrastructure Community's Space

Set default kubernetes namespace

Namespace in Kubernetes

By default, resources are created in Kubernetes with kubectl in default namespaces, we can specify the namespace when creating resources by –namespace /-n flag

kubectl get pods --namespace default 

We can also specify a default namespace which will be used for all incoming kubectl commands. with

kubectl config set-context --current --namespace=<your namespace here>

Create a kubenetes namespace

We can create a Kubernetes namespace in different ways.

Using kubectl command:

kubectl create namespace <namespace name>

Or yaml file

# custom-namespace.yaml
apiVersion: v1
kind: Namespace
  name: <insert-namespace-name-here>

then run the create command

kubectl create -f ./custom-namespace.yaml

Press ESC to close