Running memcached in kubernetes with all available memory by default.

Hardcoding the memory limit seems weird when we already define the limit via kubernetes limits … so making it just use everything available.

# Dockerfile
FROM memcached
ADD start.sh /start.sh
CMD ["sh", "start.sh"]

# start.sh
exec memcached -m $(cat /sys/fs/cgroup/memory/memory.stat | 
grep hierarchical_memory_limit | 
awk '{print $2 / 1024 / 1024 - 10}')
Advertisements