File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change 22
33MEMLIMIT=$(free -m | awk '/Mem:/ {print int($2 * 2 / 3)}')
44
5+ CG_LIMIT_FILE="/sys/fs/cgroup/memory/memory.limit_in_bytes"
6+ if [ -f "/sys/fs/cgroup/cgroup.controllers" ]; then
7+ CG_LIMIT_FILE="/sys/fs/cgroup/memory.max"
8+ fi
9+
10+ if [ -r "${CG_LIMIT_FILE}" ]; then
11+ MEMLIMIT_CG=$(awk '{print int($1 / 1024 / 1024 * 2 / 3)}' "${CG_LIMIT_FILE}")
12+
13+ if [ ${MEMLIMIT_CG} -lt ${MEMLIMIT} ]; then
14+ MEMLIMIT=${MEMLIMIT_CG}
15+ fi
16+ fi
17+
18+ echo "Memory limit for HAProxy: ${MEMLIMIT}MiB"
19+
520exec /usr/local/sbin/haproxy -W -db -m "${MEMLIMIT}" -f /etc/haproxy/haproxy.cfg -f /etc/haproxy/haproxy-aux.cfg
Original file line number Diff line number Diff line change 11#!/usr/bin/with-contenv sh
22
33MEMLIMIT=$(free -m | awk '/Mem:/ {print int($2 / 3)}')
4+
5+ CG_LIMIT_FILE="/sys/fs/cgroup/memory/memory.limit_in_bytes"
6+ if [ -f "/sys/fs/cgroup/cgroup.controllers" ]; then
7+ CG_LIMIT_FILE="/sys/fs/cgroup/memory.max"
8+ fi
9+
10+ if [ -r "${CG_LIMIT_FILE}" ]; then
11+ MEMLIMIT_CG=$(awk '{print int($1 / 1024 / 1024 / 3)}' "${CG_LIMIT_FILE}")
12+
13+ if [ ${MEMLIMIT_CG} -lt ${MEMLIMIT} ]; then
14+ MEMLIMIT=${MEMLIMIT_CG}
15+ fi
16+ fi
17+
418export GOMEMLIMIT="${MEMLIMIT}MiB"
519
20+ echo "Memory limit for Ingress Controller: ${GOMEMLIMIT}"
21+
622exec /haproxy-ingress-controller --with-s6-overlay ${EXTRA_OPTIONS}
You can’t perform that action at this time.
0 commit comments