温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Kubernetes 1.8.4中如何安装Heapster

发布时间:2021-11-12 11:33:39 来源:亿速云 阅读:201 作者:小新 栏目:云计算

这篇文章给大家分享的是有关Kubernetes 1.8.4中如何安装Heapster的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。

Heapster

      Heapster 是 Kubernetes 社区维护的容器集群监控分析工具。Heapster 会从 Kubernetes apiserver 获得所有 Node 信息,然后再通过这些 Node 来获得 kubelet 上的数据,最后再将所有收集到数据送到 Heapster 的后台储存 InfluxDB,最后利用 Grafana 来抓取 InfluxDB 的数据源来进行可视化。

  • 在master通过 kubectl 来创建 kubernetes monitor 即可
    生成kube-heapster.yml

    cat <<EOF > kube-heapster.yml
    apiVersion: v1
    kind: ServiceAccount
    metadata:
      name: heapster-sa
      namespace: kube-system
      labels:
        kubernetes.io/cluster-service: "true"
        addonmanager.kubernetes.io/mode: Reconcile
    ---
    apiVersion: rbac.authorization.k8s.io/v1
    kind: ClusterRoleBinding
    metadata:
      name: heapster-binding
      labels:
        kubernetes.io/cluster-service: "true"
        addonmanager.kubernetes.io/mode: Reconcile
    roleRef:
      apiGroup: rbac.authorization.k8s.io
      kind: ClusterRole
      name: system:heapster
    subjects:
    - kind: ServiceAccount
      name: heapster
      namespace: kube-system
    ---
    apiVersion: rbac.authorization.k8s.io/v1
    kind: Role
    metadata:
      name: system:pod-nanny
      namespace: kube-system
      labels:
        kubernetes.io/cluster-service: "true"
        addonmanager.kubernetes.io/mode: Reconcile
    rules:
    - apiGroups:
      - ""
      resources:
      - pods
      verbs:
      - get
    - apiGroups:
      - "extensions"
      resources:
      - deployments
      verbs:
      - get
      - update
    ---
    apiVersion: rbac.authorization.k8s.io/v1
    kind: RoleBinding
    metadata:
      name: heapster-binding
      namespace: kube-system
      labels:
        kubernetes.io/cluster-service: "true"
        addonmanager.kubernetes.io/mode: Reconcile
    roleRef:
      apiGroup: rbac.authorization.k8s.io
      kind: Role
      name: system:pod-nanny
    subjects:
    - kind: ServiceAccount
      name: heapster
      namespace: kube-system
    ---
    kind: Service
    apiVersion: v1
    metadata:
      name: heapster
      namespace: kube-system
      labels:
        kubernetes.io/cluster-service: "true"
        addonmanager.kubernetes.io/mode: Reconcile
    spec:
      ports:
        - port: 80
          targetPort: 8082
      selector:
        k8s-app: heapster
    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: monitoring-grafana
      namespace: kube-system
      labels:
        kubernetes.io/cluster-service: "true"
        addonmanager.kubernetes.io/mode: Reconcile
    spec:
      ports:
        - port: 80
          protocol: TCP
          targetPort: ui
      selector:
        k8s-app: influxGrafana
    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: monitoring-influxdb
      namespace: kube-system
      labels:
        kubernetes.io/cluster-service: "true"
        addonmanager.kubernetes.io/mode: Reconcile
    spec:
      ports:
        - name: http
          port: 8083
          targetPort: 8083
        - name: api
          port: 8086
          targetPort: 8086
      selector:
        k8s-app: influxGrafana
    ---
    apiVersion: extensions/v1beta1
    kind: Deployment
    metadata:
      name: heapster
      labels:
        k8s-app: heapster
        kubernetes.io/cluster-service: "true"
        addonmanager.kubernetes.io/mode: Reconcile
      namespace: kube-system
    spec:
      replicas: 1
      selector:
        matchLabels:
          k8s-app: heapster
      template:
        metadata:
          labels:
            k8s-app: heapster
          annotations:
            scheduler.alpha.kubernetes.io/critical-pod: ''
        spec:
          serviceAccountName: heapster-sa
          tolerations:
          - key: node-role.kubernetes.io/master
            effect: NoSchedule
          - key: "CriticalAddonsOnly"
            operator: "Exists"
          containers:
            - image: registry.cn-shenzhen.aliyuncs.com/rancher_cn/heapster-amd64:v1.5.0-beta.0
              name: heapster
              livenessProbe:
                httpGet:
                  path: /healthz
                  port: 8082
                  scheme: HTTP
                initialDelaySeconds: 180
                timeoutSeconds: 5
              command:
                - /heapster
                - --source=kubernetes.summary_api:''
                - --sink=influxdb:http://monitoring-influxdb:8086
            - image: registry.cn-shenzhen.aliyuncs.com/rancher_cn/heapster-amd64:v1.5.0-beta.0
              name: eventer
              command:
                - /eventer
                - --source=kubernetes:''
                - --sink=influxdb:http://monitoring-influxdb:8086
            - image: registry.cn-hangzhou.aliyuncs.com/google_containers/addon-resizer:1.7
              name: heapster-nanny
              resources:
                limits:
                  cpu: 100m
                  memory: 128Mi
                requests:
                  cpu: 50m
                  memory: 90Mi
              env:
                - name: MY_POD_NAME
                  valueFrom:
                    fieldRef:
                      fieldPath: metadata.name
                - name: MY_POD_NAMESPACE
                  valueFrom:
                    fieldRef:
                      fieldPath: metadata.namespace
              command:
                - /pod_nanny
                - --cpu=80m
                - --extra-cpu=0.5m
                - --memory=140Mi
                - --extra-memory=4Mi
                - --threshold=5
                - --deployment=heapster
                - --container=heapster
                - --poll-period=300000
                - --estimator=exponential
            - image: registry.cn-hangzhou.aliyuncs.com/google_containers/addon-resizer:1.7
              name: eventer-nanny
              resources:
                limits:
                  cpu: 100m
                  memory: 128Mi
                requests:
                  cpu: 50m
                  memory: 90Mi
              env:
                - name: MY_POD_NAME
                  valueFrom:
                    fieldRef:
                      fieldPath: metadata.name
                - name: MY_POD_NAMESPACE
                  valueFrom:
                    fieldRef:
                      fieldPath: metadata.namespace
              command:
                - /pod_nanny
                - --cpu=100m
                - --extra-cpu=0m
                - --memory=190Mi
                - --extra-memory=500Ki
                - --threshold=5
                - --deployment=heapster
                - --container=eventer
                - --poll-period=300000
                - --estimator=exponential
    ---
    kind: Deployment
    apiVersion: extensions/v1beta1
    metadata:
      name: influxdb-grafana
      namespace: kube-system
      labels:
        k8s-app: influxGrafana
        kubernetes.io/cluster-service: "true"
        addonmanager.kubernetes.io/mode: Reconcile
    spec:
      replicas: 1
      selector:
        matchLabels:
          k8s-app: influxGrafana
      template:
        metadata:
          labels:
            k8s-app: influxGrafana
          annotations:
            scheduler.alpha.kubernetes.io/critical-pod: ''
        spec:
          tolerations:
          - key: node-role.kubernetes.io/master
            effect: NoSchedule
          - key: "CriticalAddonsOnly"
            operator: "Exists"
          containers:
            - name: influxdb
              image: registry.cn-shenzhen.aliyuncs.com/rancher_cn/heapster-influxdb-amd64:v1.3.3
              resources:
                limits:
                  cpu: 100m
                  memory: 500Mi
                requests:
                  cpu: 100m
                  memory: 500Mi
              ports:
                - name: http
                  containerPort: 8083
                - name: api
                  containerPort: 8086
              volumeMounts:
              - name: influxdb-persistent-storage
                mountPath: /data
            - name: grafana
              image: registry.cn-shenzhen.aliyuncs.com/rancher_cn/heapster-grafana-amd64:v4.4.3
              env:
              resources:
                limits:
                  cpu: 100m
                  memory: 100Mi
                requests:
                  cpu: 100m
                  memory: 100Mi
              env:
                - name: INFLUXDB_SERVICE_URL
                  value: http://monitoring-influxdb:8086
                - name: GF_AUTH_BASIC_ENABLED
                  value: "false"
                - name: GF_AUTH_ANONYMOUS_ENABLED
                  value: "true"
                - name: GF_AUTH_ANONYMOUS_ORG_ROLE
                  value: Admin
                - name: GF_SERVER_ROOT_URL
                  value: /api/v1/proxy/namespaces/kube-system/services/monitoring-grafana/
              ports:
              - name: ui
                containerPort: 3000
                protocol: TCP
              volumeMounts:
              - name: grafana-persistent-storage
                mountPath: /var
          volumes:
          - name: influxdb-persistent-storage
            emptyDir: {}
          - name: grafana-persistent-storage
            emptyDir: {}
    EOF


    kubectl apply -f kube-heapster.yml

    查看状态

    kubectl -n kube-system get po,svc


    完成后,就可以通过浏览器访问Grafana Dashboard

    https://10.0.0.162:6443/api/v1/proxy/namespaces/kube-system/services/monitoring-grafana


感谢各位的阅读!关于“Kubernetes 1.8.4中如何安装Heapster”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI