<p>On my kubernetes cluster, I have 15% (~4GB) extra GB of memory taken by my pods compared to my memory requests. I suspect it's been the reason some of my nodes have been crashing lately. How can I easily find the misconfigured pods and add the missing limits (ie find pods without memory requests, or whose memory limits are too high compared to requests ?</p>

Cyril Duchon-Doris
<p>You can use custom-columns as output format for a get request.</p>
<p>The query syntax is jsonpath, <a href="https://kubernetes.io/docs/reference/kubectl/jsonpath/" rel="noreferrer">https://kubernetes.io/docs/reference/kubectl/jsonpath/</a>.</p>
<p>For example</p>
<pre class="lang-bash prettyprint-override"><code>#!/bin/bash

ns='NAMESPACE:.metadata.namespace'
pod=&quot;POD:.metadata.name&quot;
container='CONTAINER:.spec.containers[*].name'
resource_req_mem='MEM_REQ:.spec.containers[*].resources.requests.memory'
resource_lim_mem='MEM_LIM:.spec.containers[*].resources.limits.memory'
resource_req_cpu='CPU_REQ:.spec.containers[*].resources.requests.cpu'
resource_lim_cpu='CPU_LIM:.spec.containers[*].resources.limits.cpu'

kubectl get pod -A -o custom-columns=&quot;$ns,$pod,$container,$resource_req_mem,$resource_lim_mem,$resource_req_cpu,$resource_lim_cpu&quot;
</code></pre>
