Change:
This is a Bug Report <!-- Thanks for filing an issue! Before submitting, please fill in the following information. --<!-- See for guidance on writing an actionable issue description. --<!--Required Information--Problem: There is a broken link to script in tasks/administer-cluster/out-of- file. At 44 line: Proposed Solution: Move the script file to examples directory. Page to Update: <!--Optional Information (remove the comment tags around information you would like to include)--<!--Kubernetes Version:--<!--Additional Information:--/language en
/assign

Discussion:
<del> #!/bin/bash #!/usr/bin/env bash # This script reproduces what the kubelet does # to calculate memory.available relative to root cgroup. # current memory usage memory_capacity_in_kb=$(cat /proc/meminfo | grep MemTotal | awk '{print $2}') memory_capacity_in_bytes=$((memory_capacity_in_kb * 1024)) memory_usage_in_bytes=$(cat /sys/fs/cgroup/memory/memory.usage_in_bytes) memory_total_inactive_file=$(cat /sys/fs/cgroup/memory/memory.stat | grep total_inactive_file | awk '{print $2}') memory_working_set=${memory_usage_in_bytes} if [ "$memory_working_set" -lt "$memory_total_inactive_file" ]; then memory_working_set=0 else memory_working_set=$((memory_usage_in_bytes - memory_total_inactive_file)) fi memory_available_in_bytes=$((memory_capacity_in_bytes - memory_working_set)) memory_available_in_kb=$((memory_available_in_bytes / 1024)) memory_available_in_mb=$((memory_available_in_kb / 1024)) echo "memory.capacity_in_bytes $memory_capacity_in_bytes" echo "memory.usage_in_bytes $memory_usage_in_bytes" echo "memory.total_inactive_file $memory_total_inactive_file" echo "memory.working_set $memory_working_set" echo "memory.available_in_bytes $memory_available_in_bytes" echo "memory.available_in_kb $memory_available_in_kb" echo "memory.available_in_mb $memory_available_in_mb" </del>

container, and if users use the [node allocatable](/docs/tasks/administer-cluster/reserve-compute-resources/#node-allocatable) feature, out of resource decisions are made local to the end user Pod part of the cgroup hierarchy as well as the <del> root node. This [script](/docs/tasks/administer-cluster/memory-available.sh) </del> <ins> root node. This [script](/examples/admin/resource/memory-available.sh) </ins> reproduces the same set of steps that the `kubelet` performs to calculate `memory.available`. The `kubelet` excludes inactive_file (i.e. # of bytes of file-backed memory on inactive LRU list) from its calculation as it assumes that

<ins> #!/bin/bash #!/usr/bin/env bash # This script reproduces what the kubelet does # to calculate memory.available relative to root cgroup. # current memory usage memory_capacity_in_kb=$(cat /proc/meminfo | grep MemTotal | awk '{print $2}') memory_capacity_in_bytes=$((memory_capacity_in_kb * 1024)) memory_usage_in_bytes=$(cat /sys/fs/cgroup/memory/memory.usage_in_bytes) memory_total_inactive_file=$(cat /sys/fs/cgroup/memory/memory.stat | grep total_inactive_file | awk '{print $2}') memory_working_set=${memory_usage_in_bytes} if [ "$memory_working_set" -lt "$memory_total_inactive_file" ]; then memory_working_set=0 else memory_working_set=$((memory_usage_in_bytes - memory_total_inactive_file)) fi memory_available_in_bytes=$((memory_capacity_in_bytes - memory_working_set)) memory_available_in_kb=$((memory_available_in_bytes / 1024)) memory_available_in_mb=$((memory_available_in_kb / 1024)) echo "memory.capacity_in_bytes $memory_capacity_in_bytes" echo "memory.usage_in_bytes $memory_usage_in_bytes" echo "memory.total_inactive_file $memory_total_inactive_file" echo "memory.working_set $memory_working_set" echo "memory.available_in_bytes $memory_available_in_bytes" echo "memory.available_in_kb $memory_available_in_kb" echo "memory.available_in_mb $memory_available_in_mb" </ins>