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

1.4k views Asked by At

Previously my kubernetes pod was running as root and I was running ulimit -l <MLOCK_AMOUNT> in its startup script before starting its main program in foreground. However, I can no more run my pod as root, would you please know how can I set this limit now?

2

There are 2 answers

0
mario On BEST ANSWER

To be able to set it per specific Pod, the way you did it before, unfortunatelly you need privilege escalation i.e. run your container as root.

As far as I understand you're interested in setting it only per specific Pod, not globally, right ? Because it can be done by changing docker configuration on a specific kubernetes node.

This topic has already been raised in 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

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