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}')

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s