
Deploying and managing the Elasticsearch Operator is a crucial step in setting up a scalable and efficient Elasticsearch cluster. The Operator can be deployed using a Kubernetes cluster, with the ability to manage and monitor Elasticsearch clusters directly from the Kubernetes dashboard.
The Operator provides a simple and efficient way to manage Elasticsearch clusters, automating tasks such as scaling, upgrading, and backing up. This eliminates the need for manual intervention, reducing administrative overhead and improving overall cluster reliability.
By using the Operator, you can easily manage multiple Elasticsearch clusters from a single interface, making it ideal for large-scale deployments.
A fresh viewpoint: Deploy Elasticsearch on Kubernetes
Cloud and Deployment
The Elasticsearch operator is designed to leverage Amazon AWS S3 for snapshot and restore to the elastic cluster, but it's currently limited to support additional clouds and scenarios.
You can deploy the operator to your cluster by running a simple command, but make sure to update the RBAC rules in the example/controller.yaml spec to match the namespace you want to use.
Check this out: Operator Messaging
To deploy the operator, you'll need to run the command to create an Elasticsearch cluster with a single node, which will take a minute to start. You can check the cluster health during the creation process.
Once the cluster is up and running, you can check its logs to make sure everything is working as expected. You can also expose the elasticsearch-es-http service to access the Pod from your local machine.
Base Image
The base image used for Elasticsearch in this setup is upmcenterprises/docker-elasticsearch-kubernetes:6.1.3_0. This image can be overridden when creating a custom cluster.
If you don't specify a custom image, a default image is used, as previously noted.
Cloud
The operator is currently designed to leverage Amazon AWS S3 for snapshot and restore to the elastic cluster.
This allows for seamless data management and backup in the cloud.
The goal of this project is to extend support to additional clouds and scenarios to make it fully featured.
This means we can swap out storage types and use it in GKE, but snapshots won't work at the moment.
Deploy
Deploying an Elasticsearch cluster is a straightforward process.
To deploy the Elasticsearch operator, simply deploy it to your cluster. The operator can be placed in any namespace, but be sure to update the RBAC rules in the example/controller.yaml spec to match the desired namespace.
You can install the Elasticsearch operator by running a single command. This will give you access to the elasticsearch.k8s.elastic.co/v1 API, which allows you to spin up an Elasticsearch server in no time.
To create an Elasticsearch cluster with a single node, run a specific command. Give it a minute to start, and you can check the cluster health during the creation process.
A running Elasticsearch Pod is created, tied to a StatefulSet in the default namespace, along with two Services to access the Pod. To make sure the Pod is working, check its logs.
To access the Elasticsearch Pod from your local machine, expose the elasticsearch-es-http service. A default user named elastic is automatically created with the password stored in a Kubernetes secret.
You can retrieve the password by running a specific command, and then use curl to test the endpoint. If everything is set up correctly, you should be able to access the Elasticsearch cluster without any issues.
StatefulSet
A StatefulSet is a type of Kubernetes resource that manages the deployment and scaling of stateful applications, such as Elasticsearch clusters.
You can create a StatefulSet for your Elasticsearch cluster, which will allow you to configure more fine-tuned control over your deployment.
To create a StatefulSet, you can use the kubectl command to create a Kubernetes resource, which will manage the deployment and scaling of your Elasticsearch cluster.
A StatefulSet can be used to configure things like S3 snapshots of indexes, automatic TLS, and spread loads across zones, but it may not have all the features of the Elasticsearch Operator.
Here are some benefits of using a StatefulSet:
- More fine-tuned control over deployment and scaling
- Community is used to configuring Elasticsearch clusters with StatefulSets
However, if you need more automation and features like S3 snapshots of indexes, automatic TLS, and spread loads across zones, you may want to consider using the Elasticsearch Operator instead.
Deploying Kibana
You can deploy Kibana using the Elasticsearch Operator, known as ECK. This Operator comes packaged with Kibana.
To create a Kibana instance, you'll use the kibana.k8s.elastic.co/v1 API. Specify a Kibana instance and reference your Elasticsearch cluster.
Give it a second to spin up the Pod. You can retrieve details about Kibana instances with the command kubectl get kibana.
Additional reading: Elasticsearch and Kibana
Usage and Configuration
To use the Elasticsearch Operator, you'll need to build it using the controller and custom resource definition model. This will automatically create the CustomResourceDefinition (CRD) in your cluster.
Once the CRD is created, you can deploy the Elasticsearch cluster by creating a Kubernetes object type elasticsearchCluster. This will set up the cluster based on the CRD.
Any edits you make to the configuration will automatically upgrade the cluster, but be aware that existing volume claims cannot be resized.
Make sure your Kubernetes cluster has enough resources to handle any resizing you do, as this will bump up the Pod count.
By default, the cluster allocates a persistent volume of 1 GB for storage using the default storage class defined for the Kubernetes cluster.
Worth a look: Elasticsearch Storage
Example and Tutorial
To get started with the Elasticsearch operator, you can create an example cluster on Minikube. This involves setting lower Java memory constraints, which is a common requirement for running the operator on a local machine.
Minikube uses the default storage class, which writes data to the hostPath, so keep that in mind when working with your cluster.
Create Example

To create an example ElasticSearch cluster, you can run a command on AWS, but be sure to update the zones to match your AWS account.
If you're not running on AWS, you can try other examples, but note that creating a custom cluster requires the creation of a CustomResourceDefinition, which happens automatically after the controller is created.
Running the operator on Minikube is also an option, and it sets lower Java memory constraints as well as uses the default storage class in Minikube, which writes to hostPath.
You might enjoy: Elasticsearch on Aws
Insert Sample Data to Database
We'll create a few indexes in Elasticsearch using the Kubernetes Elasticsearch operator.
The operator establishes a governing service with the name of the Elasticsearch object itself when the Elasticsearch YAML is deployed.
We'll port-forward to the database from our local workstation using this service to establish a connection.
KubeDB creates a few Services to connect with the database.
We'll use curl to post some sample data into Elasticsearch, disabling attempts to verify self-signed certificates with the -k flag for testing purposes.
Best Practices and Security
To ensure the stability and security of your Elasticsearch cluster on Kubernetes, follow these best practices.
Use Dashboard like Kibana to get real-time performance insights and data visualization. Secure Kibana with access controls and encryption.
Implement high availability by utilizing Elasticsearch’s data replication features and distributing data across multiple nodes for redundancy. Kubernetes pod anti-affinity rules help prevent single points of failure.
Prioritize backup and recovery with regular data backups using Elasticsearch snapshots or available backup and recovery solutions. Store backups in separate locations or cloud storage for disaster recovery, and routinely test data restoration processes for reliability.
Implement comprehensive monitoring using tools like Prometheus, Grafana, or Elasticsearch’s monitoring features to track cluster health and performance metrics. Strengthen security with RBAC and robust authentication mechanisms, and implement Kubernetes network policies to Elasticsearch pods.
Here are some key security considerations to keep in mind:
- Secure Kibana with access controls and encryption
- Implement Kubernetes network policies to Elasticsearch pods
- Use RBAC and robust authentication mechanisms
Best Practices
When setting up Elasticsearch on Kubernetes, it's essential to use a dashboard like Kibana for real-time performance insights and data visualization. This allows you to monitor Elasticsearch cluster health and gain valuable application performance insights.
On a similar theme: Elasticsearch Performance
To ensure high availability, utilize Elasticsearch's data replication features, distributing data across multiple nodes for redundancy. Kubernetes pod anti-affinity rules help prevent single points of failure.
Regular data backups are crucial, and you can use Elasticsearch snapshots or available backup and recovery solutions. Store backups in separate locations or cloud storage for disaster recovery.
Comprehensive monitoring is vital, and you can use tools like Prometheus, Grafana, or Elasticsearch's monitoring features to track cluster health and performance metrics. Implementing Kubernetes network policies to Elasticsearch pods also strengthens security.
Here are some best practices to keep in mind:
- Deploy Kibana alongside Elasticsearch for real-time performance insights and data visualization.
- Ensure high availability by utilizing Elasticsearch’s data replication features and Kubernetes pod anti-affinity rules.
- Prioritize backup and recovery with regular data backups using Elasticsearch snapshots or available backup and recovery solutions.
- Implement comprehensive monitoring using tools like Prometheus, Grafana, or Elasticsearch’s monitoring features.
- Strengthen security with RBAC and robust authentication mechanisms, and implement Kubernetes network policies to Elasticsearch pods.
Final Thoughts
In the world of Kubernetes, the Operator Pattern has gained immense popularity over the last year, with the official Elasticsearch Operator having the same number of stars on GitHub as the most popular Elasticsearch Helm chart.
The Operator Pattern offers a lot of benefits, including the ability to automate complex tasks and make your life as a developer easier.

If you're considering using a Helm chart with StatefulSets or the Elasticsearch Operator, now you have a better understanding of the pros and cons of each approach.
The Elasticsearch Operator is a great choice if you want to autoscale your Elasticsearch cluster with Kubernetes.
Here are some key benefits of using the Operator Pattern:
- Autoscaling Elasticsearch with a Kubernetes Operator
Why Avoid It?
When working with new tools, it's essential to consider the potential drawbacks. One major issue with the Elasticsearch Operator is the additional tool you need to learn, which can be overwhelming.
Learning a new tool means investing time and effort into understanding its features and capabilities. This can be a significant challenge, especially for those with limited experience.
The Elasticsearch Operator also creates additional Kubernetes resources in a separate namespace, which can lead to overhead and increased complexity.
This can make it more difficult to manage and maintain your Elasticsearch cluster, as you'll have to keep track of multiple resources in different namespaces.
Here are some key reasons to avoid the Elasticsearch Operator:
- An additional tool to learn
- Additional Kubernetes resources in a separate namespace to worry about
- Additional resources create overhead
- Less fine-tuned control
Most of what the Elasticsearch Operator offers is already available with prebuilt Helm charts, making it a less appealing option.
Pros and Cons

The Elasticsearch Operator is still a bit of a wild card, and it's not yet clear whether it's the better choice than Helm charts. We're still seeing a tie between the two in terms of popularity.
The Elasticsearch Operator is still a bit of a wild card, and it's not yet clear whether it's the better choice than Helm charts.
If you want to have 3 Pods, running the Elasticsearch Operator might be a better option, but only time will tell.
The official Elasticsearch Operator seems to be neck-and-neck with Helm charts in terms of popularity, which suggests that both have their strengths and weaknesses.
Installation and Upgrade
Installing the Elasticsearch Operator is a straightforward process. You can install custom resource definitions and the Operator with RBAC rules using a single command.
To check the resources, run a command that will show you the Operator's location under the elastic-system namespace. Monitoring logs can be done with another command, but a better way is to add the Sematext Operator to collect them and send them to a central location.
You'll know it's working if you see logs streaming in, and the Services will have ClusterIPs with automatically generated credentials.
Curious to learn more? Check out: Elasticsearch Logs
Installing

Installing Elasticsearch Operator on your Kubernetes cluster is a straightforward process. You can install it using the command that installs custom resource definitions and the Operator with RBAC rules.
The Operator will live under the elastic-system namespace, and you can monitor its logs by running a specific command. A better way to monitor logs is to add the Sematext Operator, which collects and sends them to a central location.
To install the Operator, you can also use Terraform scripts with a prepared Helm chart. Alternatively, you can apply manifest files directly, making changes as needed.
Resource installations can be done by applying manifest files, utilizing custom resource definitions created by the Operator. This approach is a key part of streamlining the process of creating and managing Elasticsearch resources.
You can deploy both the Operator and the cluster using Helm charts, making it a convenient option for installation.
Recommended read: Monitor Elasticsearch
Upgrade and Configure
Upgrading and configuring your Elasticsearch cluster is a crucial step in ensuring it's running smoothly and efficiently. Any edits you make to the configuration will automatically upgrade the cluster.
The Operator will try to update all the configuration changes you tell it, except for existing volume claims, which cannot be resized. Make sure your Kubernetes cluster has enough resources to handle any resizing you do.
Upgrading the cluster will bump up the Pod count. You can check out a sample to see all the configuration options.
For production workloads, you'll likely want more control over storage allocation. You can use Volume claim templates for more information.
The default storage class defined for the Kubernetes cluster allocates a persistent volume of 1 GB for storage.
Troubleshooting and Maintenance
Troubleshooting Elasticsearch Operator involves checking the logs for errors and warnings. Elasticsearch Operator logs are stored in the /var/log/elasticsearch/ directory.
Check the Elasticsearch cluster health by running the command `kubectl get elasticsearch elasticsearch -o jsonpath='{.status.health}'`. If the health is red, investigate the issue further.
Regular maintenance tasks include updating the Elasticsearch Operator and its dependencies. This can be done by running `kubectl apply -f https://github.com/elastic/elasticsearch-operator/releases/latest/download/operator.yaml`.
Monitor Elasticsearch metrics, such as CPU and memory usage, to ensure optimal performance. You can use tools like Prometheus and Grafana to collect and visualize these metrics.
Avoid running Elasticsearch Operator with root privileges to prevent security risks. Instead, run it with a non-root user and group.
Check the Elasticsearch Operator configuration by running `kubectl get elasticsearch elasticsearch -o jsonpath='{.spec}'`. This will display the current configuration settings.
Regularly back up your Elasticsearch data to prevent data loss in case of a disaster. This can be done using tools like Elasticsearch's built-in snapshot feature or third-party backup tools.
Readers also liked: Elasticsearch Metrics
What is Elasticsearch Operator
The Elasticsearch Operator is a game-changer for managing Elasticsearch on Kubernetes. It automates the process of managing Elasticsearch on Kubernetes.
The Elasticsearch Operator is built using the Kubernetes Operator pattern, which means it uses custom resources to manage applications. This allows for a more streamlined and automated experience.
The official Elasticsearch Operator from Elastic is secure by default, with encryption enabled and password protected. It's also maintained by the creators of Elasticsearch, ensuring it's always up-to-date and reliable.
You can choose from different Elasticsearch Operators, but only one is written and maintained by Elastic. The official ECK Operator built by Elastic is the one we'll focus on in this tutorial.
The ECK Operator simplifies deploying the whole Elastic stack on Kubernetes, making it easier to automate and streamline critical operations. You can add, remove, and update resources with ease, just like playing with Lego bricks.
Here are some of the key features that are streamlined with the ECK Operator:
- Managing multiple clusters
- Upgrading versions
- Scaling cluster capacity
- Changing cluster configuration
- Dynamically scaling storage
- Scheduling backups
Supported Versions and Resources
The Elasticsearch Operator supports a wide range of versions, ensuring compatibility with various infrastructure and application stacks.
Kubernetes 1.20–1.24 is supported, making it a great choice for containerized environments.
OpenShift 4.6–4.10 is also supported, allowing you to integrate with enterprise-grade Kubernetes distributions.
Here's a breakdown of the supported versions for Elasticsearch and its related tools:
This ensures that your Elasticsearch setup is compatible with the latest versions of these tools, giving you a solid foundation for your data analytics and search applications.
Frequently Asked Questions
What does Eck do?
ECK streamlines critical operations like cluster management, scaling, and configuration changes, making it easier to run and maintain complex Kubernetes environments. With ECK, you can simplify and automate key tasks to boost efficiency and reduce downtime.
Should you run Elasticsearch on Kubernetes?
Yes, running Elasticsearch on Kubernetes is a viable option, but consider using an operator for management to ensure a smooth experience.
Featured Images: pexels.com


