kubernetes: CPU resource limit is not working with windows containers
What happened: CPU resource limit is not working for windows containers
What you expected to happen: Container should get terminated when it uses more resources than the specified limit.
How to reproduce it (as minimally and precisely as possible): Create cluster using the following version of aks-engine and Kubernetes. aksengineVersion: v0.30.0 orchestrator : kubernetes:1.12.5
Create a pod using windows container with the following SKU as the base image. Publisher: MicrosoftWindowsServer Offer: WindowsServerSemiAnnual SKU: Datacenter-Core-1803-with-Containers-smalldisk Version: latest
Set the following resource limit on the pod. resources: limits: cpu: “1” requests: cpu: “1”
Perform a CPU intensive task in the container and monitor container CPU usage with the following command. kubectl top pods
You will notice that container CPU core usage can go much beyond 1000m (I was able to get it to go up to 3600m)
Anything else we need to know?: The wrong fields is being requested in the create container API call into docker. It looks like whatever is calling docker is assuming that CPU limits on Windows are the same as CPU limits on Linux, which is not case.
For example, two containers were created in a pod with the following resource limits. Limits: cpu: 1 memory: 8Gi Requests: cpu: 1 memory: 8Gi
Limits:
cpu: 100m
memory: 256Mi
Requests:
cpu: 100m
memory: 256Mi
Following are the corresponding logs in HCS time=“2019-03-07T21:07:27.413447800Z” level=debug msg="hcsshim::CreateComputeSystem ID=9a2fcd2ff057c7f930f13b4a674f52a1b336fb1bf6e38bf938e68890909b2b9b … "ProcessorWeight":5000, "MemoryMaximumInMB":8192
time=“2019-03-07T21:07:29.289456500Z” level=debug msg="hcsshim::CreateComputeSystem ID=9d4d6e783468762d86cf5967d7bafe8ea69b9992efd46c25133a0c6129b83ae3 "ProcessorWeight":5000, "MemoryMaximumInMB":256,
These are all argons. If you compare a couple of similar docker run statements with resource constrains on WCOW Argon, you get the following sent to HCS. (Note this is running on an 8-core VM. And argon CPU limits are “faked” where 10000 represents all cores)
docker run --rm --cpus=2 -m 2gb microsoft/nanoserver cmd /s /c echo hello "ProcessorMaximum":2500, *2CPUs= ¼ of cores, so ¼ * 10000 = 2500 "MemoryMaximumInMB":2048
docker run --rm --cpus=8 -m 2gb microsoft/nanoserver cmd /s /c echo hello "ProcessorMaximum":10000, * 8CPUs = all cores, so 10000. "MemoryMaximumInMB":2048
Environment:
- Kubernetes version (use
kubectl version): 1.12.5 - Cloud provider or hardware configuration: Azure
- OS (e.g:
cat /etc/os-release): MicrosoftWindowsServer, Datacenter-Core-1803-with-Containers-smalldisk - Kernel (e.g.
uname -a): - Install tools:
- Others:
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 15 (9 by maintainers)
Fixed in https://github.com/kubernetes/kubernetes/pull/86101