其他分享
首页 > 其他分享> > Kubernetes创建namespaces

Kubernetes创建namespaces

作者:互联网

两种创建方式

第一种使用命令行创建:

1 查看现有命名空间
[root@master1 prometheus]# kubectl get ns
NAME                   STATUS   AGE
default                Active   29d
dev                    Active   9d
kube-node-lease        Active   29d
kube-public            Active   29d
kube-system            Active   29d
kubernetes-dashboard   Active   9d
2 使用命令行创建
[root@master1 prometheus]# kubectl create namespace test
namespace/test created
3 查看创建结果
[root@master1 prometheus]# kubectl get ns
NAME                   STATUS   AGE
default                Active   29d
dev                    Active   9d
kube-node-lease        Active   29d
kube-public            Active   29d
kube-system            Active   29d
kubernetes-dashboard   Active   9d
test                   Active   25s

第二种使用yaml文件创建

vim test1_ns.yaml
apiVersion: v1
kind: Namespace
metadata:
    name: test1
[root@master1 prometheus]# kubectl apply -f test1_ns.yaml 
namespace/test1 created
[root@master1 prometheus]# kubectl get ns
NAME                   STATUS   AGE
default                Active   29d
dev                    Active   9d
kube-node-lease        Active   29d
kube-public            Active   29d
kube-system            Active   29d
kubernetes-dashboard   Active   9d
test                   Active   3m53s
test1                  Active   8s
[root@master1 prometheus]# 

 

删除命名空间

[root@master1 prometheus]# kubectl delete ns test1
namespace "test1" deleted

 

标签:test1,master1,Kubernetes,创建,29d,prometheus,namespaces,Active,kube
来源: https://www.cnblogs.com/shuiyuesheng/p/16170401.html