Deploying Elasticsearch Operator

Elasticsearch is a highly scalable open source full-text search and analytics engine. Elasticsearch allows you to store, search, and analyze big volumes of data quickly. In this recipe, we will use it to store Kubernetes logs.

Let's perform the following steps to get Elastic Cloud on Kubernetes (ECKdeployed:

  1. Deploy Elasticsearch Operator and its CRDs using the following command:
$ kubectl apply -f https://download.elastic.co/downloads/eck/1.0.0/all-in-one.yaml
  1. Elasticsearch Operator will create its own CustomResourceDefinition (CRD). We will use this CRD later to deploy and manage Elasticsearch instances on Kubernetes. List the new CRDs using the following command:
$ kubectl get crds |grep elastic.co
apmservers.apm.k8s.elastic.co 2019-11-25T07:52:16Z
elasticsearches.elasticsearch.k8s.elastic.co 2019-11-25T07:52:17Z
kibanas.kibana.k8s.elastic.co 2019-11-25T07:52:17Z
  1. Create a new namespace called logging:
$ kubectl create ns logging
  1. Create Elasticsearch using the default parameters in the logging namespace using the following command:
$ cat <<EOF | kubectl apply -f -
apiVersion: elasticsearch.k8s.elastic.co/v1beta1
kind: Elasticsearch
metadata:
name: elasticsearch
namespace: logging
spec:
version: 7.4.2
nodeSets:
- name: default
count: 3
config:
node.master: true
node.data: true
node.ingest: true
node.store.allow_mmap: false
EOF
  1. Get the status of the Elasticsearch nodes:
$ kubectl get elasticsearch -n logging
NAME HEALTH NODES VERSION PHASE AGE
elasticsearch green 3 7.4.2 Ready 86s
  1. You can also confirm the pod's status in the logging namespace using the following command:
$ kubectl get pods -n logging
NAME READY STATUS RESTARTS AGE
elasticsearch-es-default-0 1/1 Running 0 2m24s
elasticsearch-es-default-1 1/1 Running 0 2m24s
elasticsearch-es-default-2 1/1 Running 0 2m24s

A three-node Elasticsearch cluster will be created. By default, the nodes we created here are all of the following types: master-eligible, data, and ingest. As your Elasticsearch cluster grows, it is recommended to create dedicated master-eligible, data, and ingest nodes.