在集群节点上设置vm.max_map_count

Rom*_*ain 4 elasticsearch kubernetes google-kubernetes-engine

我尝试在Google Container Engine上的群集节点上安装ElasticSearch(最新),但ElasticSearch需要变量:vm.max_map_countto> = 262144.

如果我ssh到每个节点,我手动运行:

sysctl -w vm.max_map_count=262144
Run Code Online (Sandbox Code Playgroud)

一切顺利,但任何新节点都没有指定的配置.

所以我的问题是:

有没有办法在启动时在每个节点上加载系统配置?Deamon Set不是一个好的解决方案,因为在docker容器中,系统变量是只读的.

我正在使用带有gci节点映像的全新集群.

R3D*_*3DL 10

我在查看此存储库时找到了另一种解决方案.

它依赖于使用init容器,正面是只有init容器以特权运行:

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

自Kubernetes 1.6以来,有一种新的语法可用于1.7.从1.8开始,这个新语法是必需的.init容器的声明被移动到spec:

  - name: init-sysctl
    image: busybox
    command:
    - sysctl
    - -w
    - vm.max_map_count=262144
    imagePullPolicy: IfNotPresent
    securityContext:
      privileged: true
Run Code Online (Sandbox Code Playgroud)


Rob*_*ley 4

您应该能够使用 DaemonSet 来模拟启动脚本的行为。如果脚本需要在节点上执行根级别操作,您可以将 DaemonSet Pod 配置为在特权模式下运行。

有关如何执行此操作的示例,请参阅https://github.com/kubernetes/contrib/tree/master/startup-script