命名空间(Namespace)
1.什么是命名空间
你可以认为namespaces是你kubernetes集群中的虚拟化集群。在一个Kubernetes集群中可以拥有多个命名空间,它们在逻辑上彼此隔离。 他们可以为您和您的团队提供组织,安全甚至性能方面的帮助!
2.怎么创建命名空间
1.kubectl create namespace test
2.使用yaml文件
#test.yaml:kind: NamespaceapiVersion: v1metadata:name: testlabels:name: test
3.往命名空间中添加资源
1.kubectl apply -f pod.yaml —namespace=test
2.使用yaml文件
apiVersion: v1kind: Podmetadata:name: mypodnamespace: testlabels:name: mypodspec:containers:- name: mypodimage: nginx
4.切换命名空间
kubens test
