<p>I want to test Pod eviction events that caused by memorypressure for taintbasedeviction on my pods, for to do that I created a memory load on my instance that have 2 vcpu and 8GB Ram.</p>

<p>For create a load I have run this command : </p>

<pre><code>stress-ng --vm 2 --vm-bytes 10G --timeout 60s
</code></pre>

<p>Output of memory usage</p>

<pre><code>$ free -h
              total        used        free      shared  buff/cache   available
Mem:          7.8Gi       2.7Gi       1.0Gi       3.9Gi       4.1Gi       984Mi
Swap:            0B          0B          0B
</code></pre>

<p>But in my nodes states there is no memorypressure I have updated kubelet eviction parameters at below : </p>

<pre><code>evictionHard:
    memory.available:  "200Mi"
</code></pre>

<p>As summary, How Can I create memory pressure on my worker nodes for test the taint based eviction ? </p>

<p>Thanks </p>

Ayhan Balik
<p>You could invoke the stress command multiple times. Check the script <a href="https://github.com/giantswarm/kube-stresscheck" rel="nofollow noreferrer">here</a>.</p>

<p>The value for <code>memory.available</code> is derived from the cgroupfs instead of tools like <code>free -m</code>. This is important because <code>free -m</code> does not work in a container, and if users use the node allocatable feature, out of resource decisions are made local to the end user Pod part of the cgroup hierarchy as well as the root node. This <a href="https://kubernetes.io/docs/tasks/administer-cluster/out-of-resource/memory-available.sh" rel="nofollow noreferrer">script</a> reproduces the same set of steps that the kubelet performs to calculate <code>memory.available</code>. The kubelet excludes inactive_file (i.e. # of bytes of file-backed memory on inactive LRU list) from its calculation as it assumes that memory is reclaimable under pressure.</p>
