Kubernetes 临时存储容器 [英] Kubernetes ephemeral-storage of containers

查看:123
本文介绍了Kubernetes 临时存储容器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Kubernetes 有 ephemeral-storage 的概念,它可以通过部署应用到这样的容器中:

Kubernetes has the concept of ephemeral-storage which can be applied by the deployment to a container like this:

limits:
  cpu: 500m
  memory: 512Mi
  ephemeral-storage: 100Mi
requests:
  cpu: 50m
  memory: 256Mi
  ephemeral-storage: 50Mi

现在,将其应用于 k8s 1.18 集群(IBM Cloud 管理的 k8s)时,我在查看正在运行的容器时看不到任何变化:

Now, when applying this to a k8s 1.18 cluster (IBM Cloud managed k8s), I cannot see any changes when I look at a running container:

kubectl exec -it <pod> -n <namespace> -c nginx -- /bin/df

我希望看到这些变化.我错了吗?

I would expect to see there changes. Am I wrong?

推荐答案

您可以通过使用 kubectl describe node 在该节点上查看分配的资源运行部署的 pod.

You can see the allocated resources by using kubectl describe node <insert-node-name-here> on the node that is running the pod of the deployment.

您应该会看到如下内容:

You should see something like this:

Allocated resources:
  (Total limits may be over 100 percent, i.e., overcommitted.)
  Resource                       Requests      Limits
  --------                       --------      ------
  cpu                            1130m (59%)   3750m (197%)
  memory                         4836Mi (90%)  7988Mi (148%)
  ephemeral-storage              0 (0%)        0 (0%)
  hugepages-1Gi                  0 (0%)        0 (0%)
  hugepages-2Mi                  0 (0%)        0 (0%)
  attachable-volumes-azure-disk  0             0

当您请求 50Mi 的临时存储时,它应显示在 Requests 下.当您的 pod 尝试使用超过限制 (100Mi) 时,pod 将被逐出并重新启动.

When you requested 50Mi of ephemeral-storage it should show up under Requests. When your pod tries to use more than the limit (100Mi) the pod will be evicted and restarted.

在节点方面,当节点耗尽资源时,任何使用超过其请求资源的 Pod 都会被驱逐.换句话说,Kubernetes 从不提供任何超出 Pod 请求的资源可用性保证.

On the node side, any pod that uses more than its requested resources is subject to eviction when the node runs out of resources. In other words, Kubernetes never provides any guarantees of availability of resources beyond a Pod's requests.

在 kubernetes 文档中,您可以找到有关临时存储消耗管理工作原理的更多详细信息 此处.

In kubernetes documentation you can find more details how Ephemeral storage consumption management works here.

请注意,将 kubectl exec 与 df 命令一起使用可能不会显示实际的存储使用情况.

Note that using kubectl exec with df command might not show actual use of storage.

根据 kubernetes 文档:

According to kubernetes documentation:

kubelet 可以测量它使用了多少本地存储.它这样做的前提是:

The kubelet can measure how much local storage it is using. It does this provided that:

  • LocalStorageCapacityIsolation 功能门已启用(默认情况下该功能处于启用状态),并且
  • 您已使用支持的本地临时存储配置之一设置节点.
  • the LocalStorageCapacityIsolation feature gate is enabled (the feature is on by default), and
  • you have set up the node using one of the supported configurations for local ephemeral storage.

如果您有不同的配置,那么 kubelet 不会对临时本地存储应用资源限制.

If you have a different configuration, then the kubelet does not apply resource limits for ephemeral local storage.

注意: kubelet 跟踪 tmpfs emptyDir 卷作为容器内存使用,而不是作为本地临时存储.

Note: The kubelet tracks tmpfs emptyDir volumes as container memory use, rather than as local ephemeral storage.

这篇关于Kubernetes 临时存储容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆