Deploy Elastic search on Kubernetes

4/25/2018

I have pulled a ES image and run that in a host. It works fine.

 docker pull elasticsearch
 docker run -t  -p 9200:9200 -p 9300:9300 --rm elasticsearch

I need to have the same ES image in the kubernetes.

I have created a kubernetes cluster as below:

gcloud container clusters create elasticsearch --num-nodes=1

I have written a manifest file(elasticsearch.yaml) as below:

apiVersion: v1
kind: ReplicationController
metadata:
  name: elasticsearch
spec:
  replicas: 2
  selector:
    app: elasticsearch
  template:
    metadata:
      name: elasticsearch
      labels:
        app: elasticsearch
    spec:
       containers:
         - name: elasticsearch
           image: elasticsearch
           ports:
             - containerPort: 9200
             - containerPort: 9300

Created a rc as below:

kubectl create -f elasticsearch.yaml

kubectl get pods

it shows imagebackoff error

kubectl get rc

it shows as not ready

How to deploy this ES image in Kubernetes with 2 pods in one server cluster

-- soundararajan.c
google-cloud-platform
kubectl
kubernetes

2 Answers

4/25/2018

Well, the official image for ES

docker pull docker.elastic.co/elasticsearch/elasticsearch:6.2.4

as the documentation is mentioning. https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html

If you use just elasticsearch, kubernetes will assume that you're using a local registry and I guess you don't want to do that.

Also if you run

kubectl describe pods <POD_NAME>

you can easily find if there's an issue pulling the image or not. If there're no issues with pulling the image, them most probably there's an issue inside the pods. My suggestion would be, use the log command to check what's going on.

-- Idir Ouhab Meskine
Source: StackOverflow

4/26/2018

In your manifest elasticsearch.yaml, you need to specify the version of the ES image:

...
spec:
       containers:
         - name: elasticsearch
           image: elasticsearch:5.6.9
-- Nicola Ben
Source: StackOverflow