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
The operator Helm chart installs a validation webhook whose certificate is issued by cert-manager, so cert-manager must be installed in your Kubernetes cluster before you install the operator. If cert-manager is not installed, the operator installation fails. For other options, see Webhooks.
To install the operator using Helm, follow these steps:
-
Install
cert-manager. First, add thecert-managerHelm repository:helm repo add jetstack https://charts.jetstack.ioThen install
cert-managerand its custom resource definitions:helm install cert-manager jetstack/cert-manager --namespace cert-manager --create-namespace --set crds.enabled=true -
Add the operator Helm repository:
helm repo add opensearch-operator https://opensearch-project.github.io/opensearch-k8s-operator/ -
Update your local Helm chart information. If you added the repository previously, this step ensures that Helm installs the latest operator version:
helm repo update -
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: security: tls: transport: generate: true http: generate: true 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"The
versionvalues must be quoted strings. Thesecurity.tlssection is required: if you omit it, the OpenSearch pods never become ready. Thesecurity.tlssection enables the Security plugin, andgenerate: trueinstructs the operator to generate self-signed TLS certificates. The operator also creates themy-first-cluster-admin-passwordandmy-first-cluster-dashboards-passwordsecrets containing randomly generated passwords. For more information, see TLS and User and role management. -
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-nodes-0,my-first-cluster-nodes-1, andmy-first-cluster-nodes-2), named after thenodesnode pool. - A pod for the OpenSearch Dashboards instance (
my-first-cluster-dashboards-<id>). - A job pod (
my-first-cluster-securityconfig-update-<id>) that applies the security configuration and then shows theCompletedstatus.
The cluster is ready when the three OpenSearch pods and the OpenSearch Dashboards pod show
1/1in theREADYcolumn, which takes about 3 minutes. The operator then removes the bootstrap pod. You can now connect to your cluster using port forwarding. - A bootstrap pod (
-
Retrieve the generated password for the
adminuser from themy-first-cluster-admin-passwordsecret:kubectl get secret my-first-cluster-admin-password -o jsonpath='{.data.password}' | base64 -d; echo -
Access OpenSearch Dashboards or use the OpenSearch REST API:
-
To access OpenSearch Dashboards, start port forwarding by running the following command:
kubectl port-forward svc/my-first-cluster-dashboards 5601Then go to
http://localhost:5601in your browser and log in as theadminuser using the password that you retrieved in the previous step. -
To use the OpenSearch REST API, start port forwarding by running the following command:
kubectl port-forward svc/my-first-cluster 9200Then open a second terminal and run the following command, replacing
<admin-password>with the password that you retrieved in the previous step:curl -k -u 'admin:<admin-password>' "https://localhost:9200/_cat/nodes?v"The response lists the three deployed nodes.
-
-
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 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
pprofendpoints. - 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
-
Before you use the cluster in production, see Preparing a cluster for production and Preparing OpenSearch Dashboards for production.
-
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.