# Not able to create elasticsearch on Azure aks

**URL:** <https://discuss.elastic.co/t/not-able-to-create-elasticsearch-on-azure-aks/302057>\
**Category:** Elastic Cloud on Kubernetes (ECK)\
**Tags:** docker\
**Created:** [April 10, 2022, 5:40pm UTC](https://discuss.elastic.co/t/not-able-to-create-elasticsearch-on-azure-aks/302057 "2022-04-10T17:40:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Srinivas\_RK](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/srinivas_rk/32/83303_2.png) [@Srinivas\_RK](https://discuss.elastic.co/u/Srinivas_RK)\
**Post date:** [April 10, 2022, 5:40pm UTC](https://discuss.elastic.co/t/not-able-to-create-elasticsearch-on-azure-aks/302057/1 "2022-04-10T17:40:09Z")

</div>

Im trying to create Elasticsearch on azure Kubernetes service (v 1.20.13) using eck version (1.8.0)

here is my kubernetes deployment script

```auto
apiVersion: elasticsearch.k8s.elastic.co/v1

kind: Elasticsearch

metadata:

  name: banana-elastic-depl

spec:

  version: 8.1.2

  nodeSets:

    - name: master-nodes

      count: 1

      config:

        node.roles: ["master"]

      podTemplate:

        spec:

          containers:

            - name: default

              env: #java run time memory allocation

                - name: ES_JAVA_OPTS

                  value: -Xms2g -Xmx2g

          initContainers: #make pod ready for prod mode elastic run

            - name: sysctl

              securityContext:

                privileged: true

              command: ["sh", "-c", "sysctl -w vm.max_map_count=262144"]

      volumeClaimTemplates: #persistent stoarage

        - metadata:

            name: elasticsearch-data

          spec:

            accessModes:

              - ReadWriteOnce

            resources:

              requests:

                storage: 16Gi

            storageClassName: default

    - name: data-nodes

      count: 1

      config:

        node.roles: ["data"]

      volumeClaimTemplates: #persistent stoarage

        - metadata:

            name: elasticsearch-data

          spec:

            accessModes:

              - ReadWriteOnce

            resources:

              requests:

                storage: 64Gi

            storageClassName: default

      podTemplate:

        spec:

          containers:

            - name: elasticsearch

              env: #java run time memory allocation

                - name: ES_JAVA_OPTS

                  value: -Xms2g -Xmx2g

              resources:

                requests:

                  memory: 12Gi

                  cpu: 3

                limits:

                  memory: 16Gi

                  cpu: 4

          initContainers: #make pod ready for prod mode elastic run

            - name: sysctl

              securityContext:

                privileged: true

              command: ["sh", "-c", "sysctl -w vm.max_map_count=262144"]

```

this script is giving error while creating elastichsearch

`{"@timestamp":"2022-04-10T17:06:27.441Z", "log.level": "INFO", "message":"JVM arguments [-Xshare:auto, -Des.networkaddress.cache.ttl=60, -Des.networkaddress.cache.negative.ttl=10, -Djava.security.manager=allow, -XX:+AlwaysPreTouch, -Xss1m, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djna.nosys=true, -XX:-OmitStackTraceInFastThrow, -XX:+ShowCodeDetailsInExceptionMessages, -Dio.netty.noUnsafe=true, -Dio.netty.noKeySetOptimization=true, -Dio.netty.recycler.maxCapacityPerThread=0, -Dio.netty.allocator.numDirectArenas=0, -Dlog4j.shutdownHookEnabled=false, -Dlog4j2.disable.jmx=true, -Dlog4j2.formatMsgNoLookups=true, -Djava.locale.providers=SPI,COMPAT, --add-opens=java.base/java.io=ALL-UNNAMED, -XX:+UseG1GC, -Djava.io.tmpdir=/tmp/elasticsearch-16531016403921520044, -XX:+HeapDumpOnOutOfMemoryError, -XX:+ExitOnOutOfMemoryError, -XX:HeapDumpPath=data, -XX:ErrorFile=logs/hs_err_pid%p.log, -Xlog:gc*,gc+age=trace,safepoint:file=logs/gc.log:utctime,pid,tags:filecount=32,filesize=64m, -Des.cgroups.hierarchy.override=/, -Xms2g, -Xmx2g, -XX:MaxDirectMemorySize=1073741824, -XX:G1HeapRegionSize=4m, -XX:InitiatingHeapOccupancyPercent=30, -XX:G1ReservePercent=15, -Des.path.home=/usr/share/elasticsearch, -Des.path.conf=/usr/share/elasticsearch/config, -Des.distribution.flavor=default, -Des.distribution.type=docker, -Des.bundled_jdk=true]", "ecs.version": "1.2.0","service.name":"ES_ECS","event.dataset":"elasticsearch.server","process.thread.name":"main","log.logger":"org.elasticsearch.node.Node","elasticsearch.node.name":"banana-elastic-depl-es-data-nodes-0","elasticsearch.cluster.name":"banana-elastic-depl"}`

am i missing something?

regards

---

<div class="post-metadata">

**Author:** ![michael.morello](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michael.morello/32/47448_2.png) [@michael.morello](https://discuss.elastic.co/u/michael.morello)\
**Post date:** [April 11, 2022, 6:32am UTC](https://discuss.elastic.co/t/not-able-to-create-elasticsearch-on-azure-aks/302057/2 "2022-04-11T06:32:29Z")

</div>

Hi,

There is no error in your log. Since you are using Elasticsearch 8.0 and you want to manage `vm.max_map_count` using an init container could you also set `runAsUser: 0` in the `securityContext ` ? See a [full example in the documentation](https://www.elastic.co/guide/en/cloud-on-k8s/current/k8s-virtual-memory.html#k8s-virtual-memory).

Thanks

---

<div class="post-metadata">

**Author:** ![Srinivas\_RK](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/srinivas_rk/32/83303_2.png) [@Srinivas\_RK](https://discuss.elastic.co/u/Srinivas_RK)\
**Post date:** [April 11, 2022, 10:30am UTC](https://discuss.elastic.co/t/not-able-to-create-elasticsearch-on-azure-aks/302057/3 "2022-04-11T10:30:26Z")

</div>

Thank you michael adding this worked. also slightly modified my deployment yaml

```auto
apiVersion: elasticsearch.k8s.elastic.co/v1

kind: Elasticsearch

metadata:

  name: banana-elastic-depl

spec:

  version: 8.1.2

  nodeSets:

    - name: master-nodes

      count: 1

      config:

        node.roles: ["master"]

      volumeClaimTemplates: #persistent stoarage

        - metadata:

            name: elasticsearch-data

          spec:

            accessModes:

              - ReadWriteOnce

            resources:

              requests:

                storage: 16Gi

            storageClassName: default

    - name: data-nodes

      count: 1

      config:

        node.roles: ["data"]

      volumeClaimTemplates: #persistent stoarage

        - metadata:

            name: elasticsearch-data

          spec:

            accessModes:

              - ReadWriteOnce

            resources:

              requests:

                storage: 64Gi

            storageClassName: default

      podTemplate:

        spec:

          containers:

            - name: elasticsearch

              env: #java run time memory allocation

                - name: ES_JAVA_OPTS

                  value: -Xms2g -Xmx2g

              resources:

                requests:

                  memory: 12Gi

                  cpu: 3

                limits:

                  memory: 16Gi

                  cpu: 4

          initContainers: #make pod ready for prod mode elastic run

            - name: sysctl

              securityContext:

                privileged: true

                runAsUser: 0

              command: ["sh", "-c", "sysctl -w vm.max_map_count=262144"]

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [May 9, 2022, 10:30am UTC](https://discuss.elastic.co/t/not-able-to-create-elasticsearch-on-azure-aks/302057/4 "2022-05-09T10:30:41Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
