获取边缘监控

Enable kubectl logs/exec feature

Refer to this doc.

Deploy metrics server

Here we use v0.4.1 metrics-server, please use v0.4.0+ version since it supports automatic port identification after v0.4.0.

v0.4.1 have fixed a harmless stack dump error, details see this pr.

Download Configuration

  1. $ wget https://github.com/kubernetes-sigs/metrics-server/releases/download/v0.4.0/components.yaml -O deploy.yaml

Update Deploy Configuration

Update deploy.yaml as below:

  • Add affinity and tolerations configuration:

    1. spec:
    2. template:
    3. spec:
    4. affinity:
    5. nodeAffinity:
    6. requiredDuringSchedulingIgnoredDuringExecution:
    7. nodeSelectorTerms:
    8. - matchExpressions:
    9. - key: node-role.kubernetes.io/master
    10. operator: Exists
    11. tolerations:
    12. - key: node-role.kubernetes.io/master
    13. operator: Exists
    14. effect: NoSchedule
  • Enable hostnetwork mode:

    1. spec:
    2. template:
    3. spec:
    4. hostNetwork: true
  • Skip tls insecure:

    1. spec:
    2. template:
    3. spec:
    4. containers:
    5. - args:
    6. - --kubelet-insecure-tls

Deploy

  1. $ kubectl apply -f deploy.yaml
  2. serviceaccount/metrics-server created
  3. clusterrole.rbac.authorization.k8s.io/system:aggregated-metrics-reader created
  4. clusterrole.rbac.authorization.k8s.io/system:metrics-server created
  5. rolebinding.rbac.authorization.k8s.io/metrics-server-auth-reader created
  6. clusterrolebinding.rbac.authorization.k8s.io/metrics-server:system:auth-delegator created
  7. clusterrolebinding.rbac.authorization.k8s.io/system:metrics-server created
  8. service/metrics-server created
  9. deployment.apps/metrics-server created
  10. apiservice.apiregistration.k8s.io/v1beta1.metrics.k8s.io created

Test

  1. $ kubectl top node

It would output all nodes as following:

  1. NAME CPU(cores) CPU% MEMORY(bytes) MEMORY%
  2. edge-node 1169m 29% 3605Mi 45%
  3. test-control-plane 121m 3% 664Mi 8%