Kubernetes 具有临时存储的概念,可以通过部署将其应用于容器,如下所示:
limits:
cpu: 500m
memory: 512Mi
ephemeral-storage: 100Mi
requests:
cpu: 50m
memory: 256Mi
ephemeral-storage: 50Mi
现在,将其应用于 k8s 1.18 集群(IBM Cloud 管理的 k8s)时,我在查看正在运行的容器时看不到任何变化:
kubectl exec -it <pod> -n <namespace> -c nginx -- /bin/df
我希望看到那里发生变化。我错了吗?
最佳答案
您可以使用kubectl describe node <insert-node-name-here>
查看分配的资源在运行部署 pod 的节点上。
你应该看到这样的东西:
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 将被驱逐并重新启动。
在节点端,当节点资源耗尽时,任何使用超过其请求资源的 pod 都会被驱逐。换句话说,Kubernetes 从不提供任何超出 Pod 请求的资源可用性保证。
在 kubernetes 文档中,您可以找到更多关于临时存储消耗管理工作原理的详细信息 here .
请注意,将 kubectl exec 与 df
结合使用命令可能不会显示存储的实际使用情况。
根据 kubernetes documentation :
The kubelet can measure how much local storage it is using. It does this provided that:
- 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.
If you have a different configuration, then the kubelet does not apply resource limits for ephemeral local storage.
Note: The kubelet tracks
tmpfs
emptyDir volumes as container memory use, rather than as local ephemeral storage.
关于容器的 Kubernetes 临时存储,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64817285/