You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在Google Cloud Kubernetes部署Elasticsearch6遇CrashLoopBackOff故障求助

Fixing Elasticsearch6 CrashLoopBackOff on Google Cloud GKE (f1-micro Nodes)

What's Causing the Crash?

Looking at your kubectl describe pod output, the key clue is the Exit Code: 137—this means your Elasticsearch container was killed by the Linux Out-of-Memory (OOM) Killer.

The f1-micro machine type only has ~614MB of total memory, and a chunk of that is already used by the Kubernetes node's OS and system processes. Elasticsearch defaults to a JVM heap size that's too large for this tiny instance, so the kernel kills the container as soon as it tries to allocate more memory than is available. That's why you're getting no logs—Elasticsearch doesn't even have time to start logging before it's terminated.

Step-by-Step Fixes

1. Tune Elasticsearch JVM Heap Size

First, limit the JVM heap memory Elasticsearch uses to fit within the node's available resources. Add the ES_JAVA_OPTS environment variable to your Pod spec to set a smaller heap (256MB is a safe start for f1-micro).

2. Set Kubernetes Resource Requests & Limits

Explicitly define memory/CPU requests and limits to ensure Kubernetes allocates enough resources to the container and prevents it from starving other processes.

Here's your updated pod.yml with both changes:

apiVersion: v1
kind: Pod
metadata:
  name: test-elasticsearch
  labels:
    name: test-elasticsearch
spec:
  containers:
  - image: launcher.gcr.io/google/elasticsearch6
    name: elasticsearch
    env:
    - name: ES_JAVA_OPTS
      value: "-Xms256m -Xmx256m"
    resources:
      requests:
        memory: "512Mi"
        cpu: "200m"
      limits:
        memory: "512Mi"
        cpu: "500m"

3. (Better Long-Term Fix) Upgrade to a Larger Machine Type

If you plan to use Elasticsearch for anything beyond testing, f1-micro is way too under-resourced. Consider recreating your cluster with a larger machine type like g1-small (1.7GB memory) which will give Elasticsearch enough room to run without memory pressure:

gcloud container clusters create elasticsearch-cluster --machine-type=g1-small --num-nodes=3

How to Apply the Fix

  1. Delete the existing problematic Pod:
kubectl delete pod test-elasticsearch
  1. Apply the updated Pod spec:
kubectl create -f pod.yml
  1. Check the Pod status after a minute:
kubectl get pods

You should see the status change to Running once the container starts successfully.

内容的提问来源于stack exchange,提问作者Fabian

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 07:35:12