Skip to content

Commit 68016a1

Browse files
kcrwilunkan93
andauthored
apps: Removal of previous work-around to increase vm.max_map_count for OpenSearch (#2723)
Co-authored-by: Simon Lundkvist <[email protected]>
1 parent fe3c283 commit 68016a1

File tree

9 files changed

+35
-53
lines changed

9 files changed

+35
-53
lines changed

helmfile.d/lists/images.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ images:
7575
image: registry.k8s.io/dns/k8s-dns-node-cache:1.25.0
7676
opensearch:
7777
image: docker.io/opensearchproject/opensearch:2.19.3
78-
initSysctl: ghcr.io/elastisys/curl-jq:1.0.0
7978
dashboards: docker.io/opensearchproject/opensearch-dashboards:2.19.3
8079
configurerJob: ghcr.io/elastisys/curl-jq:1.0.0
8180
curatorCronjob: ghcr.io/elastisys/bitnami/elasticsearch-curator:5.8.4-debian-10-r235

helmfile.d/stacks/opensearch.yaml.gotmpl

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,6 @@ templates:
66
labels:
77
app: opensearch
88

9-
opensearch-podsecuritypolicy:
10-
inherit:
11-
- template: opensearch
12-
- template: podsecuritypolicies
13-
installed: {{ and (.Values | get "ck8sManagementCluster.enabled" false) (.Values | get "opensearch.enabled" false) }}
14-
labels:
15-
psp: opensearch
16-
values:
17-
- values/podsecuritypolicies/service/opensearch.yaml.gotmpl
18-
199
opensearch-secrets:
2010
disableValidationOnInstall: true # creates cert-manager/certificates
2111
inherit: [ template: opensearch ]
@@ -41,7 +31,6 @@ templates:
4131
{{- end }}
4232
- kube-system/service-cluster-np
4333
- opensearch-system/opensearch-secrets
44-
- opensearch-system/podsecuritypolicy
4534
values:
4635
- values/opensearch/common.yaml.gotmpl
4736
- values/opensearch/master.yaml.gotmpl
@@ -56,7 +45,6 @@ templates:
5645
needs:
5746
- kube-system/service-cluster-np
5847
- opensearch-system/opensearch-master
59-
- opensearch-system/podsecuritypolicy
6048
values:
6149
- values/opensearch/common.yaml.gotmpl
6250
- values/opensearch/client.yaml.gotmpl
@@ -71,7 +59,6 @@ templates:
7159
needs:
7260
- kube-system/service-cluster-np
7361
- opensearch-system/opensearch-master
74-
- opensearch-system/podsecuritypolicy
7562
values:
7663
- values/opensearch/common.yaml.gotmpl
7764
- values/opensearch/data.yaml.gotmpl
@@ -89,7 +76,6 @@ templates:
8976
{{- end }}
9077
- kube-system/service-cluster-np
9178
- opensearch-system/opensearch-master
92-
- opensearch-system/podsecuritypolicy
9379
values:
9480
- values/opensearch/dashboards.yaml.gotmpl
9581
wait: true

helmfile.d/state.yaml.gotmpl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ releases:
163163
- inherit: [ template: harbor-backup ]
164164
- inherit: [ template: harbor-mpu-cleaner ]
165165

166-
- inherit: [ template: opensearch-podsecuritypolicy ]
167166
- inherit: [ template: opensearch-secrets ]
168167
- inherit: [ template: opensearch-master ]
169168
- inherit: [ template: opensearch-client ]

helmfile.d/values/admin-namespaces-sc.yaml.gotmpl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ namespaces:
6767
pod-security.kubernetes.io/warn: privileged
6868
- name: opensearch-system
6969
labels:
70-
pod-security.kubernetes.io/audit: privileged
71-
pod-security.kubernetes.io/enforce: privileged
72-
pod-security.kubernetes.io/warn: privileged
70+
pod-security.kubernetes.io/audit: restricted
71+
pod-security.kubernetes.io/enforce: restricted
72+
pod-security.kubernetes.io/warn: restricted
7373
{{ if or (.Values.objectStorage.sync.enabled) (.Values.objectStorage.restore.enabled) }}
7474
- name: rclone
7575
labels:

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

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -125,28 +125,6 @@ extraEnvs:
125125
- name: DISABLE_INSTALL_DEMO_CONFIG
126126
value: "true"
127127

128-
# This is a workaround to set vm.max_map_count before OpenSearch starts.
129-
# The chart provides this using non privileged container, and instead allows the unsafe sysctl through PSP.
130-
# However this relies on the unsafe sysctl to be allowed in kubelet, which it is not by default.
131-
extraInitContainers:
132-
- name: init-sysctl
133-
{{- with .Values.images | dig "opensearch" "initSysctl" "" }}
134-
{{- with merge (include "container_uri.parse" . | fromJson) $global }}
135-
image: "{{- include "gen.container_uri" . }}"
136-
{{- end }}
137-
{{- else }}
138-
image: ghcr.io/elastisys/curl-jq:1.0.0
139-
{{- end }}
140-
command:
141-
- sysctl
142-
- -w
143-
- vm.max_map_count=262144
144-
securityContext:
145-
allowPrivilegeEscalation: true
146-
privileged: true
147-
runAsNonRoot: false
148-
runAsUser: 0
149-
150128
secretMounts:
151129
- secretName: opensearch-transport-cert
152130
name: opensearch-transport-cert

helmfile.d/values/podsecuritypolicies/service/opensearch.yaml.gotmpl

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@ constraints:
44
podSelectorLabels:
55
app.kubernetes.io/name: opensearch
66
allow:
7-
allowPrivilegeEscalation: true
8-
# allowedUnsafeSysctls:
9-
# - vm.max_map_count
10-
privileged: true
11-
runAsUser:
12-
rule: RunAsAny
137
volumes:
148
- configMap
159
- emptyDir

migration/v0.49/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@ As with all scripts in this repository `CK8S_CONFIG_PATH` is expected to be set.
109109
export CK8S_CLUSTER=<wc|sc|both>
110110
```
111111

112+
1. Apply OpenSearch and remove PSPs, as its PSA has been lowered to `restricted`.
113+
114+
```bash
115+
./migration/v0.49/apply/30-opensearch-initContainer.sh
116+
```
117+
112118
1. Update apps configuration:
113119

114120
This will take a backup into `backups/` before modifying any files.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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+
if [[ "${CK8S_CLUSTER}" =~ ^(sc|both)$ ]]; then
12+
log_info "operation on service cluster"
13+
helmfile_upgrade sc app=opensearch
14+
helm_uninstall sc opensearch-system podsecuritypolicy
15+
fi
16+
;;
17+
rollback)
18+
log_warn "rollback not implemented"
19+
;;
20+
*)
21+
log_fatal "usage: \"${0}\" <execute|rollback>"
22+
;;
23+
esac
24+
}
25+
26+
run "${@}"

tests/unit/general/resources/images-parametric-tests.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -270,12 +270,6 @@
270270
"container_name": "opensearch",
271271
"template_file": "sc/opensearch/templates/statefulset.yaml"
272272
},
273-
{
274-
"image_property": "opensearch.initSysctl",
275-
"helmfile_selector": "app=opensearch",
276-
"container_name": "init-sysctl",
277-
"template_file": "sc/opensearch/templates/statefulset.yaml"
278-
},
279273
{
280274
"image_property": "opensearch.dashboards",
281275
"helmfile_selector": "app=opensearch",

0 commit comments

Comments
 (0)