OpenSearch Kubernetes Operator
The OpenSearch Kubernetes Operator is an open-source Kubernetes operator that helps automate the deployment and provisioning of OpenSearch and OpenSearch Dashboards in a containerized environment. The operator can manage multiple OpenSearch clusters that can be scaled up and down depending on your needs.
Installing the operator
To install the operator using Helm, follow these steps:
-
Add the Helm repository:
helm repo add opensearch-operator https://opensearch-project.github.io/opensearch-k8s-operator/ -
Install the operator:
helm install opensearch-operator opensearch-operator/opensearch-operator
Quickstart
After you have successfully installed the operator, you can deploy your first OpenSearch cluster by creating a custom OpenSearchCluster object in Kubernetes.
The following steps show you how to deploy a minimal cluster and are only intended for demonstration purposes. To learn how to configure and manage your cluster for production environments, see Configuration and management.
Follow these steps to deploy the cluster, verify that it is running, access it, and clean up resources when finished:
-
Create a
cluster.yamlfile containing the following content:apiVersion: opensearch.org/v1 kind: OpenSearchCluster metadata: name: my-first-cluster namespace: default spec: general: serviceName: my-first-cluster version: 3 dashboards: enable: true version: 3 replicas: 1 resources: requests: memory: "512Mi" cpu: "200m" limits: memory: "512Mi" cpu: "200m" nodePools: - component: nodes replicas: 3 diskSize: "5Gi" nodeSelector: resources: requests: memory: "2Gi" cpu: "500m" limits: memory: "2Gi" cpu: "500m" roles: - "cluster_manager" - "data" -
Create the cluster by running the following command:
kubectl apply -f cluster.yaml -
(Optional) Monitor the cluster status by running the following command:
watch -n 2 kubectl get podsThe operator creates several pods:
- A bootstrap pod (
my-first-cluster-bootstrap-0) that helps with initial cluster manager discovery. - Three pods for the OpenSearch cluster (
my-first-cluster-masters-0,my-first-cluster-masters-1, andmy-first-cluster-masters-2). - A pod for the OpenSearch Dashboards instance.
After all pods are ready, which takes about 1–2 minutes, you can connect to your cluster using port forwarding.
- A bootstrap pod (
- Start port forwarding:
kubectl port-forward svc/my-first-cluster-dashboards 5601 -
Access OpenSearch Dashboards or use the OpenSearch REST API:
-
To access OpenSearch Dashboards, go to http://localhost:5601 in your browser and log in using the admin or Dashboards user credentials. You can retrieve the credentials from the
my-first-cluster-admin-passwordandmy-first-cluster-dashboards-passwordsecrets. -
To use the OpenSearch REST API, run the following command:
kubectl port-forward svc/my-first-cluster 9200Then open a second terminal and run the following command. You can retrieve the admin credentials from the
my-first-cluster-admin-passwordsecret:curl -k -u admin:admin_password https://localhost:9200/_cat/nodes?vYou should see the three deployed nodes listed.
-
To delete your cluster, run the following command:
kubectl delete -f cluster.yamlThis removes Kubernetes resources created by the operator but does not delete the persistent volumes. For a complete cleanup, delete the PVCs:
kubectl delete pvc -l opensearch.org/opensearch-cluster=my-first-cluster
Single-node clusters are currently not supported. Your cluster must have at least 3 nodes with the master or cluster_manager role configured.
Configuration and management
After deploying your cluster, you can configure and manage it using the following guides:
- Operator configuration: Operator-level settings such as log levels, namespaces, and pprof endpoints.
- OpenSearch cluster configuration: OpenSearch-specific settings including node pools, TLS, plugins, and keystore management.
- OpenSearch Dashboards configuration: OpenSearch Dashboards settings, including authentication, base path, and TLS.
- Kubernetes deployment customization: Kubernetes-level settings such as persistence, security contexts, volumes, and probes.
- Cluster operations: Cluster lifecycle operations including recovery, upgrades, and volume expansion.
- User and role management: Security settings, users, roles, and access control.
- Advanced management: Monitoring, ISM policies, index templates, and snapshot policies.
Operator releases
Note the following about operator releases:
- For a compatibility matrix of the operator and OpenSearch releases, see Compatibility.
- The OpenSearch Operator User Guide in the repository corresponds to the current development state of the code. To view the documentation for a specific released version, switch to the version tag in the GitHub menu.
- Feature requests are tracked as GitHub issues. If you would like a feature implemented and find a corresponding issue, note that an issue closed as completed means that the feature has been implemented in the development version. It may still take time before the feature is included in an official release. If you’re unsure, review the project’s release list on GitHub to see whether the feature appears in the release notes.
Next steps
-
For more information about customizing your OpenSearch cluster on Kubernetes, including data persistence, authentication methods, and scaling, see the OpenSearch Kubernetes Operator User Guide.
-
To contribute to the development of the OpenSearch Kubernetes Operator, see the repository design documents.
-
For more information, see OpenSearch Operator.