首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何提高GKE节点的`fs.inotify.max_user_watches`

如何提高GKE节点的`fs.inotify.max_user_watches`
EN

Stack Overflow用户
提问于 2022-07-12 00:11:52
回答 1查看 245关注 0票数 1

我正在尝试解决一个Error “ENOSPC: System Limit for Number of File Watchers Reached”问题;这个问题通常通过在主机环境中通过sysctl增加fs.inotify.max_user_watches值来解决。此外,我不确定部分问题是否与使用"Spot“节点有关。

不幸的是,我所有设置或覆盖此值的尝试都失败了。或者是由于缺乏权限:例如,/proc/sys/fs/inotify/max_user_watches: Read-only file system

当试图配置GKE节点本身时,linuxConfig.sysctl选项似乎不支持fs.inotify.max_user_watches

节点配置: pool.yaml

代码语言:javascript
运行
复制
kubeletConfig: {}
linuxConfig:
 sysctl:
   fs.inotify.max_user_watches: '1048576'
代码语言:javascript
运行
复制
~ gcloud container node-pools update POOL_NAME \
    --cluster=CLUSTER_NAME \
    --system-config-from-file=pool.yaml

ERROR: (gcloud.container.node-pools.update) 
ResponseError: code=400, message=Unsupported kernel parameter fs.inotify.max_user_watches.

任何帮助,专门为GKE,将不胜感激!

EN

回答 1

Stack Overflow用户

发布于 2022-07-12 00:50:08

我找到了这个答案,它使用一个DaemonSet来修改所有节点。How to change the file-system watcher limit in Kubernetes (fs.inotify.max_user_watches)

node-setup-daemon-set.yaml

代码语言:javascript
运行
复制
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: node-setup
  namespace: kube-system
  labels:
    k8s-app: node-setup
spec:
  selector:
    matchLabels:
      name: node-setup
  template:
    metadata:
      labels:
        name: node-setup
    spec:
      containers:
      - name: node-setup
        image: ubuntu
        command: ["/bin/sh","-c"]
        args: ["/script/node-setup.sh; while true; do echo Sleeping && sleep 3600; done"]
        volumeMounts:
          - name: node-setup-script
            mountPath: /script
        securityContext:
          allowPrivilegeEscalation: true
          privileged: true
      volumes:
        - name: node-setup-script
          configMap:
            name: node-setup-script
            defaultMode: 0755
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: node-setup-script
  namespace: kube-system
data:
  node-setup.sh: |
    #!/bin/bash
    set -e

    # change the file-watcher max-count on each node to 524288

    # insert the new value into the system config
    sysctl -w fs.inotify.max_user_watches=524288

    # check that the new value was applied
    cat /proc/sys/fs/inotify/max_user_watches

那就跑

代码语言:javascript
运行
复制
k apply -f node-setup-daemon-set.yaml

注意:原始线程提到了安全问题..。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72945814

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档