360SDN.COM

kubernetes-1.12.1安装dashboardv1.10.1

来源:  2019-04-26 14:25:18    评论:0点击:


安装kubernetes1.12.1的web-ui附件:dashboard:v1.10.0

1.因为中国墙的问题,所以首先要准备好镜像,请使用如下脚本下载

因为你不知道pod会被调度到那个NODE上,所以你要在每个NODE上都得执行一下脚本



#!/bin/sh

#拉取镜像
docker pull registry.cn-qingdao.aliyuncs.com/wangxiaoke/kubernetes-dashboard-amd64:v1.10.0

#重新打标签
docker tag registry.cn-qingdao.aliyuncs.com/wangxiaoke/kubernetes-dashboard-amd64:v1.10.0 k8s.gcr.io/kubernetes-dashboard-amd64:v1.10.0

#删除无用镜像
docker image rm registry.cn-qingdao.aliyuncs.com/wangxiaoke/kubernetes-dashboard-amd64:v1.10.0

2.开始安装

kubectl create -f https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml

    查看dashboard的POD是否正常启动,如果正常说明安装成功

    [root@node1 ~]# kubectl get pods --namespace=kube-system
    NAME                                     READY   STATUS    RESTARTS   AGE
    coredns-576cbf47c7-kg8s9                 1/1     Running   0          29h
    coredns-576cbf47c7-st599                 1/1     Running   0          29h
    etcd-node1.ztpt.com                      1/1     Running   0          29h
    kube-apiserver-node1.ztpt.com            1/1     Running   0          29h
    kube-controller-manager-node1.ztpt.com   1/1     Running   1          29h
    kube-flannel-ds-amd64-79x9h              1/1     Running   0          27h
    kube-flannel-ds-amd64-f9fls              1/1     Running   0          26h
    kube-flannel-ds-amd64-q7kvx              1/1     Running   0          29h
    kube-proxy-242zg                         1/1     Running   0          27h
    kube-proxy-5ntm5                         1/1     Running   0          29h
    kube-proxy-6pbrv                         1/1     Running   0          26h
    kube-scheduler-node1.ztpt.com            1/1     Running   1          29h
    kubernetes-dashboard-77fd78f978-wzqjq    1/1     Running   0          5m7s

3.配置外网访问(不配置的话默认只能集群内访问)

    修改service配置,将type: ClusterIP改成NodePort

    kubectl edit service  kubernetes-dashboard --namespace=kube-system

    查看外网暴露端口(我们可以看到外网端口是32240)

    [root@node1 ~]# kubectl get service --namespace=kube-system
    NAME                   TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)         AGE
    kube-dns               ClusterIP   10.96.0.10       <none>        53/UDP,53/TCP   47h
    kubernetes-dashboard   NodePort    10.101.221.220   <none>        443:32240/TCP   17h

4.访问dashboard

    创建dashboard用户
    1.创建admin-token.yaml文件,文件内容如下:

kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
  name: admin
  annotations:
    rbac.authorization.kubernetes.io/autoupdate: "true"
roleRef:
  kind: ClusterRole
  name: cluster-admin
  apiGroup: rbac.authorization.k8s.io
subjects:
- kind: ServiceAccount
  name: admin
  namespace: kube-system
---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: admin
  namespace: kube-system
  labels:
    kubernetes.io/cluster-service: "true"
    addonmanager.kubernetes.io/mode: Reconcile

2.创建用户

[root@node1 ~]# kubectl create -f admin-token.yaml

    获取登陆token

    [root@node1 ~]# kubectl describe secret/$(kubectl get secret -nkube-system |grep admin|awk '{print $1}') -nkube-system

    kubernetes-1.12.1安装dashboardv1.10.1
    通过浏览器登陆dashboard(我用的火狐浏览器)

        注意,因为证书的问题,浏览器可能会阻止连接,必须把访问地址加入到访问例外里面

1.打开浏览器输入访问地址

访问地址:https://192.168.2.170:32240   格式:https://节点IP:bashboard暴露端口

2.认证方式选择口令,输入刚才获取到的token,即可登陆成功。
kubernetes-1.12.1安装dashboardv1.10.1
3.进入后就会看到如下界面
kubernetes-1.12.1安装dashboardv1.10.1
为您推荐

友情链接 |九搜汽车网 |手机ok生活信息网|ok生活信息网|ok微生活
 Powered by www.360SDN.COM   京ICP备11022651号-4 © 2012-2016 版权