-
Create and delete namespace with yaml file.
Create:
kubectl apply -f namespace-test.yaml
Check:
kubectl get namespace
Delete:
kubectl delete -f namespace-test.yaml
-
Create and delete namespace with only command.
kubectl create namespace test-with-kubectl-create
kubectl delete ns test-with-kubectl-create
-
Create yaml file for namespace
team-a
andteam-b
.-
team-a
: Create manually by fillingapiVersion
,kind
, andmetadata
. -
team-b
: Create withkubectl create
command
kubectl create ns team-b --dry-run=client -o yaml > ns-team-b.yaml
-
-
Create namespaces
kubectl apply -f ns-team-a.yaml,ns-team-b.yaml
-
Check namespaces
kubectl get ns
-
Create pod in
team-a
kubectl run nginx --image=nginx -n team-a
check:
kubectl get pod
kubectl get pod -n team-a
-
Create pod with the same name in
team-a
kubectl run nginx --image=nginx -n team-a
-> Will fail with an error:
Error from server (AlreadyExists): pods "nginx" already exists
-
Create pod with the same name in
team-b
kubectl run nginx --image=nginx -n team-b
-
Check pods in all namespaces
kubectl get pod --all-namespaces
-
Delete namespace
team-a
kubectl delete ns team-a
-> the pod in namespace
team-a
is also deleted.kubectl get pod --all-namespaces
-
Delete namespace
team-b
kubectl delete ns team-b
kubectl get pod --all-namespaces
Everything is deleted.
02-namespace
Folders and files
Name | Name | Last commit date | ||
---|---|---|---|---|
parent directory.. | ||||