# Limit Elasticsearch to 512 MB on Kubernetes

**URL:** <https://discuss.elastic.co/t/limit-elasticsearch-to-512-mb-on-kubernetes/234892>\
**Category:** Elasticsearch\
**Created:** [May 29, 2020, 9:41am UTC](https://discuss.elastic.co/t/limit-elasticsearch-to-512-mb-on-kubernetes/234892 "2020-05-29T09:41:51Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![lucbas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lucbas/32/69511_2.png) [@lucbas](https://discuss.elastic.co/u/lucbas)\
**Post date:** [May 29, 2020, 9:41am UTC](https://discuss.elastic.co/t/limit-elasticsearch-to-512-mb-on-kubernetes/234892/1 "2020-05-29T09:41:52Z")

</div>

Hi all

I'm trying to set up elastic search on Kubernetes (GKE) and try to limit its memory usage to max 512MB (or even lower).  
Performance is not that crucial for us, we just need to run some Jaeger queries from time to time for tracing purposes.  
When Jaeger tried to access ES, it crashes.  
I tried to set the Heap to 256MB and the limit to 512MB in the manifest.

Currently, this is the config YAML:

```auto
apiVersion: elasticsearch.k8s.elastic.co/v1
kind: Elasticsearch
metadata:
  name: elasticsearch
spec:
  version: 7.7.0
  nodeSets:
  - name: default
    count: 1
    podTemplate:
      spec:
        containers:
        - name: elasticsearch
          env:
          - name: ES_JAVA_OPTS
            value: -Xms256m -Xmx256m
          resources:
            requests:
              memory: 512Mi
              cpu: 0.2
            limits:
              memory: 512Mi
              cpu: 0.2
    config:
      node.master: true
      node.data: true
      node.ingest: true
      node.store.allow_mmap: false

```

Would appreciate any help!

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [May 29, 2020, 11:34am UTC](https://discuss.elastic.co/t/limit-elasticsearch-to-512-mb-on-kubernetes/234892/2 "2020-05-29T11:34:10Z")

</div>

I know there ha been work on making Elasticsearch work better in low memory environments, but I do not think I have seek Elasticsearch do anything useful with less that 512MB of heap. That is the smallest I would recommend setting up.

---

<div class="post-metadata">

**Author:** ![lucbas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lucbas/32/69511_2.png) [@lucbas](https://discuss.elastic.co/u/lucbas)\
**Post date:** [May 29, 2020, 12:13pm UTC](https://discuss.elastic.co/t/limit-elasticsearch-to-512-mb-on-kubernetes/234892/3 "2020-05-29T12:13:03Z")

</div>

Hi Christian

Many thanks for your answer!

I would like to avoid reserving 1 gig for the ES container with a heap of 512 if it's possible.  
Maybe there are some tricks that could help?

Either way, the following config should be workable I assume:

```auto
apiVersion: elasticsearch.k8s.elastic.co/v1
kind: Elasticsearch
metadata:
  name: elasticsearch
spec:
  version: 7.7.0
  nodeSets:
  - name: default
    count: 1
    podTemplate:
      spec:
        containers:
        - name: elasticsearch
          env:
          - name: ES_JAVA_OPTS
            value: -Xms512m -Xmx512m
          resources:
            requests:
              memory: 1Gi
              cpu: 0.2
            limits:
              memory: 1Gi
              cpu: 0.2
    config:
      node.master: true
      node.data: true
      node.ingest: true
      node.store.allow_mmap: false

```

---

<div class="post-metadata">

**Author:** ![Mikhail\_Khludnev](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mikhail_khludnev/32/59591_2.png) [@Mikhail\_Khludnev](https://discuss.elastic.co/u/Mikhail_Khludnev)\
**Post date:** [May 29, 2020, 1:06pm UTC](https://discuss.elastic.co/t/limit-elasticsearch-to-512-mb-on-kubernetes/234892/4 "2020-05-29T13:06:12Z")

</div>

> When Jaeger tried to access ES, it crashes.

Hi,  
How it crashes specifically? Are there any messages? Does it happen inside of container, or there some logs in docker host?

---

<div class="post-metadata">

**Author:** ![lucbas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lucbas/32/69511_2.png) [@lucbas](https://discuss.elastic.co/u/lucbas)\
**Post date:** [May 29, 2020, 5:27pm UTC](https://discuss.elastic.co/t/limit-elasticsearch-to-512-mb-on-kubernetes/234892/5 "2020-05-29T17:27:19Z")

</div>

Hi Mikhail

The container does not seem to get ready due to the readiness probe. This is what the ES pod shows:

```bash
{"timestamp": "2020-05-29T16:40:20+0000", "message": "readiness probe failed", "curl_rc": "28"}
{"timestamp": "2020-05-29T16:40:51+0000", "message": "readiness probe failed", "curl_rc": "28"}

```

---

<div class="post-metadata">

**Author:** ![lucbas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lucbas/32/69511_2.png) [@lucbas](https://discuss.elastic.co/u/lucbas)\
**Post date:** [June 1, 2020, 3:51pm UTC](https://discuss.elastic.co/t/limit-elasticsearch-to-512-mb-on-kubernetes/234892/6 "2020-06-01T15:51:33Z")

</div>

When talking about resource optimizations, what is the recommended way to reduce the cpu/memory requests and limits of the ES operator?

---

<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:** [June 29, 2020, 3:51pm UTC](https://discuss.elastic.co/t/limit-elasticsearch-to-512-mb-on-kubernetes/234892/7 "2020-06-29T15:51:40Z")

</div>

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