美文网首页K8S
K8S部署Dashboard和Heapster

K8S部署Dashboard和Heapster

作者: 张氏小毛驴 | 来源:发表于2022-04-27 14:49 被阅读0次

    K8S部署Dashboard和Heapster


    0.前言

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

    系统为CentOS7

    总共有三台机器:

    Name IP Role
    ceph1 172.16.32.70 Master
    ceph2 172.16.32.107 Node
    ceph3 172.16.32.71 Node

    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
      
    • 创建用户(涉及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
      
    • 执行

      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

    相关文章

      网友评论

        本文标题:K8S部署Dashboard和Heapster

        本文链接:https://www.haomeiwen.com/subject/txcipftx.html