kubernetes-dashboard-namespace搭建六
dashboard的安装和部署
wget https://www.qstack.com.cn/dashboard.zip
unzip dashboard.zip
[root@k8s-master dashboard]# docker load -i kubernetes-dashboard-amd64_v1.4.1.tar.gz
[root@k8s-master dashboard]# docker tag index.tenxcloud.com/google_containers/kubernetes-dashboard-amd64:v1.4.1 192.168.23.146:5000/index.tenxcloud.com/google_containers/kubernetes-dashboard-amd64:v1.4.1
[root@k8s-master dashboard]# docker push 192.168.23.146:5000/index.tenxcloud.com/google_containers/kubernetes-dashboard-amd64:v1.4.1
更改配置文件:dashboard-deploy.yaml
[root@k8s-master dashboard]# cat dashboard-svc.yaml apiVersion: v1 kind: Service metadata: name: kubernetes-dashboard namespace: kube-system labels: k8s-app: kubernetes-dashboard kubernetes.io/cluster-service: "true" spec: selector: k8s-app: kubernetes-dashboard ports: - port: 80 #vip的端口 targetPort: 9090 #容器的端口
[root@k8s-master dashboard]# kubectl create -f dashboard-deploy.yaml
[root@k8s-master dashboard]# kubectl create -f dashboard-svc.yaml
[root@k8s-master dashboard]# kubectl get all -o wide --namespace=kube-system #由于dashboard-deploy和svc都是在kube-system的namespace下创建的,所以查询的时候要加--namespace=kube-system,否则不加查的都是命名空间为default下的资源
访问方式:192.168.23.146:8080 #先看下api-server的
192.168.23.146:8080/ui/
[root@k8s-master dashboard]# curl 192.168.23.146:8080/api { "kind": "APIVersions", "versions": [ "v1" ], "serverAddressByClientCIDRs": [ { "clientCIDR": "0.0.0.0/0", "serverAddress": "192.168.23.146:6443" } ] }[root@k8s-master dashboard]#
root@k8s-master dashboard]# curl 192.168.23.146:8080/api/v1 | more -10 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 3711 0 3711 0 0 98696 0 --:--:-- --:--:-- --:--:-- 100k { "kind": "APIResourceList", "groupVersion": "v1", "resources": [ { "name": "bindings", "namespaced": true, "kind": "Binding" }, { "name": "componentstatuses", "namespaced": false, "kind": "ComponentStatus" }, { "name": "configmaps", "namespaced": true,
[root@k8s-master dashboard]# curl 192.168.23.146:8080/api/v1/pods
[root@k8s-master dashboard]# curl 192.168.23.146:8080/api/v1/services
namespace的作用:
例如在华为云和阿里云你买了一个账号,账号之间资源就是彼此隔离的,只能看到自己租户下的资源
Namespace(命名空间)是Kubernetes系统中的另一个非常重要的概念,Namespace在很多情况下用于实现多租户的资源隔离
创建namespace
[root@k8s-master ~]#kubectl create namespace namespace的名字
namespace "*" created
查看namespace
[root@k8s-master ~]#kubectl get namespace
NAME STATUS AGE
default Active 8d
kube-system Active 8d
删除namespace
[root@k8s-master ~]#kubectl delete namespace namespace的名字
namespace "*" deleted
注:特别危险!会删除namespace下所有的k8s资源
kubectl get all --all-namespaces #查看所有namespace下的所有资源
[root@k8s-master namespace]# vi nginx-rc.yaml apiVersion: v1 kind: ReplicationController metadata: name: myweb namespace: qiangge spec: replicas: 2 …… [root@k8s-master namespace]# vi nginx-svc.yaml apiVersion: v1 kind: Service metadata: name: test namespace: qiangge spec: type: NodePort