Skip to content

Commit d21a938

Browse files
chore: Bump OpenSearch and OpenSearch Dashboards to 3.4.0 (#360)
* chore: Upgrade OpenSearch to version 3.4.0 * chore: Update opensearch-rag stack and demo for SDP 26.3 * demos(opensearch-rag): Wait for OpenSearch Dashboards to become ready * Disable multi-tenancy in OpenSearch
1 parent d9119fc commit d21a938

11 files changed

Lines changed: 73 additions & 40 deletions

File tree

demos/opensearch-rag/load-embeddings-from-git.yaml

Lines changed: 45 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,28 @@ data:
1818
from requests.auth import HTTPBasicAuth
1919
2020
# Configuration
21-
OPENSEARCH_HOST = os.getenv('OPENSEARCH_HOST', 'opensearch')
22-
OPENSEARCH_PORT = int(os.getenv('OPENSEARCH_PORT', '9200'))
21+
OPENSEARCH_HOSTS = os.getenv('OPENSEARCH_HOSTS', 'https://opensearch:9200')
22+
OPENSEARCH_HOSTNAME = os.getenv('OPENSEARCH_HOSTNAME', 'opensearch')
23+
OPENSEARCH_PORT = os.getenv('OPENSEARCH_PORT', '9200')
24+
OPENSEARCH_PROTOCOL = os.getenv('OPENSEARCH_PROTOCOL', 'https')
2325
OPENSEARCH_USER = os.getenv('OPENSEARCH_USER', 'admin')
2426
OPENSEARCH_PASSWORD = os.getenv('OPENSEARCH_PASSWORD', 'adminadmin')
27+
OPENSEARCH_DASHBOARDS_HOST = os.getenv('DASHBOARDS_HOST', 'opensearch-dashboards')
28+
OPENSEARCH_DASHBOARDS_PORT = os.getenv('DASHBOARDS_PORT', '5601')
2529
INDEX_NAME = os.getenv('INDEX_NAME', 'rag-documents')
2630
EMBEDDINGS_FILE = os.getenv('EMBEDDINGS_FILE', '/data/stackable-docs-embeddings.json')
2731
32+
OPENSEARCH_BASIC_AUTH = HTTPBasicAuth(OPENSEARCH_USER, OPENSEARCH_PASSWORD)
33+
OPENSEARCH_DASHBOARDS_BASE_URL = f'http://{OPENSEARCH_DASHBOARDS_HOST}:{OPENSEARCH_DASHBOARDS_PORT}'
34+
2835
def wait_for_opensearch():
2936
"""Wait for OpenSearch to be ready."""
3037
print("Waiting for OpenSearch to be ready...")
3138
for i in range(60):
3239
try:
3340
response = requests.get(
34-
f'https://{OPENSEARCH_HOST}:{OPENSEARCH_PORT}',
35-
auth=HTTPBasicAuth(OPENSEARCH_USER, OPENSEARCH_PASSWORD),
41+
OPENSEARCH_HOSTS,
42+
auth=OPENSEARCH_BASIC_AUTH,
3643
verify=False,
3744
timeout=5
3845
)
@@ -46,6 +53,27 @@ data:
4653
print("[ERROR] OpenSearch did not become ready in time")
4754
return False
4855
56+
def wait_for_opensearch_dashboards():
57+
"""Wait for OpenSearch Dashboards to be ready."""
58+
print("Waiting for OpenSearch Dashboards to be ready...")
59+
for i in range(60):
60+
try:
61+
response = requests.get(
62+
OPENSEARCH_DASHBOARDS_BASE_URL,
63+
auth=OPENSEARCH_BASIC_AUTH,
64+
verify=False,
65+
timeout=5
66+
)
67+
if response.status_code == 200:
68+
print("[OK] OpenSearch Dashboards is ready!")
69+
return True
70+
except Exception:
71+
print(f"Waiting for OpenSearch Dashboards... ({i+1}/60)")
72+
time.sleep(5)
73+
74+
print("[ERROR] OpenSearch Dashboards did not become ready in time")
75+
return False
76+
4977
def index_needs_loading(client):
5078
"""Check if index exists and has documents. Returns True if loading is needed."""
5179
if not client.indices.exists(index=INDEX_NAME):
@@ -135,17 +163,13 @@ data:
135163
136164
def create_index_pattern():
137165
"""Create index pattern in OpenSearch Dashboards and set as default."""
138-
dashboards_host = os.getenv('DASHBOARDS_HOST', 'opensearch-dashboards')
139-
dashboards_port = os.getenv('DASHBOARDS_PORT', '5601')
140-
base_url = f'http://{dashboards_host}:{dashboards_port}'
141166
headers = {"osd-xsrf": "true"}
142-
auth = HTTPBasicAuth(OPENSEARCH_USER, OPENSEARCH_PASSWORD)
143167
144168
# Create index pattern
145-
response = requests.put(
146-
f'{base_url}/api/saved_objects/index-pattern/{INDEX_NAME}?overwrite=true',
169+
response = requests.post(
170+
f'{OPENSEARCH_DASHBOARDS_BASE_URL}/api/saved_objects/index-pattern/{INDEX_NAME}?overwrite=true',
147171
json={"attributes": {"title": INDEX_NAME, "timeFieldName": "timestamp"}},
148-
auth=auth, headers=headers, timeout=10
172+
auth=OPENSEARCH_BASIC_AUTH, headers=headers, timeout=10
149173
)
150174
if response.status_code not in (200, 201, 409):
151175
print(f"[ERROR] Failed to create index pattern: {response.status_code} - {response.text}")
@@ -154,9 +178,9 @@ data:
154178
155179
# Set as default
156180
response = requests.post(
157-
f'{base_url}/api/opensearch-dashboards/settings',
181+
f'{OPENSEARCH_DASHBOARDS_BASE_URL}/api/opensearch-dashboards/settings',
158182
json={"changes": {"defaultIndex": INDEX_NAME}},
159-
auth=auth, headers=headers, timeout=10
183+
auth=OPENSEARCH_BASIC_AUTH, headers=headers, timeout=10
160184
)
161185
if response.status_code in (200, 201):
162186
print(f"[OK] Set {INDEX_NAME} as default index pattern")
@@ -201,10 +225,13 @@ data:
201225
if not wait_for_opensearch():
202226
return 1
203227
228+
if not wait_for_opensearch_dashboards():
229+
return 1
230+
204231
client = OpenSearch(
205-
hosts=[{'host': OPENSEARCH_HOST, 'port': OPENSEARCH_PORT}],
232+
hosts=[{'host': OPENSEARCH_HOSTNAME, 'port': OPENSEARCH_PORT}],
206233
http_auth=(OPENSEARCH_USER, OPENSEARCH_PASSWORD),
207-
use_ssl=True,
234+
use_ssl=OPENSEARCH_PROTOCOL == 'https',
208235
verify_certs=False,
209236
ssl_show_warn=False
210237
)
@@ -277,10 +304,6 @@ spec:
277304
pip install -q opensearch-py requests urllib3
278305
python -u /scripts/load.py
279306
env:
280-
- name: OPENSEARCH_HOST
281-
value: "opensearch"
282-
- name: OPENSEARCH_PORT
283-
value: "9200"
284307
- name: OPENSEARCH_USER
285308
value: "admin"
286309
- name: OPENSEARCH_PASSWORD
@@ -292,6 +315,9 @@ spec:
292315
value: "rag-documents"
293316
- name: EMBEDDINGS_FILE
294317
value: "/data/stackable-docs-embeddings.json"
318+
envFrom:
319+
- configMapRef:
320+
name: opensearch
295321
volumeMounts:
296322
- name: script
297323
mountPath: /scripts
-113 KB
Binary file not shown.

docs/modules/demos/pages/logging.adoc

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ $ stackablectl stacklet list
5656
┌───────────────────────┬───────────────────────┬───────────┬────────────────────────────────────────────────────────────────────────────────────┬─────────────────────────────────┐
5757
│ PRODUCT ┆ NAME ┆ NAMESPACE ┆ ENDPOINTS ┆ CONDITIONS │
5858
╞═══════════════════════╪═══════════════════════╪═══════════╪════════════════════════════════════════════════════════════════════════════════════╪═════════════════════════════════╡
59-
│ opensearch ┆ opensearch ┆ default ┆ nodes-default-http http://opensearch-nodes-default.default.svc.cluster.local:9200 ┆ Available, Reconciling, Running │
59+
│ opensearch ┆ opensearch ┆ default ┆ -http http://opensearch.default.svc.cluster.local:9200 ┆ Available, Reconciling, Running │
60+
│ ┆ ┆ ┆ nodes-default-http http://opensearch-nodes-default.default.svc.cluster.local:9200 ┆ │
6061
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
6162
│ zookeeper ┆ simple-zk ┆ default ┆ server-zk simple-zk-server.default.svc.cluster.local:2282 ┆ Available, Reconciling, Running │
6263
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
@@ -79,10 +80,6 @@ Log in with the username `admin` and password `adminadmin`.
7980

8081
NOTE: On first login, you will be presented with some options. Feel free to bypass them to get to the logs.
8182

82-
Select the `Global` tenant to have access to the pre-configured `vector-*` index pattern.
83-
84-
image::logging/tenant.png[]
85-
8683
Click _Discover_ in the menu on the left to view the recent logs.
8784
If you do not see anything, increase the search window to greater than _Last 15 minutes_.
8885

docs/modules/demos/pages/opensearch-rag.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ Log in at http://localhost:5601 with:
274274
* *Username*: `admin`
275275
* *Password*: `adminadmin`
276276

277-
Select the *Global* tenant, then navigate to *Discover* to browse the `rag-documents` index:
277+
Navigate to *Discover* to browse the `rag-documents` index:
278278

279279
* Document titles and content
280280
* Categories (airflow-operator, kafka-operator, trino-operator, etc.)

stacks/_templates/opensearch-dashboards.yaml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ repo:
66
url: https://opensearch-project.github.io/helm-charts
77
version: {{ opensearchVersion }}
88
options:
9-
opensearchHosts: https://opensearch:9200
109
image:
1110
repository: oci.stackable.tech/sdp/opensearch-dashboards
1211
tag: "{{ opensearchVersion }}-stackable{{ stackableReleaseVersion }}"
@@ -16,15 +15,23 @@ options:
1615
type: NodePort
1716
port: 5601
1817
annotations:
19-
stackable.tech/logging-view-logs: |-
20-
/app/discover?security_tenant=global#/view/logs
18+
stackable.tech/logging-view-logs: /app/discover#/view/logs
2119
stackable.tech/logging-credentials-secret: opensearch-user
2220
labels:
2321
stackable.tech/vendor: Stackable
22+
opensearchHosts: null # Use the discovery ConfigMap instead
23+
extraEnvs:
24+
- name: OPENSEARCH_HOSTS
25+
valueFrom:
26+
configMapKeyRef:
27+
name: opensearch
28+
key: OPENSEARCH_HOSTS
2429
opensearchAccount:
2530
secret: opensearch-dashboard-user
2631
serviceAccount:
2732
create: false
2833
# Use the ServiceAccount of OpenSearch because its permissions are already configured to work on
2934
# OpenShift.
3035
name: opensearch-serviceaccount
36+
config:
37+
opensearch_security.multitenancy.enabled: false

stacks/logging/opensearch.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ stringData:
8888
authentication_backend:
8989
type: intern
9090
authz: {}
91+
kibana:
92+
multitenancy_enabled: false
9193
internal_users.yml: |
9294
---
9395
_meta:

stacks/logging/setup-opensearch-dashboards.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ spec:
2828
--retry-delay 5 \
2929
--header "Content-Type:application/json" \
3030
--header "osd-xsrf:true" \
31-
--header "securitytenant: global" \
3231
--data '{
3332
"attributes": {
3433
"title": "vector-*",
@@ -39,7 +38,6 @@ spec:
3938
curl \
4039
--header "Content-Type:application/json" \
4140
--header "osd-xsrf:true" \
42-
--header "securitytenant: global" \
4341
--data '{
4442
"attributes": {
4543
"title":"Logs",

stacks/opensearch-rag/jupyterlab.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@ spec:
3131
env:
3232
- name: JUPYTER_PORT
3333
value: "8888"
34-
- name: OPENSEARCH_HOST
35-
value: "opensearch"
36-
- name: OPENSEARCH_PORT
37-
value: "9200"
3834
- name: OPENSEARCH_USER
3935
value: "admin"
4036
- name: OPENSEARCH_PASSWORD
@@ -48,6 +44,9 @@ spec:
4844
value: "11434"
4945
- name: OLLAMA_LLM_MODEL
5046
value: "{{ ollamaLlmModel }}"
47+
envFrom:
48+
- configMapRef:
49+
name: opensearch
5150
ports:
5251
- name: http
5352
containerPort: 8888

stacks/opensearch-rag/opensearch-rag.ipynb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,18 @@
6868
"warnings.filterwarnings('ignore')\n",
6969
"\n",
7070
"# Configuration from environment variables\n",
71-
"OPENSEARCH_HOST = os.getenv('OPENSEARCH_HOST')\n",
71+
"OPENSEARCH_HOSTS = os.getenv('OPENSEARCH_HOSTS')\n",
72+
"OPENSEARCH_HOSTNAME = os.getenv('OPENSEARCH_HOSTNAME')\n",
7273
"OPENSEARCH_PORT = int(os.getenv('OPENSEARCH_PORT'))\n",
74+
"OPENSEARCH_PROTOCOL = os.getenv('OPENSEARCH_PROTOCOL')\n",
7375
"OPENSEARCH_USER = os.getenv('OPENSEARCH_USER')\n",
7476
"OPENSEARCH_PASSWORD = os.getenv('OPENSEARCH_PASSWORD')\n",
7577
"OLLAMA_HOST = os.getenv('OLLAMA_HOST')\n",
7678
"OLLAMA_PORT = int(os.getenv('OLLAMA_PORT'))\n",
7779
"OLLAMA_LLM_MODEL = os.getenv('OLLAMA_LLM_MODEL')\n",
7880
"INDEX_NAME = 'rag-documents'\n",
7981
"\n",
80-
"print(f\"OpenSearch: {OPENSEARCH_HOST}:{OPENSEARCH_PORT}\")\n",
82+
"print(f\"OpenSearch: {OPENSEARCH_HOSTS}\")\n",
8183
"print(f\"Ollama: {OLLAMA_HOST}:{OLLAMA_PORT} using {OLLAMA_LLM_MODEL} to generate responses\")\n",
8284
"print(f\"Index: {INDEX_NAME}\")"
8385
]
@@ -101,9 +103,9 @@
101103
"source": [
102104
"# Initialize OpenSearch client\n",
103105
"opensearch_client = OpenSearch(\n",
104-
" hosts=[{'host': OPENSEARCH_HOST, 'port': OPENSEARCH_PORT}],\n",
106+
" hosts=[{'host': OPENSEARCH_HOSTNAME, 'port': OPENSEARCH_PORT}],\n",
105107
" http_auth=(OPENSEARCH_USER, OPENSEARCH_PASSWORD),\n",
106-
" use_ssl=True,\n",
108+
" use_ssl=OPENSEARCH_PROTOCOL == 'https',\n",
107109
" verify_certs=False,\n",
108110
" ssl_show_warn=False\n",
109111
")\n",

stacks/opensearch-rag/opensearch.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ stringData:
9090
authentication_backend:
9191
type: intern
9292
authz: {}
93+
kibana:
94+
multitenancy_enabled: false
9395
internal_users.yml: |
9496
---
9597
_meta:

0 commit comments

Comments
 (0)