Skip to content

Commit 076e9fe

Browse files
committed
Change to default OpenSearch Dashboards index name
1 parent a8c95aa commit 076e9fe

File tree

6 files changed

+162
-44
lines changed

6 files changed

+162
-44
lines changed

config/schemas/config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6643,9 +6643,9 @@ properties:
66436643
type: boolean
66446644
default: true
66456645
tektonPipelines:
6646-
title: Network Policies Tekton Piepline
6646+
title: Network Policies Tekton Pipeline
66476647
description: |-
6648-
Enable network policies for tekton and the peipline.
6648+
Enable network policies for tekton and the pipeline.
66496649
type: object
66506650
additionalProperties: false
66516651
properties:

helmfile.d/values/opensearch/dashboards.yaml.gotmpl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ config:
1212
- Authorization
1313
- securitytenant
1414

15-
opensearchDashboards:
16-
index: .opensearch_dashboards
17-
1815
opensearch_security:
1916
{{ if .Values.opensearch.sso.enabled }}
2017
auth:

helmfile.d/values/opensearch/securityadmin.yaml.gotmpl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ securityConfig:
99

1010
config:
1111
dynamic:
12+
kibana:
13+
server_username: dashboards
1214
authc:
1315
basic_internal_auth_domain:
1416
description: "Authenticate via HTTP Basic against internal users database"

migration/v0.43/README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,16 @@ As with all scripts in this repository `CK8S_CONFIG_PATH` is expected to be set.
8282
./bin/ck8s upgrade wc v0.43 apply
8383
```
8484

85+
1. If Tekton is enabled, ensure to add appropriate network policies that allow traffic to OpenSearch.
86+
87+
To check if the tekton is enabled, run the following command
88+
89+
```
90+
yq4 '.tektonPipelines.enabled == true' $CK8S_CONFIG_PATH/sc-config.yaml
91+
```
92+
93+
Example of how the network policies for the pipeline can be found on the [documentation page](https://elastisys.io/welkin/operator-manual/schema/config-properties-network-policies-config-properties-network-policies-tekton-pipeline/#pipeline).
94+
8595
1. Apply upgrade - *disruptive*
8696

8797
> *Done during maintenance window.*
@@ -137,7 +147,7 @@ As with all scripts in this repository `CK8S_CONFIG_PATH` is expected to be set.
137147
1. Upgrade Opensearch:
138148

139149
```bash
140-
./migration/v0.43/apply/10-upgrade-opensearch.sh execute
150+
./migration/v0.43/apply/20-upgrade-opensearch.sh execute
141151
```
142152

143153
1. Upgrade applications:

migration/v0.43/apply/10-upgrade-opensearch.sh

Lines changed: 0 additions & 38 deletions
This file was deleted.
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
#!/usr/bin/env bash
2+
3+
ROOT="$(readlink -f "$(dirname "${0}")/../../../")"
4+
5+
# shellcheck source=scripts/migration/lib.sh
6+
source "${ROOT}/scripts/migration/lib.sh"
7+
8+
run() {
9+
case "${1:-}" in
10+
execute)
11+
12+
if [[ "${CK8S_CLUSTER}" =~ ^(sc|both)$ ]]; then
13+
log_info "operation on service cluster"
14+
15+
16+
user="admin"
17+
password=$(sops --config "${CK8S_CONFIG_PATH}/.sops.yaml" -d "${CK8S_CONFIG_PATH}"/secrets.yaml | yq4 '.opensearch.adminPassword')
18+
os_url=https://opensearch.$(yq4 '.global.opsDomain' "${CK8S_CONFIG_PATH}"/common-config.yaml)
19+
20+
resp=$(curl -sS -kL -u "${user}:${password}" -X GET "${os_url}"/.kibana_1)
21+
if [[ $(echo "${resp}" | jq -r 'to_entries | .[0].key') == ".kibana_1" ]]; then
22+
23+
log_info "- Index .kibana_1 already exists, skipping"
24+
25+
elif [[ $(echo "${resp}" | jq -r '.error.type') == "index_not_found_exception" ]]; then
26+
27+
log_info "- Cloning index .opensearch_dashboards to .kibana"
28+
29+
log_info "- Getting name of .opensearch_dashboards index"
30+
os_dashboards_index=$(curl -sS -kL -u "${user}:${password}" -X GET "${os_url}"/_alias/.opensearch_dashboards | jq -r 'to_entries | .[0].key')
31+
32+
if [[ "${os_dashboards_index}" != .opensearch_dashboards* ]]; then
33+
log_fatal "Failed to get index name of the .opensearch_dashboards alias"
34+
fi
35+
36+
log_info "- Marking index '${os_dashboards_index}' as read-only"
37+
resp=$(curl -sS -kL -u "${user}:${password}" -X PUT "${os_url}"/"${os_dashboards_index}"/_settings -H 'Content-Type: application/json' -d'
38+
{
39+
"settings": {
40+
"index.blocks.write": true
41+
}
42+
}
43+
')
44+
45+
acknowledged=$(echo "${resp}" | grep "^{" | jq -r '.acknowledged')
46+
if [ "${acknowledged}" = "true" ]; then
47+
log_info "- Marked '${os_dashboards_index}' as read-only"
48+
else
49+
log_fatal "Failed to mark index '${os_dashboards_index}' as read-only" "${resp}"
50+
fi
51+
52+
log_info "- Cloning index '${os_dashboards_index}' to index .kibana_1"
53+
resp=$(curl -sS -kL -u "${user}:${password}" -X PUT "${os_url}"/"${os_dashboards_index}"/_clone/.kibana_1)
54+
acknowledged=$(echo "${resp}" | grep "^{" | jq -r '.acknowledged')
55+
if [ "${acknowledged}" = "true" ]; then
56+
log_info "- Successfully cloned '${os_dashboards_index}' to .kibana_1"
57+
else
58+
log_fatal "Failed to clone index '${os_dashboards_index}' to .kibana_1" "${resp}"
59+
fi
60+
61+
62+
log_info "- Disabling read-only mode for '${os_dashboards_index}'"
63+
resp=$(curl -sS -kL -u "${user}:${password}" -X PUT "${os_url}"/"${os_dashboards_index}"/_settings -H 'Content-Type: application/json' -d'
64+
{
65+
"settings": {
66+
"index.blocks.write": false
67+
}
68+
}
69+
')
70+
acknowledged=$(echo "${resp}" | grep "^{" | jq -r '.acknowledged')
71+
if [ "${acknowledged}" = "true" ]; then
72+
log_info "- Successfully disabled read-only mode for '${os_dashboards_index}'"
73+
else
74+
log_fatal "Failed to disable read-only mode for '${os_dashboards_index}'" "${resp}"
75+
fi
76+
77+
log_info "- Disabling read-only mode for .kibana_1"
78+
resp=$(curl -sS -kL -u "${user}:${password}" -X PUT "${os_url}"/.kibana_1/_settings -H 'Content-Type: application/json' -d'
79+
{
80+
"settings": {
81+
"index.blocks.write": false
82+
}
83+
}
84+
')
85+
acknowledged=$(echo "${resp}" | grep "^{" | jq -r '.acknowledged')
86+
if [ "${acknowledged}" = "true" ]; then
87+
log_info "- Successfully disabled read-only mode for .kibana_1"
88+
else
89+
log_fatal "Failed to disable read-only mode for .kibana_1" "${resp}"
90+
fi
91+
else
92+
log_fatal "Failed to check if index .kibana_1 already exists" "${resp}"
93+
fi
94+
95+
resp=$(curl -sS -kL -u "${user}:${password}" -X GET "${os_url}"/_alias/.kibana)
96+
if [[ $(echo "${resp}" | jq -r 'to_entries | .[0].key') == .kibana* ]]; then
97+
log_info "- Alias .kibana already exists, skipping"
98+
elif [[ $(echo "${resp}" | jq -r '.status') == "404" ]]; then
99+
log_info "- Creating alias .kibana"
100+
resp=$(curl -sS -kL -u "${user}:${password}" -X PUT "${os_url}"/.kibana_1/_aliases/.kibana)
101+
acknowledged=$(echo "${resp}" | grep "^{" | jq -r '.acknowledged')
102+
if [ "${acknowledged}" = "true" ]; then
103+
log_info "- Successfully created alias .kibana"
104+
else
105+
log_fatal "Failed to create alias .kibana" "${resp}"
106+
fi
107+
else
108+
log_fatal "Failed to check if alias .kibana exists" "${resp}"
109+
fi
110+
111+
os_dashboards_index=$(curl -sS -kL -u "${user}:${password}" -X GET "${os_url}"/_alias/.opensearch_dashboards | jq -r 'to_entries | .[0].key')
112+
if [[ "${os_dashboards_index}" != .opensearch_dashboards* ]]; then
113+
log_info "- Skipping: Alias .opensearch_dashboards doesn't exist"
114+
else
115+
log_info "- Deleting index '${os_dashboards_index}'"
116+
resp=$(curl -sS -kL -u "${user}:${password}" -X DELETE "${os_url}"/"${os_dashboards_index}")
117+
acknowledged=$(echo "${resp}" | grep "^{" | jq -r '.acknowledged')
118+
if [ "${acknowledged}" = "true" ]; then
119+
log_info "- Successfully deleted index '${os_dashboards_index}'"
120+
else
121+
log_fatal "Failed to delete index '${os_dashboards_index}'" "${resp}"
122+
fi
123+
fi
124+
125+
log_info "- Removing opensearch-configurer"
126+
helmfile_destroy sc name=opensearch-configurer
127+
log_info "- Upgrading Opensearch"
128+
helmfile_do sc -lapp=opensearch sync
129+
fi
130+
;;
131+
rollback)
132+
log_warn "rollback not implemented"
133+
134+
# if [[ "${CK8S_CLUSTER}" =~ ^(sc|both)$ ]]; then
135+
# log_info "rollback operation on service cluster"
136+
# fi
137+
# if [[ "${CK8S_CLUSTER}" =~ ^(wc|both)$ ]]; then
138+
# log_info "rollback operation on workload cluster"
139+
# fi
140+
;;
141+
*)
142+
log_fatal "usage: \"${0}\" <execute|rollback>"
143+
;;
144+
esac
145+
}
146+
147+
run "${@}"

0 commit comments

Comments
 (0)