create namespace in kubernetes code example

Example 1: k8s create namespace

# cli
kubectl create ns test-namespace

# or in yaml
---
apiVersion: v1
kind: Namespace
metadata:
  name: test-namespace

Example 2: kubectl create namespace

# Create Namespace in current cluster
kubectl create namespace my-namespace

Example 3: kubernetes get namespace

# Get Namespaces for current cluster
kubectl get namespaces

Example 4: kubernetes java client create namespace

V1Namespace ns = new V1Namespace().metadata(new V1ObjectMeta().name("new-namespace"));
CoreV1Api api = new CoreV1Api();
V1Namespace createdNamespace = api.createNamespace(ns, null, null, null);