<转>Kubernetes Web UI搭建

来源:互联网 发布:大数据与企业管理 编辑:程序博客网 时间:2024/05/03 10:33

Kubernetes Web UI搭建

这节我以搭建Kubernetes Web UI(kubernetes-dashboard)来简要演示如何使用Docker私有库。

由于我的Kubernetes集群无法直接从gcr.io拉取kubernetes-dashboard的镜像,我事先下载了镜像文件并使用docker load命令加载镜像:

# docker load < kubernetes-dashboard-amd64_v1.1.0.tar.gz# docker imagesREPOSITORY                                        TAG                 IMAGE ID            CREATED             SIZEregistry                                          2                   c6c14b3960bd        3 days ago          33.28 MBubuntu                                            latest              42118e3df429        9 days ago          124.8 MBhello-world                                       latest              c54a2cc56cbb        4 weeks ago         1.848 kB172.28.80.11:5000/kubernetes-dashboard-amd64      v1.1.0              20b7531358be        5 weeks ago         58.52 MBregistry                                          2                   8ff6a4aae657        7 weeks ago         171.5 MB


我为加载的kubernetes-dashboard镜像打上私有库的标签并推送到私有库:

# docker tag 20b7531358be 192.168.169.125:5000/kubernetes-dashboard-amd64# docker push 192.168.169.125:5000/kubernetes-dashboard-amd64


从Kubernetes官网获取了kubernetes-dashboard的配置文件https://rawgit.com/kubernetes/dashboard/master/src/deploy/kubernetes-dashboard.yaml,对其进行编辑如下:

[plain] view plain copy
 在CODE上查看代码片派生到我的代码片
  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.   
  15. # Configuration to deploy release version of the Dashboard UI.  
  16. #  
  17. # Example usage: kubectl create -f <this_file>  
  18.   
  19. kind: Deployment  
  20. apiVersion: extensions/v1beta1  
  21. metadata:  
  22.   labels:  
  23.     app: kubernetes-dashboard  
  24.     version: v1.1.0  
  25.   name: kubernetes-dashboard  
  26.   namespace: kube-system  
  27. spec:  
  28.   replicas: 1  
  29.   selector:  
  30.     matchLabels:  
  31.       app: kubernetes-dashboard  
  32.   template:  
  33.     metadata:  
  34.       labels:  
  35.         app: kubernetes-dashboard  
  36.     spec:  
  37.       containers:  
  38.       - name: kubernetes-dashboard  
  39.         image: 192.168.169.125:5000/kubernetes-dashboard-amd64  
  40.         imagePullPolicy: Always  
  41.         ports:  
  42.         - containerPort: 9090  
  43.           protocol: TCP  
  44.         args:  
  45.           # Uncomment the following line to manually specify Kubernetes API server Host  
  46.           # If not specified, Dashboard will attempt to auto discover the API server and connect  
  47.           # to it. Uncomment only if the default does not work.  
  48.           - --apiserver-host=192.168.169.120:8080  
  49.         livenessProbe:  
  50.           httpGet:  
  51.             path: /  
  52.             port: 9090  
  53.           initialDelaySeconds: 30  
  54.           timeoutSeconds: 30  
  55. ---  
  56. kind: Service  
  57. apiVersion: v1  
  58. metadata:  
  59.   labels:  
  60.     app: kubernetes-dashboard  
  61.   name: kubernetes-dashboard  
  62.   namespace: kube-system  
  63. spec:  
  64.   type: NodePort  
  65.   ports:  
  66.   - port: 80  
  67.     targetPort: 9090  
  68.   selector:  
  69.     app: kubernetes-dashboard  

尤其要注意:1 创建的Pods所要拉取的镜像是Docker私有库的192.168.169.125:5000/kubernetes-dashboard-adm64; 2 apiserver-host参数是192.168.169.120:8080,即Kubernetes Master节点的aipserver服务地址。

修改完kubernetes-dashboard.yaml后保存到Kubernetes Master节点192.168.169.120节点上,在该节点上用kubectl create命令创建kubernetes-dashboard:

# kubectl create -f kubernetes-dashboard.yaml 


创建完成后,查看Pods和Service的详细信息:

# kubectl get pods --all-namespacesNAMESPACE     NAME                                    READY     STATUS    RESTARTS   AGEdefault       nginx                                   1/1       Running   0          3hkube-system   kubernetes-dashboard-4164430742-lqhcg   1/1       Running   0          2h


# kubectl describe pods/kubernetes-dashboard-4164430742-lqhcg --namespace="kube-system"Name:        kubernetes-dashboard-4164430742-lqhcgNamespace:    kube-systemNode:        192.168.169.124/192.168.169.124Start Time:    Mon, 01 Aug 2016 16:12:02 +0800Labels:        app=kubernetes-dashboard,pod-template-hash=4164430742Status:        RunningIP:        172.17.17.3Controllers:    ReplicaSet/kubernetes-dashboard-4164430742Containers:  kubernetes-dashboard:    Container ID:    docker://40ab377c5b8a333487f251547e5de51af63570c31f9ba05fe3030a02cbb3660c    Image:        192.168.169.125:5000/kubernetes-dashboard-amd64    Image ID:        docker://sha256:20b7531358be693a34eafdedee2954f381a95db469457667afd4ceeb7146cd1f    Port:        9090/TCP    Args:      --apiserver-host=192.168.169.120:8080    QoS Tier:      cpu:        BestEffort      memory:        BestEffort    State:        Running      Started:        Mon, 01 Aug 2016 16:12:03 +0800    Ready:        True    Restart Count:    0    Liveness:        http-get http://:9090/ delay=30s timeout=30s period=10s #success=1 #failure=3    Environment Variables:Conditions:  Type        Status  Ready     True No volumes.No events.


# kubectl describe service/kubernetes-dashboard --namespace="kube-system"Name:            kubernetes-dashboardNamespace:        kube-systemLabels:            app=kubernetes-dashboardSelector:        app=kubernetes-dashboardType:            NodePortIP:            10.254.213.209Port:            <unset>    80/TCPNodePort:        <unset>    31482/TCPEndpoints:        172.17.17.3:9090Session Affinity:    NoneNo events.


从kubernetes-dashboard的service详细信息可以看到,该service绑定到了Node节点的31482端口上。现在,通过浏览器访问该端口就能看到Kubernetes的Web UI:

0 0
原创粉丝点击