Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

Commit

Permalink
Merge pull request #55 from jdeathe/issue/47
Browse files Browse the repository at this point in the history
CLOSES #47: Adds required sysctl settings to docker run templates.
  • Loading branch information
jdeathe authored Nov 16, 2018
2 parents dd6b797 + 4c31a6a commit e723c83
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ CentOS-7 7.5.1804 x86_64 - Memcached 1.4.
### 2.1.1 - Unreleased

- Fixes typo in test; using `--format` instead of `--filter`.
- Adds required `--sysctl` settings to docker run templates.

### 2.1.0 - 2018-08-16

Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Run up a container named `memcached.pool-1.1.1` from the docker image `jdeathe/c
$ docker run -d \
--name memcached.pool-1.1.1 \
-p 11211:11211/tcp \
--sysctl "net.core.somaxconn=1024" \
jdeathe/centos-ssh-memcached:2.1.0
```

Expand Down Expand Up @@ -74,6 +75,9 @@ $ docker run \
--tty \
--name memcached.pool-1.1.1 \
--publish 11211:11211/tcp \
--sysctl "net.core.somaxconn=1024" \
--sysctl "net.ipv4.ip_local_port_range=1024 65535" \
--sysctl "net.ipv4.route.flush=1" \
--env "MEMCACHED_CACHESIZE=32" \
jdeathe/centos-ssh-memcached:2.1.0
```
Expand Down
3 changes: 3 additions & 0 deletions default.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
define DOCKER_CONTAINER_PARAMETERS
--name $(DOCKER_NAME) \
--restart $(DOCKER_RESTART_POLICY) \
--sysctl "net.core.somaxconn=$(SYSCTL_NET_CORE_SOMAXCONN)" \
--sysctl "net.ipv4.ip_local_port_range=$(SYSCTL_NET_IPV4_IP_LOCAL_PORT_RANGE)" \
--sysctl "net.ipv4.route.flush=$(SYSCTL_NET_IPV4_ROUTE_FLUSH)" \
--env "MEMCACHED_AUTOSTART_MEMCACHED_WRAPPER=$(MEMCACHED_AUTOSTART_MEMCACHED_WRAPPER)" \
--env "MEMCACHED_CACHESIZE=$(MEMCACHED_CACHESIZE)" \
--env "MEMCACHED_MAXCONN=$(MEMCACHED_MAXCONN)" \
Expand Down
5 changes: 5 additions & 0 deletions environment.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ DOCKER_IMAGE_RELEASE_TAG_PATTERN := ^(1|2|centos-(6-1|7-2))\.[0-9]+\.[0-9]+$
# Variables
# -----------------------------------------------------------------------------

# Docker --sysctl settings
SYSCTL_NET_CORE_SOMAXCONN ?= 1024
SYSCTL_NET_IPV4_IP_LOCAL_PORT_RANGE ?= 1024 65535
SYSCTL_NET_IPV4_ROUTE_FLUSH ?= 1

# Docker image/container settings
DOCKER_CONTAINER_OPTS ?=
DOCKER_IMAGE_TAG ?= latest
Expand Down
6 changes: 6 additions & 0 deletions src/etc/systemd/system/centos-ssh-memcached@.service
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ Environment="MEMCACHED_AUTOSTART_MEMCACHED_WRAPPER=true"
Environment="MEMCACHED_CACHESIZE=64"
Environment="MEMCACHED_MAXCONN=1024"
Environment="MEMCACHED_OPTIONS=-U 0"
Environment="SYSCTL_NET_CORE_SOMAXCONN=1024"
Environment="SYSCTL_NET_IPV4_IP_LOCAL_PORT_RANGE=1024 65535"
Environment="SYSCTL_NET_IPV4_ROUTE_FLUSH=1"

# Initialisation: Load image from local storage if available, otherwise pull.
ExecStartPre=/bin/bash -c \
Expand Down Expand Up @@ -88,6 +91,9 @@ ExecStartPre=-/bin/bash -c \
ExecStart=/bin/bash -c \
"exec /usr/bin/docker run \
--name %p.%i \
--sysctl \"net.core.somaxconn=${SYSCTL_NET_CORE_SOMAXCONN}\" \
--sysctl \"net.ipv4.ip_local_port_range=${SYSCTL_NET_IPV4_IP_LOCAL_PORT_RANGE}\" \
--sysctl \"net.ipv4.route.flush=${SYSCTL_NET_IPV4_ROUTE_FLUSH}\" \
--env \"MEMCACHED_AUTOSTART_MEMCACHED_WRAPPER=${MEMCACHED_AUTOSTART_MEMCACHED_WRAPPER}\" \
--env \"MEMCACHED_CACHESIZE=${MEMCACHED_CACHESIZE}\" \
--env \"MEMCACHED_MAXCONN=${MEMCACHED_MAXCONN}\" \
Expand Down
3 changes: 3 additions & 0 deletions src/opt/scmi/default.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ fi
# Common parameters of create and run targets
DOCKER_CONTAINER_PARAMETERS="--name ${DOCKER_NAME} \
--restart ${DOCKER_RESTART_POLICY} \
--sysctl \"net.core.somaxconn=${SYSCTL_NET_CORE_SOMAXCONN}\" \
--sysctl \"net.ipv4.ip_local_port_range=${SYSCTL_NET_IPV4_IP_LOCAL_PORT_RANGE}\" \
--sysctl \"net.ipv4.route.flush=${SYSCTL_NET_IPV4_ROUTE_FLUSH}\" \
--env \"MEMCACHED_AUTOSTART_MEMCACHED_WRAPPER=${MEMCACHED_AUTOSTART_MEMCACHED_WRAPPER}\" \
--env \"MEMCACHED_CACHESIZE=${MEMCACHED_CACHESIZE}\" \
--env \"MEMCACHED_MAXCONN=${MEMCACHED_MAXCONN}\" \
Expand Down
5 changes: 5 additions & 0 deletions src/opt/scmi/environment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ DIST_PATH="${DIST_PATH:-./dist}"
# Number of seconds expected to complete container startup including bootstrap.
STARTUP_TIME="${STARTUP_TIME:-1}"

# Docker --sysctl settings
SYSCTL_NET_CORE_SOMAXCONN="${SYSCTL_NET_CORE_SOMAXCONN:-1024}"
SYSCTL_NET_IPV4_IP_LOCAL_PORT_RANGE="${SYSCTL_NET_IPV4_IP_LOCAL_PORT_RANGE:-1024 65535}"
SYSCTL_NET_IPV4_ROUTE_FLUSH="${SYSCTL_NET_IPV4_ROUTE_FLUSH:-1}"

# ETCD register service settings
REGISTER_ETCD_PARAMETERS="${REGISTER_ETCD_PARAMETERS:-}"
REGISTER_TTL="${REGISTER_TTL:-60}"
Expand Down
3 changes: 3 additions & 0 deletions src/opt/scmi/service-unit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ readonly SERVICE_UNIT_ENVIRONMENT_KEYS="
MEMCACHED_CACHESIZE
MEMCACHED_MAXCONN
MEMCACHED_OPTIONS
SYSCTL_NET_CORE_SOMAXCONN
SYSCTL_NET_IPV4_IP_LOCAL_PORT_RANGE
SYSCTL_NET_IPV4_ROUTE_FLUSH
"
readonly SERVICE_UNIT_REGISTER_ENVIRONMENT_KEYS="
REGISTER_ETCD_PARAMETERS
Expand Down

0 comments on commit e723c83

Please sign in to comment.