• K8S部署Dashboard和Heapster


    K8S部署Dashboard和Heapster


    0.前言

    文章使用的k8s版本为1.10.0,dashboard版本为v1.8.3

    系统为CentOS7

    总共有三台机器:

    NameIPRole
    ceph1172.16.32.70Master
    ceph2172.16.32.107Node
    ceph3172.16.32.71Node

    1.安装
    • 下载官方dashboard的yaml文件

      wget https://raw.githubusercontent.com/kubernetes/dashboard/v1.8.3/src/deploy/recommended/kubernetes-dashboard.yaml

    • 修改镜像地址

      修改yaml文件,将image: k8s.gcr.io/kubernetes-dashboard-amd64:v1.8.3修改为image: registry.cn-hangzhou.aliyuncs.com/zhanye-zhang/kubernetes-dashboard-amd64:v1.8.3

    • 暴露端口,以使用NodeIP访问

      在Service部分修改,添加type: NoedPort和nodePort: 300001,修改后Service部分如下:

      kind: Service
      apiVersion: v1
      metadata:
        labels:
          k8s-app: kubernetes-dashboard
        name: kubernetes-dashboard
        namespace: kube-system
      spec:
        type: NodePort
        ports:
          - port: 443
            targetPort: 8443
            nodePort: 30001
        selector:
          k8s-app: kubernetes-dashboard
      
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7
      • 8
      • 9
      • 10
      • 11
      • 12
      • 13
      • 14
      • 15
    • 创建用户(涉及kubernetes的RBAC Authorization,暂未学习)

      创建一个admin 用户,并与cluster-admin绑定,新建一个yaml文件用来创建一个admin用户并赋予管理权限。

      apiVersion: v1
      kind: ServiceAccount
      metadata:
        name: admin-user
        namespace: kube-system
      ---
      apiVersion: rbac.authorization.k8s.io/v1beta1
      kind: ClusterRoleBinding
      metadata:
        name: admin-user
        annotations:
          rbac.authorization.kubernetes.io/autoupdate: "true"
      roleRef:
        apiGroup: rbac.authorization.k8s.io
        kind: ClusterRole
        name: cluster-admin
      subjects:
      - kind: ServiceAccount
        name: admin-user
        namespace: kube-system
      
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7
      • 8
      • 9
      • 10
      • 11
      • 12
      • 13
      • 14
      • 15
      • 16
      • 17
      • 18
      • 19
      • 20
    • 执行

      kubectl create -f .

    2.访问Dashboard

    在安装好Dashboard后(可以使用kubectl get pods -n kube-system |grep dashboard查看是否Running),可以使用https://NodeIp:3000,在这里为:https://172.16.32.70:300001进行访问。

    正常情况下会出现以下页面:

    在这里插入图片描述

    选择令牌(也就是token),输入token。

    获取token的方式:kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep admin | awk '{print $1}')

    成功登入后,会是以下的页面:

    在这里插入图片描述

    3.安装heapster

    heapster是kubernetes的集群监控方案的一种,它通过从节点上的kubelet获取监控数据,在dashboard上显示各个组件的资源消耗情况。

    • 下载官方yaml文件

      git clone https://github.com/kubernetes/heapster.git

      四个yaml文件分别在:

      heapster/deploy/kube-config/rbac/heapster-rbac.yaml

      heapster/deploy/kube-config/influxdb/grafana.yaml

      heapster/deploy/kube-config/influxdb/heapster.yaml

      heapster/deploy/kube-config/influxdb/influxdb.yaml

    • 修改grafana.yaml

      在service中添加type: NodePort 和nodePort: 30004

      修改镜像为:registry.cn-hangzhou.aliyuncs.com/zhanye-zhangf/heapster-grafana-amd64:v4.4.3

    • 修改heapster.yaml

      修改镜像为:registry.cn-hangzhou.aliyuncs.com/zhanye-zhang/heapster-amd64:v1.5.3

    • 修改influxdb.yaml

      修改镜像为:registry.cn-hangzhou.aliyuncs.com/zhanye-zhang/heapster-influxdb-amd64:v1.3.3

    执行安装:

    kubectl create -f heapster/deploy/kube-config/rbac/heapster-rbac.yaml

    kubectl create -f heapster/deploy/kube-config/influxdb/

    如果安装成功,将可以在dashboard上看到以下界面:

    在这里插入图片描述

    也可以通过访问http://172.16.32.70:30004(这里是http)直接访问heapster的UI,如下:

    在这里插入图片描述

    也可以通过命令行查看kubectl top podkubectl top node

  • 相关阅读:
    MySql数据库实现注册登录及个人信息查询的数据库设计
    软考高项-项目资源管理的相关概念
    玩转KubeEdge
    《中华人民共和国消防法》(2021年修订版)解读
    hadoop
    2022-34~35周(8.15-8.28) 项目问题整理
    Redis笔记
    Linux网络编程(高并发服务器)
    windows计划任务的配置文件
    PID算法及其实现
  • 原文地址:https://blog.csdn.net/chisuisi5702/article/details/126282516