Cost Optimized Addon scaling (CoreDns & Retina)
What happened: Many AKS maintained Pods are running with memory overcommitment, eg:
- omsagent (Daemonset; up to 375 MB)
- coredns (Deployment, up to 100MB)
- kube-proxy (Daemonset; unlimited?!)
- azure-policy (Deployment; up to 150MB)
- azure-policy-webhook (Deployment, up to 150MB)
- and others
for example OMS agent pods (from daemonset omsagent) are running with:
resources:
limits:
cpu: 500m
memory: 600Mi
requests:
cpu: 75m
memory: 225Mi
on high load and if node memory is used eg. 99% (which is possible with Kubernetes) this might trigger an OOM Killer on the host (not on the pod!) and so might affect other Pods!
What you expected to happen:
be fair and set limit and request for memory to the same values. don't overcommit memory.
resources:
limits:
cpu: 500m
memory: 600Mi
requests:
cpu: 75m
memory: 600Mi
How to reproduce it (as minimally and precisely as possible):
spin up AKS in 1.18 or 1.19 w/ and w/o services (eg. omsagent, policy agent,...)
Anything else we need to know?:
Environment:
- Kubernetes version (use
kubectl version): 1.18.14 (also with 1.19.7) - Size of cluster (how many worker nodes are in the cluster?) 3
- General description of workloads in the cluster (e.g. HTTP microservices, Java app, Ruby on Rails, machine learning, etc.)
- Others:
Hi mblaschke, AKS bot here :wave: Thank you for posting on the AKS Repo, I'll do my best to get a kind human from the AKS team to assist you.
I might be just a bot, but I'm told my suggestions are normally quite good, as such:
- If this case is urgent, please open a Support Request so that our 24/7 support team may help you faster.
- Please abide by the AKS repo Guidelines and Code of Conduct.
- If you're having an issue, could it be described on the AKS Troubleshooting guides or AKS Diagnostics?
- Make sure your subscribed to the AKS Release Notes to keep up to date with all that's new on AKS.
- Make sure there isn't a duplicate of this issue already reported. If there is, feel free to close this one and '+1' the existing issue.
- If you have a question, do take a look at our AKS FAQ. We place the most common ones there!
Triage required from @Azure/aks-pm
@az-policy-kube would you be able to assist?
Issue Details
What happened: Many AKS maintained Pods are running with memory overcommitment, eg:
- omsagent (Daemonset; up to 375 MB)
- coredns (Deployment, up to 100MB)
- kube-proxy (Daemonset; unlimited?!)
- azure-policy (Deployment; up to 150MB)
- azure-policy-webhook (Deployment, up to 150MB)
- and others
for example OMS agent pods (from daemonset omsagent) are running with:
resources:
limits:
cpu: 500m
memory: 600Mi
requests:
cpu: 75m
memory: 225Mi
on high load and if node memory is used eg. 99% (which is possible with Kubernetes) this might trigger an OOM Killer on the host (not on the pod!) and so might affect other Pods!
What you expected to happen:
be fair and set limit and request for memory to the same values. don't overcommit memory.
resources:
limits:
cpu: 500m
memory: 600Mi
requests:
cpu: 75m
memory: 600Mi
How to reproduce it (as minimally and precisely as possible):
spin up AKS in 1.18 or 1.19 w/ and w/o services (eg. omsagent, policy agent,...)
Anything else we need to know?:
Environment:
- Kubernetes version (use
kubectl version): 1.18.14 (also with 1.19.7) - Size of cluster (how many worker nodes are in the cluster?) 3
- General description of workloads in the cluster (e.g. HTTP microservices, Java app, Ruby on Rails, machine learning, etc.)
- Others:
| Author: | mblaschke |
|---|---|
| Assignees: | - |
| Labels: |
|
| Milestone: | - |
Here is a document that talks about resource-reservations to the specific K8s components.
https://docs.microsoft.com/en-us/azure/aks/concepts-clusters-workloads#resource-reservations
I would recommend to use system node pool for the system pods (deployments), and application node pool for customer workloads. This will reduce the impact from the system components to their application. https://docs.microsoft.com/en-us/azure/aks/use-system-pools#system-and-user-node-pools
The challenge here is about the daemonset, since it runs on all the nodes, and we need to support various kind of clusters, small/large, different VM SKUs on different agent pools. For example, the smallest VM SKU we support is F2 which has 4 GB, and ~2GB allocatable memory. We usually set the memory request to the minimum footprint of the pod, and set the memory limit to a large number from the “large cluster” scaling test. If we increase the request to limit, ds pods might not fit on the F2 VM.
The omsagent memory usage depends on how many log is written by all the pods running on the node, mostly contributed by customer’s application pods.
Adding Policy team to comment on there pods.
The problem here is: There is no memory overcommit. You can overcommit CPUs but not memory (if you don't have swap which is strongly not recommended by Kubernetes).
So if the application Pods are using 99% of memory and eg. omsagent or even kubeproxy (which is not reserved at all) uses 2% more memory this will trigger the OOM killer on the host and kills a container or application more or less randomly.
IMHO the options are:
- make it configurable (eg. implement an operator) how much the customer wants to reserve/limit (or maybe the customer doesn't care)
- set request = limit
- or let the customer deal with the fact that this can trigger an OOMkiller on the host and randomly
- the customer has to deploy a pause pod which reserves eg. 500Mi to deal with the fact that there are apps which are not reserving their memory in a proper way
I'm not that happy about the statement with system and user node pools. The argument (from the microsoft conultant) for AKS was that the customer doesn't have to care for the master and now it feels like there are "masters" (sort of) again. This would mean that system nodes cannot be used for anything else (because they are "unstable") and would reduce the total node count by one pool (only having 9 pools left for applications). With proper memory reservation there is no real reason not to use these nodes :)
Action required from @Azure/aks-pm
Issue needing attention of @Azure/aks-leads
Issue needing attention of @Azure/aks-leads
Issue needing attention of @Azure/aks-leads
@juan-lee @robbiezhang
Action required from @Azure/aks-pm
Issue needing attention of @Azure/aks-leads
Issue needing attention of @Azure/aks-leads
Issue needing attention of @Azure/aks-leads
Issue needing attention of @Azure/aks-leads
prometheus-operator always alerts on those Pods:
52.5% throttling of CPU in namespace kube-system for container openvpn-client in pod aks-link-7676547cc6-5lfgd.
This should be fixed or somehow we should be able to configure it.
Issue needing attention of @Azure/aks-leads
@Kaarthis FYI.
Applications might use more memory in the startup time, but reduce later after GC. If we set the memory request/limit low, it maybe OOMKilled (as highlighted), and cause the pod fail to start. if AKS set the request/limit high for start up, it may cause memory utilization low in the runtime and waste of the VM compute power. Therefore, AKS strategy is to set the request to close to the regular usage, limit to the spike usage.
The memory consumption pattern for different applications are different. It will be different for different clusters as well. AKS today provides a high limit based on some estimation analysis. Having said that there is definitely an opportunity in providing a configurable memory limits for customers - This is something we shall consider in our Roadmap this year, though there is no immediate solution available.
In Kubernetes you can use nearly 100% of the Node memory by reserving it for Pods. So applications can reserve their memory to the limit what they are using and so improve the performance.
Unlike CPU there is no memory overcommitment so if Pods are using 99% of VM's memory (because it was reserved that way) the AKS maintained Pods can run into the overcommitment (use more than reserved) and trigger an Kernel OOM killer (instead of the cgroup memory killer) which kills innocent Pods/Containers.
To solve it: Don't overcommit memory because there is no way to overcommit it (because there is no swap).
Workaround: The customer has to reserve eg. 5% to 10% of memory on every system node because AKS is not caring about memory reservations. We're not talking about some megabytes, we're talking about more then 1 GiB of memory.
Either solve your memory reservation problem or make it configurable for the customer. But simply overcommit a resource which is not overcommit able is not really a professional way to run a managed Kubernetes cluster.