[root@master1 ~]# kubectl get nodes
NAME STATUS ROLES AGE VERSION
master1 Ready master 133m v1.19.0
worker1 Ready <none> 81m v1.19.0
worker2 Ready <none> 79m v1.19.0
[root@master1 ~]# kubectl get namespace
NAME STATUS AGE
default Active 4h9m
kube-node-lease Active 4h9m
kube-public Active 4h9m
kube-system Active 4h9m
You have new mail in /var/spool/mail/root
[root@master1 ~]# kubectl create namespace test1
namespace/test1 created
[root@master1 ~]# kubectl get namespace
NAME STATUS AGE
default Active 4h13m
kube-node-lease Active 4h13m
kube-public Active 4h13m
kube-system Active 4h13m
test1 Active 22s
[root@master1 ~]# kubectl get ns
NAME STATUS AGE
default Active 4h13m
kube-node-lease Active 4h13m
kube-public Active 4h13m
kube-system Active 4h13m
test1 Active 46s
[root@master1 ~]# mkdir yamldir
[root@master1 ~]# cd yamldir/
[root@master1 yamldir]# vim 01_create_ns.yaml
[root@master1 yamldir]# cat 01_create_ns.yaml
apiVersion: v1
kind: Namespace
metadata:
name: test2
[root@master1 yamldir]# kubectl apply -f 01_create_ns.yaml
namespace/test2 created
[root@master1 yamldir]# kubectl get ns
NAME STATUS AGE
default Active 4h24m
kube-node-lease Active 4h24m
kube-public Active 4h24m
kube-system Active 4h24m
test1 Active 11m
test2 Active 29s
[root@master1 yamldir]# kubectl get ns
NAME STATUS AGE
default Active 4h27m
kube-node-lease Active 4h27m
kube-public Active 4h27m
kube-system Active 4h27m
test1 Active 14m
test2 Active 3m
[root@master1 yamldir]# kubectl delete namespace test1
namespace "test1" deleted
[root@master1 yamldir]# kubectl get ns
NAME STATUS AGE
default Active 4h28m
kube-node-lease Active 4h28m
kube-public Active 4h28m
kube-system Active 4h28m
test2 Active 3m56s
[root@master1 yamldir]# kubectl get ns
NAME STATUS AGE
default Active 4h28m
kube-node-lease Active 4h28m
kube-public Active 4h28m
kube-system Active 4h28m
test2 Active 4m17s
[root@master1 yamldir]# kubectl delete -f 01_create_ns.yaml
namespace "test2" deleted
[root@master1 yamldir]#
2020-09-10-k8s-namespace
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。