Get Started with OpenSearch on Kubernetes Using the Bitnami Helm Chart
OpenSearch is a comprehensive open source search and analytics engine that empowers users to index extensive datasets and quickly retrieve them. OpenSearch intelligently manages and distributes data through the core principle of sharding, which means that an index—a compilation of interconnected documents—is subdivided into more manageable units known as shards. These shards are then distributed across many nodes within a cluster, facilitating parallel processing and optimizing resource utilization for enhanced efficiency.
The Bitnami-packaged OpenSearch Helm chart offers a streamlined method for deploying OpenSearch on your Kubernetes cluster with minimal effort, while also providing numerous configuration options.
In this blog, we'll guide you through the process of launching an OpenSearch cluster using the Bitnami OpenSearch Helm chart from Bitnami Application Catalog and Tanzu Application Catalog, discuss how to access the dashboard, and then provide an example to illustrate how to use the OpenSearch API to get the most out of this application.
Assumptions and prerequisites
Before we start, let's make sure that we meet the necessary prerequisites:
- An operational Kubernetes cluster
- Installed and configured kubectl CLI and Helm v3.x package manager. If you need help with these steps, you can check our article “Learn how to install kubectl and Helm v3.x.”
- Installed curl
- Optional: Access to Tanzu Application Catalog
Getting and deploying the Bitnami package for OpenSearch Helm chart
Deploying the community version of the chart through Bitnami Application Catalog
- Deploy the Bitnami OpenSearch Helm chart:
helm install my-release oci://registry-1.docker.io/bitnamicharts/opensearch
Deploying the enterprise version of the chart through Tanzu Application Catalog
The following steps describe how to navigate to Tanzu Application Catalog and deploy OpenSearch in your cluster. This example shows an OpenSearch chart built using Photon OS 4 as the base OS image, but feel free to customize the chart depending on your needs. Note that Photon OS is the recommended base OS image in Tanzu Application Catalog.
- Navigate to app-catalog.vmware.com and sign in to your catalog with your VMware account.
- In the My Applications section, search for the OpenSearch chart and click Details.
On the next screen, you will find the instructions for deploying the chart on your cluster. Make sure that your cluster is up and running.
- Execute kubectl cluster-info, then run the commands you will find in the Consume your Helm chart section.
Accessing the dashboard
Once you have installed the OpenSearch Helm chart in your cluster, check the status of the deployment by using the following command:
kubectl get pods
You should see the following pods being deployed:
- opensearch-coordinating: distributes the search and index requests to the data nodes
- opensearch-data: handles tasks such as indexing, searching, and serving data
- opensearch-ingest: responsible for pre-processing documents before they are indexed
- opensearch-master: responsible for cluster-wide coordination and management tasks
The status of the pods after running the kubectl command
By default, the OpenSearch Dashboard is disabled. Wait for the deployment to be ready and then upgrade the chart to enable the OpenSearch Dashboard:
helm upgrade my-release oci://registry-1.docker.io/bitnamicharts/opensearch --set dashboards.enabled=true
You should now see an opensearch-dashboards pod being deployed:
The deployment status of the opensearch-dashboards pod
When the deployment is ready, we need to forward the port of the OpenSearch dashboards pod so we can access it through the browser:
kubectl port-forward svc/my-release-opensearch-dashboards 5601:5601
You should now be able to access the dashboard on http://localhost:5601.
Let’s check out some visualization options.
- Click on Add sample data:
The OpenSearch Dashboard opening page showing the Add sample data button
- On the sample data page, choose a sample dataset and click on Add data:
Various sample data options you can choose from
- Click on View data to open the sample data dashboard:
The View data button
- Check out the many visualization options that are available:
The sample data dashboard
Using the OpenSearch API
Now, let's use the OpenSearch API. To illustrate its functionality, we'll use a webshop example, demonstrating the process of creating a product index, adding products, and executing a query to retrieve relevant data.
- Forward port 9200 so we can access the API through localhost:
kubectl port-forward svc/my-release-opensearch 9200:9200
- Create an index named webproducts with mapping for product information:
curl -X PUT "http://localhost:9200/webproducts" -H 'Content-Type: application/json' -d'
{
"mappings": {
"properties": {
"name": { "type": "text" },
"description": { "type": "text" },
"price": { "type": "float" },
"category": { "type": "keyword" },
"stock_quantity": { "type": "integer" }
}
}
}'
- Let’s add a couple of product entries to the webproducts index:
curl -X POST "http://localhost:9200/webproducts/_doc/1" -H 'Content-Type: application/json' -d'
{
"name": "Smartphone X",
"description": "High-performance smartphone with advanced features.",
"price": 599.99,
"category": "Electronics",
"stock_quantity": 100
}'
curl -X POST "http://localhost:9200/webproducts/_doc/2" -H 'Content-Type: application/json' -d'
{
"name": "Wireless Headphones",
"description": "Noise-canceling wireless headphones for an immersive audio experience.",
"price": 129.99,
"category": "Audio",
"stock_quantity": 50
}'
The OpenSearch API allows you to perform various operations on your data using diverse criteria, including full-text searches, exact term matches, numeric and date range queries, Boolean operations, wildcard patterns, and more. For example, the following command returns a list of products with a price range between $100 and $200:
curl -X POST "http://localhost:9200/webproducts/_search" -H 'Content-Type: application/json' -d'
{
"query": {
"range": {
"price": {
"gte": 100,
"lte": 200
}
}
}
}'
- Finally, let’s count the number of items per category:
curl -X POST "http://localhost:9200/webproducts/_search" -H 'Content-Type: application/json' -d'
{
"size": 0,
"aggs": {
"products_by_category": {
"terms": {
"field": "category"
}
}
}
}
'
Support and resources
You can access the Bitnami package for OpenSearch from the Bitnami GitHub repository, available in both community and enterprise versions via Tanzu Application Catalog. Explore the differences between these catalogs by referring to our blog post.
If you encounter issues with Bitnami community packages, please don’t hesitate to open an issue in the Bitnami Helm charts or containers GitHub repository. Additionally, if you want to contribute to the catalog, you can submit a pull request. Our team will review your request and offer guidance throughout the merging process for a successful collaboration.
If you are deploying the enterprise version of this package and experience any issues, please file a support request via the VMware Cloud Services Console.
For comprehensive guidance on integrating OpenSearch into your code or processes, please consult the official OpenSearch documentation.
If you are interested in learning more about Tanzu Application Catalog in general, check out our product webpage, Tech Zone page and additional resources. If you would like to get in touch, please contact us.
This article may contain hyperlinks to non-Broadcom websites that are created and maintained by third parties who are solely responsible for the content on such websites.