githubEdit

How do I set kernel parameters for containerized services that require specific host settings?

Context Some containerized applications, like SonarQube, require specific kernel parameters to be set on the host system to function properly. For example, SonarQube needs vm.max_map_count=262144 to be set. When services are deployed across different hosts in a container orchestration environment, manually setting these parameters on each host is not scalable or reliable. Answer The best approach is to use an init container that sets the required kernel parameter before your main application starts. This ensures the parameter is set automatically on whatever host the service lands on, every time it's deployed. In DuploCloud, you can add an init container by configuring the service's Other Docker Config field with the following JSON: { "initContainers": [ { "name": "set-sysctl", "image": "busybox", "securityContext": { "privileged": true }, "command": ["sh", "-c", "sysctl -w vm.max_map_count=262144"] } ] } This configuration: Creates an init container that runs before your main application container Uses a lightweight busybox image Runs with privileged access to modify kernel parameters Sets the required vm.max_map_count parameter After adding this configuration, redeploy your service. The init container will automatically set the kernel parameter on the host before your application starts, eliminating the need for manual host configuration. This is the most container-native approach and requires zero host management while ensuring your service works correctly regardless of which host it's scheduled on.

Last updated

Was this helpful?