Kubernetes--学习笔记-3-Kubernetes Web UI部署

一、Kubernetes集群环境

请参考Kubernetes--学习笔记-安装配置和服务部署-2

https://cnodejs.org/topic/57aa945c476898b472247d90

二,创建kubernetes-dashboard.yaml

在master服务器上创建kubernetes-dashboard.yaml文件,并输入以下内容:

  1. # Copyright 2015 Google Inc. All Rights Reserved.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. # Configuration to deploy release version of the Dashboard UI.
  15. #
  16. # Example usage: kubectl create -f
  17. kind: Deployment
  18. apiVersion: extensions/v1beta1
  19. metadata:
  20. labels:
  21. app: kubernetes-dashboard
  22. version: v1. 1.0
  23. name: kubernetes-dashboard
  24. namespace: kube- system
  25. spec:
  26. replicas: 1
  27. selector:
  28. matchLabels:
  29. app: kubernetes-dashboard
  30. template:
  31. metadata:
  32. labels:
  33. app: kubernetes-dashboard
  34. spec:
  35. containers:
  36. - name: kubernetes-dashboard
  37. image: docker.io/mritd/kubernetes-dashboard-amd64
  38. imagePullPolicy: Always
  39. ports:
  40. - containerPort: 9090
  41. protocol: TCP
  42. args:
  43. # Uncomment the following line to manually specify Kubernetes API server Host
  44. # If not specified, Dashboard will attempt to auto discover the API server and connect
  45. # to it. Uncomment only if the default does not work.
  46. - --apiserver-host= 10.11. 3.56: 8080
  47. livenessProbe:
  48. httpGet:
  49. path: /
  50. port: 9090
  51. initialDelaySeconds: 30
  52. timeoutSeconds: 30
  53. ---
  54. kind: Service
  55. apiVersion: v1
  56. metadata:
  57. labels:
  58. app: kubernetes-dashboard
  59. name: kubernetes-dashboard
  60. namespace: kube-system
  61. spec:
  62. type: NodePort
  63. ports:
  64. - port: 80

修改以下几项:

 image: docker.io/mritd/kubernetes-dashboard-amd64 # 这个镜像在创建之前已docker pull 下载下来,避免网络失败
 - --apiserver-host=10.11.3.56:8080 # 这里改成master这的ip地址,不能用master服务器名称,否则会报错失败

执行以下命令创建kubernetes-dashboard

systemctl create -f kubernetes-dashboard.yaml
创建完成后,查看Pods和Service的详细信息:

  1. [root@master cloud] # kubectl get pods --all-namespaces
  2. NAMESPACE NAME READY STATUS RESTARTS AGE
  3. default nginx-pod 1/ 1 Running 0 5h
  4. kube- system kubernetes-dashboard- 350055417-wf8j1 1/ 1 Running 0 44 m
  5. [root@master cloud] #
  1. [root@master cloud] # kubectl describe pods/kubernetes-dashboard-350055417-wf8j1  --namespace="kube-system"                                    
  2. Name:           kubernetes-dashboard -350055417-wf8j1
  3. Namespace:      kube-system
  4. Node:           node -1/ 10.11 .3 .61
  5. Start Time:     Wed, 17 Jan 2018 08: 07: 38 + 0100
  6. Labels:         app=kubernetes-dashboard
  7.                 pod-template-hash= 350055417
  8. Status:         Running
  9. IP:              172.17 .0 .3
  10. Controllers:    ReplicaSet/kubernetes-dashboard -350055417
  11. Containers:
  12.   kubernetes-dashboard:
  13.     Container ID:       docker:// 4fab3e7e09bbd80546aec6f3569b3a59723ef983356e59428879fe06e3359861
  14.     Image:              docker.io/mritd/kubernetes-dashboard-amd64
  15.     Image ID:           docker-pullable://docker.io/mritd/kubernetes-dashboard-amd64@sha256: 377d905c758d08674fd434e567fbfb4411f64a52090d0de7f64fd70b72b2fbeb
  16.     Port:                9090/TCP
  17.     Args:
  18.       --apiserver-host= 10.11 .3 .56: 8080
  19.     State:                      Running
  20.       Started:                  Wed, 17 Jan 2018 08: 07: 43 + 0100
  21.     Ready:                      True
  22.     Restart Count:              0
  23.     Liveness:                   http-get http://: 9090/ delay= 30s timeout= 30s period= 10s #success=1 #failure=3
  24.     Volume Mounts:             
  25.     Environment Variables:     
  26. Conditions:
  27.   Type          Status
  28.   Initialized    True 
  29.   Ready          True 
  30.   PodScheduled  True 
  31. No volumes.
  32. QoS Class:      BestEffort
  33. Tolerations:   
  34. Events:
  35.   FirstSeen     LastSeen        Count   From                    SubObjectPath                           Type            Reason                  Message
  36.   ---------     --------        -----   ----                    -------------                           --------        ------                  -------
  37.   46m            46m              1       {default-scheduler }                                            Normal          Scheduled               Successfully assigned kubernetes-dashboard -350055417-wf8j1 to node -1
  38.   46m            46m              1       {kubelet node -1}        spec.containers{kubernetes-dashboard}   Normal          Pulling                 pulling image "docker.io/mritd/kubernetes-dashboard-amd64"
  39.   46m            46m              2       {kubelet node -1}                                                Warning         MissingClusterDNS       kubelet does not have ClusterDNS IP configured and cannot create Pod using "ClusterFirst" policy. Falling back to DNSDefault policy.
  40.   46m            46m              1       {kubelet node -1}        spec.containers{kubernetes-dashboard}   Normal          Pulled                  Successfully pulled image "docker.io/mritd/kubernetes-dashboard-amd64"
  41.   46m            46m              1       {kubelet node -1}        spec.containers{kubernetes-dashboard}   Normal          Created                 Created container with docker id 4fab3e7e09bb; Security:[seccomp=unconfined]
  42.   46m            46m              1       {kubelet node -1}        spec.containers{kubernetes-dashboard}   Normal          Started                 Started container with docker id 4fab3e7e09bb
  43. [root@master cloud]

查看service 信息:

  1. [root@master cloud] # kubectl describe service/kubernetes-dashboard --namespace="kube-system"
  2. Name:                   kubernetes-dashboard
  3. Namespace:              kube- system
  4. Labels:                 app=kubernetes-dashboard
  5. Selector:               app=kubernetes-dashboard
  6. Type:                   NodePort
  7. IP:                      10.254. 85.224
  8. Port:                    80/TCP
  9. NodePort:                30943/TCP
  10. Endpoints:              172.17. 0. 3: 9090
  11. Session Affinity:       None
  12. No events.
  13. [root@master cloud]

从kubernetes-dashboard的service详细信息可以看到,该service绑定到了Node节点的30943端口上。现在,通过浏览器访问该端口就能看到Kubernetes的Web UI:
Kubernetes--学习笔记-3-Kubernetes Web UI部署_第1张图片


参考链接:

http://blog.csdn.net/u013760355/article/details/70161982

http://blog.csdn.net/zjysource/article/details/52086835

https://blog.csdn.net/harris135/article/details/79086221

你可能感兴趣的:(kubernetes)