Skip to content

Commit a7ccef5

Browse files
committed
revamp opensearch
1 parent 098a9e7 commit a7ccef5

File tree

1 file changed

+72
-74
lines changed

1 file changed

+72
-74
lines changed

src/content/docs/aws/services/opensearch.md renamed to src/content/docs/aws/services/opensearch.mdx

Lines changed: 72 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
---
22
title: "OpenSearch Service"
3-
linkTitle: "OpenSearch Service"
4-
description: >
5-
Get started with OpenSearch Service on LocalStack
3+
description: Get started with OpenSearch Service on LocalStack
64
tags: ["Free"]
75
---
86

@@ -12,7 +10,7 @@ OpenSearch Service is an open-source search and analytics engine, offering devel
1210
OpenSearch Service also offers log analytics, real-time application monitoring, and clickstream analysis.
1311

1412
LocalStack allows you to use the OpenSearch Service APIs in your local environment to create, manage, and operate the OpenSearch clusters.
15-
The supported APIs are available on our [API coverage page]({{< ref "coverage_opensearch" >}}), which provides information on the extent of OpenSearch's integration with LocalStack.
13+
The supported APIs are available on our [API coverage page](), which provides information on the extent of OpenSearch's integration with LocalStack.
1614

1715
The following versions of OpenSearch Service are supported by LocalStack:
1816

@@ -42,20 +40,20 @@ To create an OpenSearch Service cluster, you can use the [`CreateDomain`](https:
4240
OpenSearch Service domain is synonymous with an OpenSearch cluster.
4341
Execute the following command to create a new OpenSearch domain:
4442

45-
{{< command >}}
46-
$ awslocal opensearch create-domain --domain-name my-domain
47-
{{< / command >}}
43+
```bash
44+
awslocal opensearch create-domain --domain-name my-domain
45+
```
4846

4947
Each time you establish a cluster using a new version of OpenSearch, the corresponding OpenSearch binary must be downloaded, a process that might require some time to complete.
5048
In the LocalStack log you will see something like, where you can see the cluster starting up in the background.
5149

5250
You can open the LocalStack logs, to see that the OpenSearch Service cluster is being created in the background.
5351
You can use the [`DescribeDomain`](https://docs.aws.amazon.com/opensearch-service/latest/APIReference/API_DescribeDomain.html) API to check the status of the cluster:
5452

55-
{{< command >}}
56-
$ awslocal opensearch describe-domain \
53+
```bash
54+
awslocal opensearch describe-domain \
5755
--domain-name my-domain | jq ".DomainStatus.Processing"
58-
{{< / command >}}
56+
```
5957

6058
The `Processing` attribute will be `false` once the cluster is up and running.
6159
Once the cluster is up, you can interact with the cluster.
@@ -66,15 +64,15 @@ You can now interact with the cluster at the cluster API endpoint for the domain
6664

6765
Run the following command to get the cluster health:
6866

69-
{{< command >}}
70-
$ curl http://my-domain.us-east-1.opensearch.localhost.localstack.cloud:4566
71-
{{< / command >}}
67+
```bash
68+
curl http://my-domain.us-east-1.opensearch.localhost.localstack.cloud:4566
69+
```
7270

7371
You can verify that the cluster is up and running by checking the cluster health:
7472

75-
{{< command >}}
76-
$ curl -s http://my-domain.us-east-1.opensearch.localhost.localstack.cloud:4566/_cluster/health | jq .
77-
{{< / command >}}
73+
```bash
74+
curl -s http://my-domain.us-east-1.opensearch.localhost.localstack.cloud:4566/_cluster/health | jq .
75+
```
7876

7977
The following output will be visible on your terminal:
8078

@@ -108,7 +106,7 @@ The strategy can be configured via the `OPENSEARCH_ENDPOINT_STRATEGY` environmen
108106
| ------- | ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- |
109107
| `domain` | `<domain-name>.<region>.<engine-type>.localhost.localstack.cloud:4566` | The default strategy employing the `localhost.localstack.cloud` domain for routing to localhost. |
110108
| `path` | `localhost:4566/<engine-type>/<region>/<domain-name>` | An alternative strategy useful if resolving LocalStack's localhost domain poses difficulties. |
111-
| `port` | `localhost:<port-from-range>` | Directly exposes cluster(s) via ports from [the external service port range]({{< ref "external-ports" >}}). |
109+
| `port` | `localhost:<port-from-range>` | Directly exposes cluster(s) via ports from [the external service port range](). |
112110

113111
Irrespective of the originating service for the clusters, the domain of each cluster consistently aligns with its engine type, be it OpenSearch or Elasticsearch.
114112
Consequently, OpenSearch clusters incorporate `opensearch` within their domains (e.g., `my-domain.us-east-1.opensearch.localhost.localstack.cloud:4566`), while Elasticsearch clusters feature `es` in their domains (e.g., `my-domain.us-east-1.es.localhost.localstack.cloud:4566`).
@@ -121,16 +119,16 @@ Moreover, you can opt for custom domains, though it's important to incorporate t
121119

122120
Run the following command to create a new OpenSearch domain with a custom endpoint:
123121

124-
{{< command >}}
125-
$ awslocal opensearch create-domain --domain-name my-domain \
122+
```bash
123+
awslocal opensearch create-domain --domain-name my-domain \
126124
--domain-endpoint-options '{ "CustomEndpoint": "http://localhost:4566/my-custom-endpoint", "CustomEndpointEnabled": true }'
127-
{{< / command >}}
125+
```
128126

129127
After the domain processing is complete, you can access the cluster using the custom endpoint:
130128

131-
{{< command >}}
132-
$ curl http://localhost:4566/my-custom-endpoint/_cluster/health
133-
{{< / command >}}
129+
```bash
130+
curl http://localhost:4566/my-custom-endpoint/_cluster/health
131+
```
134132

135133
## Re-using a single cluster instance
136134

@@ -146,20 +144,22 @@ As a result, we advise caution when considering this approach and generally reco
146144

147145
OpenSearch will be organized in your state directory as follows:
148146

149-
{{< command >}}
150-
$ tree -L 4 ./volume/state
151-
./volume/state
152-
├── opensearch
153-
│ └── arn:aws:es:us-east-1:000000000000:domain
154-
│ ├── my-cluster-1
155-
│ │ ├── backup
156-
│ │ ├── data
157-
│ │ └── tmp
158-
│ ├── my-cluster-2
159-
│ │ ├── backup
160-
│ │ ├── data
161-
│ │ └── tmp
162-
{{< /command >}}
147+
import { Tabs, TabItem, FileTree } from '@astrojs/starlight/components';
148+
149+
<FileTree>
150+
- volume
151+
- state
152+
- opensearch
153+
- arn:aws:es:us-east-1:000000000000:domain
154+
- my-cluster-1
155+
- backup
156+
- data
157+
- tmp
158+
- my-cluster-2
159+
- backup
160+
- data
161+
- tmp
162+
</FileTree>
163163

164164
## Advanced Security Options
165165

@@ -208,15 +208,15 @@ Save it in a file named `opensearch_domain.json`.
208208

209209
To provision it, use the following `awslocal` CLI command, assuming the aforementioned CLI input has been stored in a file named `opensearch_domain.json`:
210210

211-
{{< command >}}
212-
$ awslocal opensearch create-domain --cli-input-json file://./opensearch_domain.json
213-
{{< /command >}}
211+
```bash
212+
awslocal opensearch create-domain --cli-input-json file://./opensearch_domain.json
213+
```
214214

215215
Once the domain setup is complete (`Processing: false`), the cluster can only be accessed with the given master user credentials, via HTTP basic authentication:
216216

217-
{{< command >}}
218-
$ curl -u 'admin:really-secure-passwordAa!1' http://secure-domain.us-east-1.opensearch.localhost.localstack.cloud:4566/_cluster/health
219-
{{< /command >}}
217+
```bash
218+
curl -u 'admin:really-secure-passwordAa!1' http://secure-domain.us-east-1.opensearch.localhost.localstack.cloud:4566/_cluster/health
219+
```
220220

221221
The following output will be visible on your terminal:
222222

@@ -232,22 +232,23 @@ It's important to note that any unauthorized requests will yield an HTTP respons
232232
And you can directly use the official OpenSearch Dashboards Docker image to analyze data in your OpenSearch domain within LocalStack!
233233

234234
When using OpenSearch Dashboards with LocalStack, you need to make sure to:
235-
- Enable the [advanced security options]({{< ref "#advanced-security-options" >}}) and set a username and a password.
235+
- Enable the [advanced security options](#advanced-security-options) and set a username and a password.
236236
This is required by OpenSearch Dashboards.
237237
- Ensure that the OpenSearch Dashboards Docker container uses the LocalStack DNS.
238-
You can find more information on how to connect your Docker container to Localstack in our [Network Troubleshooting guide]({{< ref "references/network-troubleshooting/endpoint-url/#from-your-container" >}}).
238+
You can find more information on how to connect your Docker container to Localstack in our [Network Troubleshooting guide]().
239239

240240
First, you need to make sure to start LocalStack in a specific Docker network:
241-
{{< command >}}
242-
$ localstack start --network ls
243-
{{< /command >}}
241+
242+
```bash
243+
localstack start --network ls
244+
```
244245

245246
Now you can provision a new OpenSearch domain.
246-
Make sure to enable the [advanced security options]({{< ref "#advanced-security-options" >}}):
247+
Make sure to enable the [advanced security options](#advanced-security-options):
247248

248-
{{< command >}}
249-
$ awslocal opensearch create-domain --cli-input-json file://./opensearch_domain.json
250-
{{< /command >}}
249+
```bash
250+
awslocal opensearch create-domain --cli-input-json file://./opensearch_domain.json
251+
```
251252

252253
Now you can start another container for OpenSearch Dashboards, which is configured such that:
253254
- The port for OpenSearch Dashboards is mapped (`5601`).
@@ -257,18 +258,17 @@ Now you can start another container for OpenSearch Dashboards, which is configur
257258
- The OpenSearch credentials are set.
258259
- The version of OpenSearch Dashboards is the same as the OpenSearch domain.
259260

260-
{{< command >}}
261+
```bash
261262
docker inspect localstack-main | \
262263
jq -r '.[0].NetworkSettings.Networks | to_entries | .[].value.IPAddress'
263-
# prints 172.22.0.2
264264

265265
docker run --rm -p 5601:5601 \
266266
--network ls \
267267
--dns 172.22.0.2 \
268268
-e "OPENSEARCH_HOSTS=http://secure-domain.us-east-1.opensearch.localhost.localstack.cloud:4566" \
269269
-e "OPENSEARCH_USERNAME=admin" -e 'OPENSEARCH_PASSWORD=really-secure-passwordAa!1' \
270270
opensearchproject/opensearch-dashboards:2.11.0
271-
{{< /command >}}
271+
```
272272

273273
Once the container is running, you can reach OpenSearch Dashboards at `http://localhost:5601` and you can log in with your OpenSearch domain credentials.
274274

@@ -329,45 +329,43 @@ volumes:
329329
330330
You can start the Docker Compose environment using the following command:
331331
332-
{{< command >}}
333-
$ docker-compose up -d
334-
{{< /command >}}
332+
```bash
333+
docker-compose up -d
334+
```
335335

336336
You can now create an OpenSearch cluster using the `awslocal` CLI:
337337

338-
{{< command >}}
339-
$ awslocal opensearch create-domain --domain-name my-domain
340-
{{< /command >}}
338+
```bash
339+
awslocal opensearch create-domain --domain-name my-domain
340+
```
341341

342342
If the `Processing` status shows as `true`, the cluster isn't fully operational yet.
343343
You can use the `describe-domain` command to retrieve the current status:
344344

345-
{{< command >}}
346-
$ awslocal opensearch describe-domain --domain-name my-domain
347-
{{< /command >}}
345+
```bash
346+
awslocal opensearch describe-domain --domain-name my-domain
347+
```
348348

349349
You can now verify cluster health and set up indices:
350350

351-
{{< command >}}
352-
$ curl my-domain.us-east-1.opensearch.localhost.localstack.cloud:4566/_cluster/health | jq
353-
{{< /command >}}
351+
```bash
352+
curl my-domain.us-east-1.opensearch.localhost.localstack.cloud:4566/_cluster/health | jq
353+
```
354354

355355
The output will provide insights into the cluster's health and version information.
356356

357357
Finally create an example index using the following command:
358358

359-
{{< command >}}
360-
$ curl -X PUT my-domain.us-east-1.opensearch.localhost.localstack.cloud:4566/my-index
361-
{{< /command >}}
359+
```bash
360+
curl -X PUT my-domain.us-east-1.opensearch.localhost.localstack.cloud:4566/my-index
361+
```
362362

363363
## Resource Browser
364364

365365
The LocalStack Web Application provides a Resource Browser for managing OpenSearch domains.
366366
You can access the Resource Browser by opening the LocalStack Web Application in your browser, navigating to the **Resources** section, and then clicking on **OpenSearch Service** under the **Analytics** section.
367367

368-
<img src="opensearch-resource-browser.png" alt="OpenSearch Resource Browser" title="OpenSearch Resource Browser" width="900" />
369-
<br>
370-
<br>
368+
![OpenSearch Resource Browser](/images/aws/opensearch-resource-browser.png)
371369

372370
The Resource Browser allows you to perform the following actions:
373371

@@ -390,4 +388,4 @@ The `CustomEndpointOptions` in LocalStack offers the flexibility to utilize arbi
390388
## Troubleshooting
391389

392390
If you encounter difficulties resolving subdomains while employing the `OPENSEARCH_ENDPOINT_STRATEGY=domain` (the default setting), it's advisable to investigate whether your DNS configuration might be obstructing rebind queries.
393-
For further insights on addressing this issue, refer to the section on [DNS rebind protection]({{< ref "dns-server#dns-rebind-protection" >}}).
391+
For further insights on addressing this issue, refer to the section on [DNS rebind protection](/aws/tooling/dns-server#dns-rebind-protection).

0 commit comments

Comments
 (0)