简体   繁体   English

如何永久更改 GKE 主机节点上的 sysctl 设置?

[英]How to permanently change sysctl settings on a GKE host node?

We have a kubernetes cluster running in Google GKE.我们有一个在 Google GKE 中运行的 kubernetes 集群。 I want to permanently set another value for fs.aio-max-nr in sysctl, but it keeps changing back to default after running sudo reboot .我想在 sysctl 中为fs.aio-max-nr永久设置另一个值,但在运行sudo reboot后它不断变回默认值。

This is what I've tried:这是我尝试过的:

  • sysctl -w fs.aio-max-nr=1048576
  • echo 'fs.aio-max-nr = 1048576' | sudo tee --append /etc/sysctl.d/99-gke-defaults.conf
  • echo 'fs.aio-max-nr = 1048576' | sudo tee --append /etc/sysctl.d/00-sysctl.conf

Is it possible to change this permanently?是否可以永久更改此设置? And why isn't there a etc/sysctl.config but two sysctl files in sysctl.d/ folder?为什么在sysctl.d/文件夹中没有etc/sysctl.config但有两个 sysctl 文件?

I'd do this by deploying a DaemonSet on all the nodes on which you need this setting.我会通过在需要此设置的所有节点上部署 DaemonSet 来做到这一点。 The only drawback here is that the DaemonSet pod will need to run with elevated privileges.这里唯一的缺点是 DaemonSet pod 需要以提升的权限运行。 The container has access to /proc on the host, so then you just need to execute your sysctl commands in a script and then exit.容器可以访问主机上的/proc ,因此您只需在脚本中执行sysctl命令然后退出。

apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: sysctl
spec:
  template:
    spec:
      containers:
        - name: sysctl
          image: alpine
          command:
            - /bin/sh
            - -c
            - sysctl fs.aio-max-nr=1048576
          securityContext:
            privileged: true

There's also example here . 这里也有例子。

I ended up switching node image from Googles default image cos_containerd to ubuntu containerd.我最终将节点图像从 Google 的默认图像 cos_containerd 切换到 ubuntu containerd。 This made the sysctl changes permanent.这使得 sysctl 更改永久化。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM