kubectl描述节点未报告适当的Pod使用情况

时间:2018-06-27 22:49:01

标签: kubernetes

我有一个k8s v1.10.2、3x3集群,我想强调一下。我把命令放在一起:

kubectl run stress --replicas=1 --image=lorel/docker-stress-ng -- --cpu 8 --io 8 --vm 4 --vm-bytes 1024m  --fork 4 --timeout 5m --metrics-brief  

,当我通过以下方式查看节点使用情况时:

kubectl describe node addons-worker-01

节点未报告Pod的使用情况:

Non-terminated Pods:         (6 in total)
  Namespace                  Name                                  CPU Requests  CPU Limits  Memory Requests  Memory Limits
  ---------                  ----                                  ------------  ----------  ---------------  -------------
  default                    stress-765b45bdd5-qwqbj               0 (0%)        0 (0%)      0 (0%)           0 (0%)

但是,当我在顶部查看时,该节点显示了我期望的用法。这是预期的吗?我想念什么吗?

1 个答案:

答案 0 :(得分:2)

kubctl describe用于显示您当前的节点配置。

例如:

Namespace       Name                CPU Requests    CPU Limits Memory Requests  Memory Limits
 ---------      ----                ------------    ---------- ---------------  ------------- 
 default        stress                  100m (1%)       0 (0%)          0 (0%)          0 (0%)
 kube-system    fluentd                 100m (1%)       0 (0%)      200Mi (0%)      300Mi (1%) 
 kube-system    kube-dns                260m (3%)       0 (0%)      110Mi (0%)      170Mi (0%) 
 kube-system    kube-proxy-gke-cluster  100m (1%)       0 (0%)          0 (0%)          0 (0%) 
 kube-system    kubernetes-dashboard    100m (1%)    100m (1%)      100Mi (0%)      300Mi (1%)

Allocated resources: 
(Total limits may be over 100 percent, i.e., overcommitted.) 
CPU Requests CPU Limits Memory Requests Memory Limits 
------------ ---------- --------------- ------------- 
660m (8%) 100m (1%) 410Mi (1%) 770Mi (2%)

这意味着节点上有5个容器,例如, 流利 需要100m的CPU才能不启动 限制设置和200M的启动内存,限制为300M。

您可以在pod的配置yaml文件内设置限制,如下所示:

spec:
  containers:
  - name: text
    image: nginx
   resources:
      limits:
        memory: 512Mi
      requests:
        memory: 128Mi

有关设置内存和CPU限制的更多信息,您可以在Kubernetes manage-resources文档中阅读。

为进行监视,我建议使用PrometheusGoogle Cloud Monitoring

您还可以使用kubctl top nodes来显示节点上的当前负载:

NAME                                       CPU(cores)   CPU%      MEMORY(bytes)   MEMORY%
gke-cluster-1-default-pool-1                7969m        100%      4708Mi          17%
gke-cluster-1-default-pool-2                56m          0%        491Mi           1%
gke-cluster-1-default-pool-3                60m          0%        568Mi           2%