Create an OpenSearch cluster
An OpenSearch cluster is described by an OpenSearchCluster custom resource in the opensearch.org/v1 API group. You can create it in any namespace, because the operator watches all namespaces.
Before you start, make sure that:
- The operator is installed. See Installation.
vm.max_map_countis 262144 or higher on the nodes that will run OpenSearch.- You know which StorageClass to use. See Storage.
TOC
Choose TLS or plain HTTPCluster with TLS (recommended)Admin credentialsConnect to the clusterCluster without TLSOpenSearch DashboardsDashboards does not become readyCheck the cluster statusDelete a clusterChoose TLS or plain HTTP
Use TLS for any cluster that holds real data or that is reachable by more than a trusted set of clients. Without TLS, anyone who can reach the service can read, change and delete all data.
Cluster with TLS (recommended)
The operator generates a certificate authority and signs the certificates for you:
transport.generate: truewithtransport.perNode: trueissues one transport certificate per OpenSearch node.http.generate: trueissues the certificate for the REST API.
Replace my-namespace and <storage-class>, then apply the file:
Notes on the fields:
spec.general.serviceNameis required. It is the name of the Kubernetes Service for the REST API.spec.general.versionselects the engine version:3.8.0(default version of this release) or2.19.6. Setspec.dashboards.versionto the same version.- At least one node pool must have the
cluster_managerrole andreplicasof 1 or more. Use 3 cluster-manager-eligible nodes for a highly available cluster. componentmust be unique within the cluster. It is part of the names of the StatefulSet and pods (<cluster-name>-<component>-<index>).- If
jvmis not set for a node pool, the operator sets the Java heap (-Xmsand-Xmx) to half of the pool's memory request. Always set a memory request. diskSizedefaults to30Giwhen it is not set.
Admin credentials
Unless you provide your own credentials, the operator generates the password of the built-in admin user and stores it in a Secret named <cluster-name>-admin-password in the cluster's namespace, with the keys username and password.
To use credentials that you manage, create a Secret with the keys username and password before you create the cluster, and reference it:
Connect to the cluster
The REST API is exposed by a Service named after spec.general.serviceName, on port 9200 (spec.general.httpPort). For a quick check from a workstation:
In another terminal:
The certificates are signed by the operator-generated CA, which your workstation does not trust; -k skips the verification for this test only.
Cluster without TLS
If an OpenSearchCluster has no TLS configuration, the operator starts OpenSearch with the security plugin disabled. The REST API is served over plain HTTP on port 9200 without authentication.
Check the cluster:
Things to know:
- The security plugin is disabled when neither
spec.security.tls.transportnorspec.security.tls.httpis configured (or both are set toenabled: false). Aspec.security.configsection on its own does not enable it. - The operator still creates the
<cluster-name>-admin-passwordSecret, but OpenSearch does not check credentials. - Decide between TLS and plain HTTP when you create the cluster. This documentation does not cover switching an existing cluster between the two modes.
OpenSearch Dashboards
Set spec.dashboards.enable: true to deploy OpenSearch Dashboards with the cluster, as in the TLS example above. The operator:
- creates a Deployment with
spec.dashboards.replicaspods and a Service named<serviceName>-dashboardson port 5601; - connects Dashboards to the cluster with a dedicated internal user (
kibanaserver) whose credentials it stores in the Secret<cluster-name>-dashboards-password.
The Service type is ClusterIP by default. To expose Dashboards outside the cluster, set spec.dashboards.service.type to NodePort or LoadBalancer, or put an Ingress in front of the Service. For a quick check:
Then open http://localhost:5601 and log in as admin with the password from the <cluster-name>-admin-password Secret.
To serve Dashboards itself over HTTPS with an operator-generated certificate, add:
Dashboards does not become ready
If Dashboards keeps logging that another instance is migrating its index and never becomes ready, see Dashboards waits for another migration.
Check the cluster status
When the cluster is first created, the operator starts a temporary bootstrap pod (<cluster-name>-bootstrap-0) to form the cluster, and removes it once the cluster has formed. The cluster is ready when status.phase of the OpenSearchCluster is RUNNING and all node pool pods are Ready.
Events on the custom resource explain what the operator is doing:
Delete a cluster
By default the data PVCs of the node pools are kept when the cluster is deleted. If you create a cluster with the same name in the same namespace again, it reuses those volumes and re-forms the previous cluster from the data on disk. Delete the PVCs as well if you want a fresh cluster. See Storage.
OpenSearch® is a registered trademark of LF Projects, LLC.