-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path30-test-opensearch.yaml
More file actions
115 lines (105 loc) · 2.79 KB
/
30-test-opensearch.yaml
File metadata and controls
115 lines (105 loc) · 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
---
apiVersion: batch/v1
kind: Job
metadata:
name: test-opensearch
spec:
template:
spec:
containers:
- name: test-opensearch
image: oci.stackable.tech/sdp/testing-tools:0.3.0-stackable0.0.0-dev
command:
- /bin/bash
- -euxo
- pipefail
- -c
args:
- |
pip install opensearch-py==3.0.0
python scripts/test.py
env:
# required for pip install
- name: HOME
value: /stackable
- name: NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
volumeMounts:
- name: script
mountPath: /stackable/scripts
- name: tls
mountPath: /stackable/tls
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
runAsNonRoot: true
resources:
requests:
memory: 128Mi
cpu: 100m
limits:
memory: 128Mi
cpu: 400m
volumes:
- name: script
configMap:
name: test-opensearch
- name: tls
ephemeral:
volumeClaimTemplate:
metadata:
annotations:
secrets.stackable.tech/class: tls
spec:
storageClassName: secrets.stackable.tech
accessModes:
- ReadWriteOnce
resources:
requests:
storage: "1"
serviceAccountName: test-service-account
securityContext:
fsGroup: 1000
restartPolicy: OnFailure
---
apiVersion: v1
kind: ConfigMap
metadata:
name: test-opensearch
data:
test.py: |
import os
from opensearchpy import OpenSearch
namespace = os.environ['NAMESPACE']
host = f'opensearch.{namespace}.svc.cluster.local'
port = 9200
auth = ('integrationtest', 'integrationtest')
ca_certs_path = '/stackable/tls/ca.crt'
client = OpenSearch(
hosts = [{'host': host, 'port': port}],
http_compress = True,
http_auth = auth,
use_ssl = True,
verify_certs = True,
ca_certs = ca_certs_path
)
# Create an index
index_name = 'test-index'
response = client.indices.create(index=index_name)
print(f'Creating index; {response=}')
# Add a document to the index
response = client.index(
index = index_name,
body = {
'name': 'Stackable'
},
id = 1,
)
print(f'Adding document; {response=}')
# Delete the index.
response = client.indices.delete(index=index_name)
print(f'Deleting index; {response=}')