KubeBlocks
BlogsKubeBlocks Cloud
⌘K
​
Overview
Quickstart

Operations

Lifecycle Management
Vertical Scaling
Horizontal Scaling
Volume Expansion
Manage Elasticsearch Services
Decommission Elasticsearch Replica

Monitoring

Observability for Elasticsearch Clusters

tpl

  1. Prerequisites
    1. System Requirements
    2. Verify Elasticsearch Add-on
  2. Deploy a Elasticsearch Cluster
  3. Verify Cluster Status
  4. Stop the Elasticsearch Cluster
  5. Start the Elasticsearch Cluster
  6. Delete Elasticsearch Cluster

Elasticsearch Quickstart

This guide provides a comprehensive walkabout for deploying and managing Elasticsearch ReplicaSet Clusters using the KubeBlocks Elasticsearch Add-on, covering:

  • System prerequisites and add-on installation
  • Cluster creation and configuration
  • Operational management including start/stop procedures
  • Connection methods and cluster monitoring

Prerequisites

System Requirements

Before proceeding, verify your environment meets these requirements:

  • A functional Kubernetes cluster (v1.21+ recommended)
  • kubectl v1.21+ installed and configured with cluster access
  • Helm installed (installation guide)
  • KubeBlocks installed (installation guide)

Verify Elasticsearch Add-on

The Elasticsearch Add-on is included with KubeBlocks by default. Check its status:

helm list -n kb-system | grep elasticsearch
Example Output:
NAME NAMESPACE REVISION UPDATED STATUS CHART kb-addon-elasticsearch kb-system 1 2025-05-21 deployed elasticsearch-1.0.0

If the add-on isn't enabled, choose an installation method:

# Add Helm repo helm repo add kubeblocks-addons https://apecloud.github.io/helm-charts # For users in Mainland China, if GitHub is inaccessible or slow, use this alternative repo: #helm repo add kubeblocks-addons https://jihulab.com/api/v4/projects/150246/packages/helm/stable # Update helm repo helm repo update # Search available Add-on versions helm search repo kubeblocks/elasticsearch --versions # Install your desired version (replace <VERSION> with your chosen version) helm upgrade -i kb-addon-elasticsearch kubeblocks-addons/elasticsearch --version <VERSION> -n kb-system
# Add an index (kubeblocks is added by default) kbcli addon index add kubeblocks https://github.com/apecloud/block-index.git # Update the index kbcli addon index update kubeblocks # Update all indexes kbcli addon index update --all

To search and install an addon:

# Search Add-on kbcli addon search elasticsearch # Install Add-on with your desired version (replace <VERSION> with your chosen version) kbcli addon install elasticsearch --version <VERSION>

Example Output:

ADDON VERSION INDEX elasticsearch 0.9.0 kubeblocks elasticsearch 0.9.1 kubeblocks elasticsearch 1.0.0 kubeblocks

To enable or disable an addon:

# Enable Add-on kbcli addon enable elasticsearch # Disable Add-on kbcli addon disable elasticsearch
NOTE

Version Compatibility

Always verify that the Elasticsearch Add-on version matches your KubeBlocks major version to avoid compatibility issues.

Deploy a Elasticsearch Cluster

For development and testing purposes, you can deploy a single-node cluster where one node handles all roles.

kubectl apply -f https://raw.githubusercontent.com/apecloud/kubeblocks-addons/refs/heads/main/examples/elasticsearch/cluster-single-node.yaml

This creates:

  • A Elasticsearch Cluster with 1 component, where one replica handles all roles.
  • Default resource allocations (1 CPU, 2Gi memory)
  • 20Gi persistent storage
apiVersion: apps.kubeblocks.io/v1 kind: Cluster metadata: name: es-singlenode namespace: demo spec: terminationPolicy: Delete componentSpecs: - name: mdit componentDef: elasticsearch-8 serviceVersion: 8.8.2 replicas: 1 configs: - name: es-cm variables: mode: "single-node" resources: limits: cpu: "1" memory: "2Gi" requests: cpu: "1" memory: "2Gi" volumeClaimTemplates: - name: data spec: accessModes: - ReadWriteOnce resources: requests: storage: 20Gi

For more API fields and descriptions, refer to the API Reference.

Verify Cluster Status

When deploying a Elasticsearch Cluster with 1 replicas:

Confirm successful deployment by checking:

  1. Cluster phase is Running
  2. All pods are operational

Check status using either method:

kubectl get cluster es-singlenode -n demo -w NAME CLUSTER-DEFINITION TERMINATION-POLICY STATUS AGE es-singlenode Delete Running 49s kubectl get pods -l app.kubernetes.io/instance=es-singlenode -n demo NAME READY STATUS RESTARTS AGE es-singlenode-mdit-0 3/3 Running 0 58s

With kbcli installed, you can view comprehensive cluster information:

kbcli cluster describe es-singlenode -n demo Name: es-singlenode Created Time: May 19,2025 20:34 UTC+0800 NAMESPACE CLUSTER-DEFINITION TOPOLOGY STATUS TERMINATION-POLICY demo Running Delete Endpoints: COMPONENT INTERNAL EXTERNAL mdit es-singlenode-mdit-http.demo.svc.cluster.local:9200 <none> Topology: COMPONENT SERVICE-VERSION INSTANCE ROLE STATUS AZ NODE CREATED-TIME mdit 8.8.2 es-singlenode-mdit-0 <none> Running <none> kbv10-control-plane/172.19.0.2 May 19,2025 20:34 UTC+0800 Resources Allocation: COMPONENT INSTANCE-TEMPLATE CPU(REQUEST/LIMIT) MEMORY(REQUEST/LIMIT) STORAGE-SIZE STORAGE-CLASS mdit 1 / 1 2Gi / 2Gi data:20Gi standard Images: COMPONENT COMPONENT-DEFINITION IMAGE mdit elasticsearch-8-1.0.0 docker.io/library/elasticsearch:8.8.2 docker.io/prometheuscommunity/elasticsearch-exporter:v1.7.0 docker.io/apecloud/curl-jq:0.1.0 Data Protection: BACKUP-REPO AUTO-BACKUP BACKUP-SCHEDULE BACKUP-METHOD BACKUP-RETENTION RECOVERABLE-TIME Show cluster events: kbcli cluster list-events -n demo es-singlenode

Stop the Elasticsearch Cluster

Stopping a cluster temporarily suspends operations while preserving all data and configuration:

Key Effects:

  • Compute resources (Pods) are released
  • Persistent storage (PVCs) remains intact
  • Service definitions are maintained
  • Cluster configuration is preserved
  • Operational costs are reduced
apiVersion: operations.kubeblocks.io/v1alpha1 kind: OpsRequest metadata: name: elasticsearch-stop namespace: demo spec: clusterName: es-singlenode type: Stop

Alternatively, stop by setting spec.componentSpecs.stop to true:

kubectl patch cluster es-singlenode -n demo --type='json' -p='[ { "op": "add", "path": "/spec/componentSpecs/0/stop", "value": true }

Start the Elasticsearch Cluster

Restarting a stopped cluster resumes operations with all data and configuration intact.

Key Effects:

  • Compute resources (Pods) are recreated
  • Services become available again
  • Cluster returns to previous state
apiVersion: operations.kubeblocks.io/v1alpha1 kind: OpsRequest metadata: name: elasticsearch-start namespace: demo spec: clusterName: es-singlenode type: Start

Restart by setting spec.componentSpecs.stop to false:

kubectl patch cluster es-singlenode -n demo --type='json' -p='[ { "op": "remove", "path": "/spec/componentSpecs/0/stop" }

Delete Elasticsearch Cluster

Choose carefully based on your data retention needs:

PolicyResources RemovedData RemovedRecommended For
DoNotTerminateNoneNoneCritical production clusters
DeleteAll resourcesPVCs deletedNon-critical environments
WipeOutAll resourcesEverything*Test environments only

*Includes snapshots and backups in external storage

Pre-Deletion Checklist:

  1. Verify no applications are using the cluster
  2. Ensure required backups exist
  3. Confirm proper terminationPolicy is set
  4. Check for dependent resources

For test environments, use this complete cleanup:

kubectl patch cluster es-singlenode -p '{"spec":{"terminationPolicy":"WipeOut"}}' --type="merge" -n demo kubectl delete cluster es-singlenode -n demo

© 2025 ApeCloud PTE. Ltd.