如何将 pod 运行 中的最大锁定内存设置为非 root

How to set max locked memory in a pod running as non root

以前我的 kubernetes pod 是 运行ning 作为 root,我是 运行ning ulimit -l <MLOCK_AMOUNT> 在它的启动脚本中,然后在前台启动它的主程序。但是,我不能再 运行 我的 pod 作为 root,请问我现在如何设置这个限制?

kind: Pod
....
spec:
  containers:
  - name: prc
    image: prc/stable
    resources:
      limits:
        memory: "1Gi"
      requests:
        memory: "200Mi"

为了能够按照特定 Pod 进行设置,不幸的是,您需要提升权限,即 运行 您的容器作为 root。

据我了解,您有兴趣仅根据特定 Pod 设置它,而不是全局设置,对吧?因为它可以通过更改特定 kubernetes 节点上的 docker 配置来完成。

此主题已在 another thread and as you may read in James Brown's answer 中提出:

It appears that you can't currently set a ulimit but it is an open issue: https://github.com/kubernetes/kubernetes/issues/3595