bitnami – Setting vm.max_map_count with busybox in Kubernetes?

I need to ask the same question here since it was closed. I appreciate it if you don’t close it because Kubernetes community is bigger here on StackOverFlow and similar questions opened earlier but they were not closed. I appreciate your understanding.

When running sysctl command as an init container in my MongoDB cluster. I noticed some people had this issue but their suggestions didn’t help me. Any ideas to fix this?

    initContainers:
      - name: sysctl
        image: busybox
        command: ['sysctl', '-w', 'vm.max_map_count=1677720']
        securityContext:
          privileged: true

Output:

Error: sysctl: error setting key 'vm.max_map_count': Permission denied

Noticed the following securityContext of the statefulset. If I update them that may fix the problem but I don’t want to have any security breaches either. What would be the best practise for that?

securityContext:                                                                                             
  allowPrivilegeEscalation: false                                                                                   
  readOnlyRootFilesystem: true

Reference posts that didn’t help:

I think this question is Kubernetes/security context related which can be asked here due to K8s community on StackOverFlow

Read more here: Source link