Skip to content

Commit 15730a2

Browse files
TheAlgobbaraniDandyDevelopersmlxbelfhi
authored
Migrate helm charts from opensearch-devops repo (opensearch-project#7)
* Adding a new folder to host Helm related code * Helm Chart for OpenSearch (opensearch-project#4) * Create basic structure of OpenSearch helm chart * Add templates and change values * Change statefulset and configmap to resolve indentation issue * Fix issues in templates * Fix typos in statefulset.yaml * Add multinode deployment feature * Update version to reflect the OpenSearch version * Add explicit security configuration * Update values.yaml * Create placeholder README.md * Minimum masters should be 3 * Add YAML support for config. sysctl vm.mem fix. * Fixing PSP. Adding better sysctl logic. * Adding ref for systctl * PSP False by default * Disable HTTP SSL by default for Demo. * Fix Chart version to sync with OpenSearch Version * Change cluster name and enable SSL by default Co-authored-by: Aaron Layfield <[email protected]> * fix: give networkpolicy objects a unique name (opensearch-project#16) This fixes the problem of installing this chart multiple times in the same namespace and having the network policy name conflict. * fix: use the stable chart appVersion as image tag by default (opensearch-project#17) Using :latest by default is going to lead to clusters with version skew as pods schedule onto new nodes. So use a stable tag instead. * OpenSearch Dashboards Helm Chart (opensearch-project#10) * Scaffold OpenSearch Dashboards Helm Chart * Fix error for connection refused * Add RBAC functionality * Add security configurations in the chart * Address issues and comments * Fix templates * Disable SSL by default * Address comments for beautification * Address comments * chore: update demo config section (opensearch-project#24) This snippet doesn't make sense in a kubernetes statefulset. * added secretMounts to values.yaml w/ example config (opensearch-project#29) Co-authored-by: johannes.reppin <[email protected]> * Change persistence config to make it more coherent w/ other helm charts (opensearch-project#33) Co-authored-by: johannes.reppin <[email protected]> * add Volumes and change broken (!) yaml indentation (opensearch-project#31) Co-authored-by: johannes.reppin <[email protected]> * support for current ingress apiVersion (opensearch-project#47) * Helm Chart Fixes for Env variables and volumes (opensearch-project#35) * Helm Chart Fixes for Env variables and volumes The opensearch-dashboards chart failed to render correctly when utilizing the extraEnvs flag, caused by incorrect indentation. The opensearch chart failed to render when utlizing the secrets for the security config, this was due to them being in the env section. This pull request reqolves both issues, verified via running helm template with the minumal values files included here: ```yaml envFrom: - secretRef: name: kibana-secrets extraEnvs: - name: TENANT_ID valueFrom: secretKeyRef: name: kibana-secrets key: tenantID ``` ```yaml securityConfig: enabled: true configSecret: "security-config" internalUsersSecret: "internal-users-config" rolesMappingSecret: "roles-mapping-config" rolesSecret: "roles-config" ``` * Updating paths in sts to be dynamic Updating the paths specified in the sts for opensearch to utilize .Values.opensearchHome to allow for dynamic paths, with a default of `/usr/share/opensearch` which should be sufficient for most users. * Fixing config path in opensearch-dashboards (opensearch-project#38) * Fixing config path in opensearch-dashboards The manifests rendered by the Helm chart place the user provided config into the incorrect directory. This simply updates that location to the correct path and updates the values.yaml file to use the correct default config file so that the user provided setting override the defaults. * Updating cert paths to opensearch-dashboards Cert paths also need to utilize new filesystem location for opensearch-dashboards config. * Resolves issue with securityConfig path (opensearch-project#41) * Resolves issue with securityConfig path Issue opensearch-project#39 This updates the securityConfig path in values to use the correct value for opensearch. * Fixing bad auto formatting Removing unneeded indentation/newlines. * Fixing missed auto formatting errors * resolve issue about .Values.opensearchHome (opensearch-project#52) refer to this: opensearch-project/opensearch-devops@fe831db#commitcomment-55395428 Error Msg: nil pointer evaluating interface {}.opensearchHome * Fix helm chart can not be deployed without ssl (opensearch-project#56) * Fixing issue exposed by changes in opensearch-project#38 After switching the name of the config file, and removing the shadowing between the default (from the docker container opensearch-dashbaords.yaml) and the default from the helm chart (dashboards.yaml) there is an issue with the certs that are attempting to be used. In order for this to work with the defaults, disabled TLS verification will be needed, and then disabling TLS to remain in line with the defaults. I added a commented out section showing what could potentially be used as TLS config if the user chooses to enable it. * Using conventional yaml formatting for ssl config Moving comments around to follow relevant code and utilizing nested yaml format rather than dot format. * Changing Folder name to Charts * Change deafult configuration for dashboards * Update securityconfig.yaml to remove extra spaces Co-authored-by: Barani <[email protected]> Co-authored-by: Aaron Layfield <[email protected]> Co-authored-by: Scott Leggett <[email protected]> Co-authored-by: Johannes Reppin <[email protected]> Co-authored-by: johannes.reppin <[email protected]> Co-authored-by: paltryeffort <[email protected]> Co-authored-by: hgoscenski-imanage <[email protected]> Co-authored-by: Nagle Zhang <[email protected]>
1 parent 246bd3d commit 15730a2

28 files changed

+1818
-0
lines changed

charts/README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
2+
This Helm chart is a lightweight way to configure and run the official [OpenSearch Docker image](https://hub.docker.com/r/opensearchproject/opensearch).
3+
4+
5+
- [Installing](#installing)
6+
- [Usage notes](#usage-notes)
7+
- [Configuration](#configuration)
8+
- [Future](#Future)
9+
10+
11+
12+
## Installing
13+
14+
This chart is tested with the latest 1.0.0-rc1 version.
15+
16+
* Clone this repo
17+
* Install it:
18+
- with Helm 3: `helm install oss ./Helm/opensearch`
19+
20+
## Usage notes
21+
22+
* The chart deploys a StatefulSet and by default will do an automated rolling
23+
update of your cluster. It does this by waiting for the cluster health to become
24+
green after each instance is updated.
25+
* It is important to verify that the JVM heap size in `esJavaOpts` and to set
26+
the CPU/Memory `resources` to something suitable for your cluster.
27+
* To simplify chart and maintenance each set of node groups is deployed as a
28+
separate Helm release. Without doing this it isn't possible to resize persistent
29+
volumes in a StatefulSet. By setting it up this way it makes it possible to add
30+
more nodes with a new storage size then drain the old ones. It also solves the
31+
problem of allowing the user to determine which node groups to update first when
32+
doing upgrades or changes.
33+
* We have designed this chart to be very un-opinionated about how to configure
34+
OpenSearch. It exposes ways to set environment variables and mount secrets
35+
inside of the container. Doing this makes it much easier for this chart to
36+
support multiple versions with minimal changes.
37+
38+
## Configuration
39+
TODO : Write about all the parameters used
40+
41+
42+
## Future
43+
* Create example for different types of configurations for different K8S providers.
44+
* Have a chart for deploying the OpenSearch stack comprising OpenSearch and OpenSearch Dashboards
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: v2
2+
name: opensearch-dashboards
3+
description: A Helm chart for OpenSearch Dashboards
4+
5+
# A chart can be either an 'application' or a 'library' chart.
6+
#
7+
# Application charts are a collection of templates that can be packaged into versioned archives
8+
# to be deployed.
9+
#
10+
# Library charts provide useful utilities or functions for the chart developer. They're included as
11+
# a dependency of application charts to inject those utilities and functions into the rendering
12+
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
13+
type: application
14+
15+
# This is the chart version. This version number should be incremented each time you make changes
16+
# to the chart and its templates, including the app version.
17+
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18+
version: 1.0.0
19+
20+
# This is the version number of the application being deployed. This version number should be
21+
# incremented each time you make changes to the application. Versions are not expected to
22+
# follow Semantic Versioning. They should reflect the version the application is using.
23+
# It is recommended to use it with quotes.
24+
appVersion: "1.0.0"
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
1. Get the application URL by running these commands:
2+
{{- if .Values.ingress.enabled }}
3+
{{- range $host := .Values.ingress.hosts }}
4+
{{- range .paths }}
5+
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
6+
{{- end }}
7+
{{- end }}
8+
{{- else if contains "NodePort" .Values.service.type }}
9+
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "opensearch-dashboards.fullname" . }})
10+
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
11+
echo http://$NODE_IP:$NODE_PORT
12+
{{- else if contains "LoadBalancer" .Values.service.type }}
13+
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
14+
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "opensearch-dashboards.fullname" . }}'
15+
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "opensearch-dashboards.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
16+
echo http://$SERVICE_IP:{{ .Values.service.port }}
17+
{{- else if contains "ClusterIP" .Values.service.type }}
18+
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "opensearch-dashboards.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
19+
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
20+
echo "Visit http://127.0.0.1:8080 to use your application"
21+
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
22+
{{- end }}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "opensearch-dashboards.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "opensearch-dashboards.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{/*
27+
Create chart name and version as used by the chart label.
28+
*/}}
29+
{{- define "opensearch-dashboards.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "opensearch-dashboards.labels" -}}
37+
helm.sh/chart: {{ include "opensearch-dashboards.chart" . }}
38+
{{ include "opensearch-dashboards.selectorLabels" . }}
39+
{{- if .Chart.AppVersion }}
40+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
41+
{{- end }}
42+
app.kubernetes.io/managed-by: {{ .Release.Service }}
43+
{{- end }}
44+
45+
{{/*
46+
Selector labels
47+
*/}}
48+
{{- define "opensearch-dashboards.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "opensearch-dashboards.name" . }}
50+
app.kubernetes.io/instance: {{ .Release.Name }}
51+
{{- end }}
52+
53+
{{/*
54+
Create the name of the service account to use
55+
*/}}
56+
{{- define "opensearch-dashboards.serviceAccountName" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "opensearch-dashboards.fullname" .) .Values.serviceAccount.name }}-dashboards
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- end }}
63+
64+
{{/*
65+
Define standard labels for frequently used metadata.
66+
*/}}
67+
{{- define "opensearch-dashboards.standard" -}}
68+
app: {{ template "opensearch-dashboards.fullname" . }}
69+
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
70+
release: "{{ .Release.Name }}"
71+
heritage: "{{ .Release.Service }}"
72+
{{- end -}}
73+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{{- if .Values.config -}}
2+
apiVersion: v1
3+
kind: ConfigMap
4+
metadata:
5+
name: {{ template "opensearch-dashboards.fullname" . }}-config
6+
labels: {{ include "opensearch-dashboards.labels" . | nindent 4 }}
7+
data:
8+
{{- range $configName, $configYaml := .Values.config }}
9+
{{ $configName }}: |
10+
{{- toYaml $configYaml | nindent 4 }}
11+
{{- end }}
12+
{{- end -}}
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ template "opensearch-dashboards.fullname" . }}
5+
labels: {{- include "opensearch-dashboards.labels" . | nindent 4 }}
6+
spec:
7+
replicas: {{ .Values.replicaCount }}
8+
strategy:
9+
{{ toYaml .Values.updateStrategy | indent 4 }}
10+
selector:
11+
matchLabels:
12+
app: {{ .Chart.Name }}
13+
release: {{ .Release.Name | quote }}
14+
template:
15+
metadata:
16+
labels:
17+
app: {{ .Chart.Name }}
18+
release: {{ .Release.Name | quote }}
19+
{{- range $key, $value := .Values.labels }}
20+
{{ $key }}: {{ $value | quote }}
21+
{{- end }}
22+
annotations:
23+
{{- range $key, $value := .Values.podAnnotations }}
24+
{{ $key }}: {{ $value | quote }}
25+
{{- end }}
26+
{{- /* This forces a restart if the configmap has changed */}}
27+
{{- if .Values.config }}
28+
configchecksum: {{ include (print .Template.BasePath "/configmap.yaml") . | sha256sum | trunc 63 }}
29+
{{- end }}
30+
spec:
31+
{{- if .Values.priorityClassName }}
32+
priorityClassName: {{ .Values.priorityClassName }}
33+
{{- end }}
34+
securityContext:
35+
{{ toYaml .Values.podSecurityContext | indent 8 }}
36+
serviceAccountName: {{ template "opensearch-dashboards.serviceAccountName" . }}
37+
{{- if .Values.hostAliases }}
38+
hostAliases: {{ toYaml .Values.hostAliases | nindent 6 }}
39+
{{- end }}
40+
volumes:
41+
{{- range .Values.secretMounts }}
42+
- name: {{ .name }}
43+
secret:
44+
secretName: {{ .secretName }}
45+
{{- end }}
46+
{{- if .Values.config }}
47+
- name: config
48+
configMap:
49+
name: {{ template "opensearch-dashboards.fullname" . }}-config
50+
{{- end }}
51+
{{- with .Values.nodeSelector }}
52+
nodeSelector:
53+
{{ toYaml . | indent 8 }}
54+
{{- end }}
55+
{{- with .Values.affinity }}
56+
affinity:
57+
{{ toYaml . | indent 8 }}
58+
{{- end }}
59+
{{- with .Values.tolerations }}
60+
tolerations:
61+
{{ toYaml . | indent 8 }}
62+
{{- end }}
63+
{{- if .Values.imagePullSecrets }}
64+
imagePullSecrets:
65+
{{ toYaml .Values.imagePullSecrets | indent 8 }}
66+
{{- end }}
67+
{{- if .Values.extraInitContainers }}
68+
# Currently some extra blocks accept strings
69+
# to continue with backwards compatibility this is being kept
70+
# whilst also allowing for yaml to be specified too.
71+
initContainers:
72+
{{- if eq "string" (printf "%T" .Values.extraInitContainers) }}
73+
{{ tpl .Values.extraInitContainers . | indent 6 }}
74+
{{- else }}
75+
{{ toYaml .Values.extraInitContainers | indent 6 }}
76+
{{- end }}
77+
{{- end }}
78+
containers:
79+
- name: dashboards
80+
securityContext:
81+
{{ toYaml .Values.securityContext | indent 10 }}
82+
image: "{{ .Values.image }}:{{ .Values.imageTag | default .Chart.AppVersion }}"
83+
imagePullPolicy: "{{ .Values.imagePullPolicy }}"
84+
env:
85+
{{- if .Values.opensearchURL }}
86+
- name: OPENSEARCH_URL
87+
value: "{{ .Values.opensearchURL }}"
88+
{{- else if .Values.opensearchHosts }}
89+
- name: OPENSEARCH_HOSTS
90+
value: "{{ .Values.opensearchHosts }}"
91+
{{- end }}
92+
- name: SERVER_HOST
93+
value: "{{ .Values.serverHost }}"
94+
{{- if .Values.opensearchAccount.secret }}
95+
- name: OPENSEARCH_USERNAME
96+
valueFrom:
97+
secretKeyRef:
98+
name: {{ .Values.opensearchAccount.secret }}
99+
key: username
100+
- name: OPENSEARCH_PASSWORD
101+
valueFrom:
102+
secretKeyRef:
103+
name: {{ .Values.opensearchAccount.secret }}
104+
key: password
105+
{{- if and .Values.opensearchAccount.keyPassphrase.enabled }}
106+
- name: KEY_PASSPHRASE
107+
valueFrom:
108+
secretKeyRef:
109+
name: {{ .Values.opensearchAccount.secret }}
110+
key: keypassphrase
111+
# 32-character random string to be used as cookie password by security plugin
112+
{{- end }}
113+
- name: COOKIE_PASS
114+
valueFrom:
115+
secretKeyRef:
116+
name: {{ .Values.opensearchAccount.secret }}
117+
key: cookie
118+
{{- end }}
119+
{{- if .Values.extraEnvs }}
120+
{{ toYaml .Values.extraEnvs | indent 8 }}
121+
{{- end }}
122+
{{- if .Values.envFrom }}
123+
envFrom:
124+
{{ toYaml .Values.envFrom | indent 10 }}
125+
{{- end }}
126+
ports:
127+
- containerPort: {{ .Values.service.port }}
128+
name: {{ .Values.service.httpPortName | default "http" }}
129+
protocol: TCP
130+
{{- if .Values.lifecycle }}
131+
lifecycle:
132+
{{ toYaml .Values.lifecycle | indent 10 }}
133+
{{- end }}
134+
resources:
135+
{{ toYaml .Values.resources | indent 10 }}
136+
volumeMounts:
137+
{{- range .Values.secretMounts }}
138+
- name: {{ .name }}
139+
mountPath: {{ .path }}
140+
{{- if .subPath }}
141+
subPath: {{ .subPath }}
142+
{{- end }}
143+
{{- end }}
144+
{{- range $path, $config := .Values.config }}
145+
- name: config
146+
mountPath: /usr/share/opensearch-dashboards/config/{{ $path }}
147+
subPath: {{ $path }}
148+
{{- end }}
149+
{{- if .Values.extraContainers }}
150+
# Currently some extra blocks accept strings
151+
# to continue with backwards compatibility this is being kept
152+
# whilst also allowing for yaml to be specified too.
153+
{{- if eq "string" (printf "%T" .Values.extraContainers) }}
154+
{{ tpl .Values.extraContainers . | indent 6 }}
155+
{{- else }}
156+
{{ toYaml .Values.extraContainers | indent 6 }}
157+
{{- end }}
158+
{{- end }}

0 commit comments

Comments
 (0)