Memory locking requested for elasticsearch process but memory is not locked

i am enabling bootstrap.memory_lock: true on kubrnetes deployment of elastic multi node cluster. getting below error.

Tried with this one

#Set memlock limit
      - name: memlock-limit
        image: busybox
        imagePullPolicy: IfNotPresent
        command: ["sh", "-c", "ulimit -l unlimited"]
        securityContext:
          privileged: true
# Increase the max number of open file descriptors.
      - name: increase-fd-ulimit
        image: busybox
        imagePullPolicy: IfNotPresent
        command: ["sh", "-c", "ulimit -n 65536"]
        securityContext:
          privileged: true

Then tried doing it with adding in limits.conf file
elasticsearch soft memlock unlimited

elasticsearch hard memlock unlimited 

still getting below error on logs


ERROR: [1] bootstrap checks failed. You must address the points described in the following [1] lines before starting Elasticsearch.
bootstrap check failure [1] of [1]: memory locking requested for elasticsearch process but memory is not locked
ERROR: Elasticsearch did not exit normally - check the logs at /usr/share/elasticsearch/logs/elasticsearch.log
{"type": "server", "timestamp": "2022-05-13T08:15:55,875Z", "level": "INFO", "component": "o.e.n.Node", "cluster.name": "elasticsearch", "node.name": "es-master", "message": "stopping ..." }

I am not able to access the /usr/share/Elasticsearch/logs/Elasticsearch.log as container gets killed

{"@timestamp":"2022-05-16T01:48:17.969Z", "log.level": "WARN", "message":"Unable to lock JVM Memory: error=12, reason=Cannot allocate memory", "ecs.version": "1.2.0","service.name":"ES_ECS","event.dataset":"elasticsearch.server","process.thread.name":"main","log.logger":"org.elasticsearch.bootstrap.JNANatives","elasticsearch.node.name":"es-master","elasticsearch.cluster.name":"elasticsearch"}
{"@timestamp":"2022-05-16T01:48:17.975Z", "log.level": "WARN", "message":"This can result in part of the JVM being swapped out.", "ecs.version": "1.2.0","service.name":"ES_ECS","event.dataset":"elasticsearch.server","process.thread.name":"main","log.logger":"org.elasticsearch.bootstrap.JNANatives","elasticsearch.node.name":"es-master","elasticsearch.cluster.name":"elasticsearch"}
{"@timestamp":"2022-05-16T01:48:17.976Z", "log.level": "WARN", "message":"Increase RLIMIT_MEMLOCK, soft limit: 65536, hard limit: 65536", "ecs.version": "1.2.0","service.name":"ES_ECS","event.dataset":"elasticsearch.server","process.thread.name":"main","log.logger":"org.elasticsearch.bootstrap.JNANatives","elasticsearch.node.name":"es-master","elasticsearch.cluster.name":"elasticsearch"}
{"@timestamp":"2022-05-16T01:48:17.976Z", "log.level": "WARN", "message":"These can be adjusted by modifying /etc/security/limits.conf, for example:\n\t# allow user 'elasticsearch' mlockall\n\telasticsearch soft memlock unlimited\n\telasticsearch hard memlock unlimited", "ecs.version": "1.2.0","service.name":"ES_ECS","event.dataset":"elasticsearch.server","process.thread.name":"main","log.logger":"org.elasticsearch.bootstrap.JNANatives","elasticsearch.node.name":"es-master","elasticsearch.cluster.name":"elasticsearch"}