#default namespace
kubectl get ns
NAME STATUS AGE
default Active 4d7h
kube-node-lease Active 4d7h
kube-public Active 4d7h
kube-system Active 4d7h
kubernetes-dashboard Active 4d7h
#to create a namespace
kubectl create ns mynamespace
namespace/mynamespace created
kubectl get ns
NAME STATUS AGE
default Active 4d7h
kube-node-lease Active 4d7h
kube-public Active 4d7h
kube-system Active 4d7h
kubernetes-dashboard Active 4d7h
mynamespace Active 7s
#create a pod with mynamespace
kubectl run nginx --image=nginx --namespace mynamespace
pod/nginx created
kubectl get pods --namespace mynamespace
NAME READY STATUS RESTARTS AGE
nginx 1/1 Running 0 13s
#add 2nd pod with mynamespace
kubectl run nginx2 --image=nginx --namespace mynamespace
pod/nginx2 created
kubectl get pods --namespace mynamespace
NAME READY STATUS RESTARTS AGE
nginx 1/1 Running 0 76s
nginx2 1/1 Running 0 17s
#delete mynamespace
kubectl delete ns mynamespace
namespace "mynamespace" deleted
#all resources listed are deleted from the mynamespace
kubectl delete ns mynamespace
Error from server (NotFound): namespaces "mynamespace" not found
No comments:
Post a Comment