<p>I am running my elixir app on GKE</p>

<p>here is my deployment configuration:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: myapp
  namespace: production
spec:
  replicas: 1
  revisionHistoryLimit: 1
  strategy:
      type: RollingUpdate
  template:
    metadata:
      labels:
        app: myapp
        tier: backend
    spec:
      securityContext:
        runAsUser: 0
        runAsNonRoot: false
      containers:
      - name: myapp
        image: myimage
        resources:
          limits:
            cpu: 3000m
            memory: 2000Mi
          requests:
            cpu: 2500m
            memory: 1000Mi
        ports:
        - containerPort: 80
        args:
          - foreground
</code></pre>

<p>as you can see in the image, the pod reached its memory limit and crashed
<a href="https://i.stack.imgur.com/nbiwR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nbiwR.png" alt="pod"></a></p>

<p>these are my last logs:</p>

<pre><code>erl_child_setup closed

Crash dump is being written to: erl_crash.dump...done

Shutting down..

Node is not running!
</code></pre>

<p>and then my app is frozen, I get 502 when trying to request the app,</p>

<p>In order to restart I restart the pod (kubectl delete pod), and then it runs again,</p>

<p>my question is: why doesnt the pod restart automatically when reaches memory limit?</p>

dina
<p>You'll need to add probes that will check if your application is healthy.</p>

<p>Since you mentioned a <code>502</code>, I'm assuming this is a Phoenix application and you can add a health-check endpoint:</p>

<pre><code>livenessProbe:
  httpGet:
    path: /healthz
    port: 8080
  initialDelaySeconds: 3
  periodSeconds: 3
</code></pre>

<p>When this request stops receiving a <code>200</code>, then the Kubernetes Controller will restart your pod.</p>
