Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set vm.max_map_count on cluster nodes

I try to install ElasticSearch (latest) on a cluster nodes on Google Container Engine but ElasticSearch needs the variable : vm.max_map_count to be >= 262144.

If I ssh to every nodes and I manually run :

sysctl -w vm.max_map_count=262144

All goes fine then, but any new node will not have the specified configuration.

So my questions is :

Is there a way to load a system configuration on every nodes at boot time ? Deamon Set would not be the good solution because inside a docker container, the system variables are read-only.

I'm using a fresh created cluster with the gci node image.

like image 561
Romain Avatar asked Dec 22 '16 08:12

Romain


People also ask

What is VM max map count?

The maximum map count check checks that the kernel allows a process to have at least 262,144 memory-mapped areas and is enforced on Linux only. To pass the maximum map count check, you must configure vm. max_map_count via sysctl to be at least 262144 .


1 Answers

I found another solution while looking at this repository.

It relies on the use of an init container, the plus side is that only the init container is running with privileges:

annotations:
    pod.beta.kubernetes.io/init-containers: '[
      {
      "name": "sysctl",
        "image": "busybox",
        "imagePullPolicy": "IfNotPresent",
        "command": ["sysctl", "-w", "vm.max_map_count=262144"],
        "securityContext": {
          "privileged": true
        }
      }
    ]'

There is a new syntax available since Kubernetes 1.6 which still works for 1.7. Starting with 1.8 this new syntax is required. The declaration of init containers is moved to spec:

  - name: init-sysctl
    image: busybox
    command:
    - sysctl
    - -w
    - vm.max_map_count=262144
    imagePullPolicy: IfNotPresent
    securityContext:
      privileged: true
like image 54
R3DL Avatar answered Sep 18 '22 13:09

R3DL