Set vm.max_map_count on cluster nodes

前端 未结 3 631
面向向阳花
面向向阳花 2020-12-19 08:18

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.

3条回答
  •  庸人自扰
    2020-12-19 08:54

    As Robert pointed out, a DaemonSet could run as a startup script. Unfortunately, GKE will only let you run a DaemonSet with restartPolicy set as Always.

    So in order to prevent k8s to continually restart the container after running sysctl, it has to sleep after the setup and preferably just run on selected nodes. It isn't an elegant solution, but it's elastic at least.

    Example:

    es-host-setup Dockerfile:

    FROM alpine
    CMD sysctl -w vm.max_map_count=262144; sleep 365d
    

    DaemonSet resource file:

    apiVersion: extensions/v1beta1
    kind: DaemonSet
    metadata:
      name: es-host-setup
    spec:
      template:
        metadata:
          labels:
            name: es-host-setup
        spec:
          containers:
          - name: es-host-setup
            image: es-host-setup
            securityContext:
              privileged: true
          restartPolicy: Always
          nodeSelector:
            pool: elasticsearch
    

提交回复
热议问题