Skip to content

Commit

Permalink
Add Helm Chart for the OpenSearch cluster CR (#478)
Browse files Browse the repository at this point in the history
This fixes #448 
PR to add Helm Chart to install OpenSearch cluster CR.
  • Loading branch information
swoehrl-mw committed Jun 2, 2023
2 parents 868721e + b64c583 commit 72d46e2
Show file tree
Hide file tree
Showing 11 changed files with 481 additions and 4 deletions.
1 change: 1 addition & 0 deletions .github/workflows/functional-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jobs:
## Install helm chart
helm install opensearch-operator ../charts/opensearch-operator --set manager.image.repository=controller --set manager.image.tag=latest --set manager.image.pullPolicy=IfNotPresent --namespace default --wait
helm install opensearch-cluster ../charts/opensearch-cluster --set OpenSearchClusterSpec.enabled=true --wait
cd functionaltests
## Run tests
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/prepare-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ jobs:
# Set versions in helm chart
sed -i -e 's/^appVersion:.*/appVersion: '$RELEASE_VERSION'/' charts/opensearch-operator/Chart.yaml
sed -i -e 's/^version:.*/version: '$RELEASE_VERSION'/' charts/opensearch-operator/Chart.yaml
sed -i -e 's/^appVersion:.*/appVersion: '$RELEASE_VERSION'/' charts/opensearch-cluster/Chart.yaml
sed -i -e 's/^version:.*/version: '$RELEASE_VERSION'/' charts/opensearch-cluster/Chart.yaml
# Commit changes
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
Expand Down
4 changes: 2 additions & 2 deletions MAINTAINERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ The following sections explain what maintainers do in this repo, and how they sh
To release a new version of the operator open Github in the browser, navigate to "Actions", select the workflow `Prepare and publish release`, select "Run workflow", then enter the version of the release (semver, x.y.z) and click "Run workflow". After a few seconds a new workflow run will start. It will do the following:

* Run the test suite to make sure the version is functional
* Update the helm chart with the newest CRD YAMLs
* Update `version` and `appVersion` in the chart
* Update the helm chart for operator with the newest CRD YAMLs
* Update `version` and `appVersion` in both the charts
* Commit and push the chart changes
* Tag the commit
* Build and push the docker image
Expand Down
6 changes: 6 additions & 0 deletions charts/opensearch-cluster/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v2
name: opensearch-cluster
description: A Helm chart for OpenSearch Cluster
type: application
version: 2.2.0
appVersion: 2.2.0
63 changes: 63 additions & 0 deletions charts/opensearch-cluster/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "opensearch-cluster.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "opensearch-cluster.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "opensearch-cluster.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Common labels
*/}}
{{- define "opensearch-cluster.labels" -}}
helm.sh/chart: {{ include "opensearch-cluster.chart" . }}
{{ include "opensearch-cluster.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}

{{/*
Selector labels
*/}}
{{- define "opensearch-cluster.selectorLabels" -}}
app.kubernetes.io/name: {{ include "opensearch-cluster.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end -}}

{{/*
Create the name of the service account to use
*/}}
{{- define "opensearch-cluster.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{ default (include "opensearch-cluster.fullname" .) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}
292 changes: 292 additions & 0 deletions charts/opensearch-cluster/templates/opensearch-cluster-cr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,292 @@
{{- if eq .Values.OpenSearchClusterSpec.enabled true }}
apiVersion: opensearch.opster.io/v1
kind: OpenSearchCluster
metadata:
name: {{ .Values.clusterName | default .Release.Name}}
namespace: {{ .Release.Namespace }}
spec:
{{- if .Values.OpenSearchClusterSpec.bootstrap }}
bootstrap:
{{- if .Values.OpenSearchClusterSpec.bootstrap.additionalConfig }}
additionalConfig:
{{ toYaml .Values.OpenSearchClusterSpec.bootstrap.additionalConfig | nindent 6 }}
{{- end }}
{{- end }}
{{- if .Values.OpenSearchClusterSpec.initHelper }}
initHelper:
{{- if .Values.OpenSearchClusterSpec.initHelper.version }}
version: {{ .Values.OpenSearchClusterSpec.initHelper.version }}
{{ end }}
{{- if .Values.OpenSearchClusterSpec.initHelper.image }}
image: {{ .Values.OpenSearchClusterSpec.initHelper.image }}
{{- end }}
{{- if .Values.OpenSearchClusterSpec.initHelper.imagePullPolicy }}
imagePullPolicy: {{ .Values.OpenSearchClusterSpec.initHelper.imagePullPolicy }}
{{- end }}
{{- if .Values.OpenSearchClusterSpec.initHelper.imagePullSecrets }}
imagePullSecrets:
{{ toYaml .Values.OpenSearchClusterSpec.initHelper.imagePullSecrets | nindent 6 }}
{{- end }}
{{- end }}
general:
{{- if .Values.OpenSearchClusterSpec.general.version }}
version: {{ .Values.OpenSearchClusterSpec.general.version }}
{{- end }}
{{- if .Values.OpenSearchClusterSpec.general.image }}
image: {{ .Values.OpenSearchClusterSpec.general.image | quote }}
{{- end }}
{{- if .Values.OpenSearchClusterSpec.general.httpPort }}
httpPort: {{ .Values.OpenSearchClusterSpec.general.httpPort }}
{{- end }}
vendor: opensearch
serviceName: {{ .Values.OpenSearchClusterSpec.general.serviceName }}
{{- if .Values.OpenSearchClusterSpec.general.pluginsList }}
pluginsList:
{{ toYaml .Values.OpenSearchClusterSpec.general.pluginsList | nindent 6 }}
{{- end }}
{{- if .Values.OpenSearchClusterSpec.general.keystore }}
keystore:
{{ toYaml .Values.OpenSearchClusterSpec.general.keystore | nindent 6 }}
{{- end }}
{{- if .Values.OpenSearchClusterSpec.general.securityContext }}
securityContext:
{{ toYaml .Values.OpenSearchClusterSpec.general.securityContext | nindent 6}}
{{- end}}
{{- if .Values.OpenSearchClusterSpec.general.podSecurityContext }}
podSecurityContext:
{{ toYaml .Values.OpenSearchClusterSpec.general.podSecurityContext | nindent 6 }}
{{- end}}
{{- if .Values.OpenSearchClusterSpec.general.additionalVolumes }}
additionalVolumes:
{{- range $key, $val := .Values.OpenSearchClusterSpec.general.additionalVolumes }}
- name: {{ $val.name }}
path: {{ $val.path }}
secret:
secretName: {{ $val.secret.secretName }}
{{- end -}}
{{- end }}
{{- if .Values.OpenSearchClusterSpec.general.additionalConfig }}
additionalConfig:
{{ toYaml .Values.OpenSearchClusterSpec.general.additionalConfig | nindent 6 }}
{{- end }}
{{- if .Values.OpenSearchClusterSpec.dashboards }}
dashboards:
{{- if .Values.OpenSearchClusterSpec.dashboards.image }}
image: {{ .Values.OpenSearchClusterSpec.dashboards.image | quote }}
{{- end }}
version: {{ .Values.OpenSearchClusterSpec.dashboards.version }}
{{- if .Values.OpenSearchClusterSpec.dashboards.enable }}
enable: {{ .Values.OpenSearchClusterSpec.dashboards.enable }}
{{- end }}
replicas: {{ .Values.OpenSearchClusterSpec.dashboards.replicas }}
{{- if .Values.OpenSearchClusterSpec.dashboards.pluginsList }}
pluginsList:
{{ toYaml .Values.OpenSearchClusterSpec.dashboards.pluginsList | nindent 6 }}
{{- end }}
{{- if .Values.OpenSearchClusterSpec.dashboards.basePath }}
basePath: {{ .Values.OpenSearchClusterSpec.dashboards.basePath }}
{{- end }}
{{- if .Values.OpenSearchClusterSpec.dashboards.labels }}
labels: # Add any extra labels as key-value pairs here
{{ toYaml .Values.OpenSearchClusterSpec.dashboards.labels | nindent 6 }}
{{- end }}
{{- if .Values.OpenSearchClusterSpec.dashboards.annotations }}
annotations: # Add any extra annotations as key-value pairs here
{{ toYaml .Values.OpenSearchClusterSpec.dashboards.annotations | nindent 6 }}
{{- end }}
{{- if .Values.OpenSearchClusterSpec.dashboards.opensearchCredentialsSecret }}
opensearchCredentialsSecret:
name: {{ .Values.OpenSearchClusterSpec.dashboards.opensearchCredentialsSecret.name }}
{{- end }}
{{- if .Values.OpenSearchClusterSpec.dashboards.env }}
env:
{{- toYaml .Values.OpenSearchClusterSpec.dashboards.env | nindent 8 }}
{{- end }}
{{- if .Values.OpenSearchClusterSpec.dashboards.resources }}
resources:
{{- if .Values.OpenSearchClusterSpec.dashboards.resources.requests }}
requests:
{{- if .Values.OpenSearchClusterSpec.dashboards.resources.requests.memory }}
memory: {{ .Values.OpenSearchClusterSpec.dashboards.resources.requests.memory }}
{{- end }}
{{- if .Values.OpenSearchClusterSpec.dashboards.resources.requests.cpu }}
cpu: {{ .Values.OpenSearchClusterSpec.dashboards.resources.requests.cpu }}
{{- end }}
{{- end }}
{{- if .Values.OpenSearchClusterSpec.dashboards.resources.limits }}
limits:
{{- if .Values.OpenSearchClusterSpec.dashboards.resources.limits.memory }}
memory: {{ .Values.OpenSearchClusterSpec.dashboards.resources.limits.memory }}
{{- end }}
{{- if .Values.OpenSearchClusterSpec.dashboards.resources.limits.cpu }}
cpu: {{ .Values.OpenSearchClusterSpec.dashboards.resources.limits.cpu }}
{{- end }}
{{- end }}
{{- end }}
{{- if .Values.OpenSearchClusterSpec.dashboards.tls }}
tls:
{{- if .Values.OpenSearchClusterSpec.dashboards.tls.enable }}
enable: {{ .Values.OpenSearchClusterSpec.dashboards.tls.enable }} # Configure TLS
{{- end }}
{{- if .Values.OpenSearchClusterSpec.dashboards.tls.generate }}
generate: {{ .Values.OpenSearchClusterSpec.dashboards.tls.generate }} # Have the Operator generate and sign a certificate
{{- end }}
{{- if .Values.OpenSearchClusterSpec.dashboards.tls.secret }}
secret:
name: {{ .Values.OpenSearchClusterSpec.dashboards.tls.secret.name }}
{{- end }}
{{- if .Values.OpenSearchClusterSpec.dashboards.tls.casecret }}
caSecret:
name: {{ .Values.OpenSearchClusterSpec.dashboards.tls.caSecret.name }}
{{- end }}
{{- end }}
{{- if .Values.OpenSearchClusterSpec.dashboards.securityContext }}
securityContext:
{{ toYaml .Values.OpenSearchClusterSpec.dashboards.securityContext | nindent 6 }}
{{- end}}
{{- if .Values.OpenSearchClusterSpec.dashboards.podSecurityContext }}
podSecurityContext:
{{ toYaml .Values.OpenSearchClusterSpec.dashboards.podSecurityContext | nindent 6}}
{{- end}}
{{- if .Values.OpenSearchClusterSpec.dashboards.additionalVolumes }}
additionalVolumes:
{{- range $key,$val := .Values.OpenSearchClusterSpec.dashboards.additionalVolumes }}
- name: {{ $val.name }}
path: {{ $val.path }}
secret:
secretName: {{ $val.secretName.name }}
{{- end }}
{{- end }}
{{- if .Values.OpenSearchClusterSpec.dashboards.additionalConfig }}
additionalConfig:
{{ toYaml .Values.OpenSearchClusterSpec.dashboards.additionalConfig | nindent 6 }}
{{- end }}
{{- end }}
{{- if .Values.OpenSearchClusterSpec.confMgmt }}
confMgmt:
{{- if .Values.OpenSearchClusterSpec.confMgmt.smartScaler }}
smartScaler: .Values.OpenSearchClusterSpec.confMgmt.smartScaler
{{- end }}
{{- end }}
nodePools:
{{- range $key,$val := .Values.OpenSearchClusterSpec.nodePools }}
- component: {{ $val.component }}
replicas: {{ $val.replicas }}
diskSize: {{ $val.diskSize | quote }}
{{- if $val.NodeSelector }}
nodeSelector:
{{- toYaml $val.NodeSelector | nindent 8 }}
{{- end }}
{{- if $val.labels }}
labels: # Add any extra labels as key-value pairs here
{{ toYaml $val.labels | nindent 8 }}
{{- end }}
{{- if $val.annotations }}
annotations: # Add any extra annotations as key-value pairs here
{{ toYaml $val.annotations | nindent 8 }}
{{- end }}
{{- if $val.priorityClassName }}
priorityClassName: {{ $val.priorityClassName }}
{{- end }}
{{- if $val.env }}
env:
{{- toYaml $val.env | nindent 8 }}
{{- end }}
{{- if $val.resources }}
resources:
{{- if $val.resources.requests }}
requests:
{{- if $val.resources.requests.memory }}
memory: {{ $val.resources.requests.memory }}
{{- end}}
{{- if $val.resources.requests.cpu }}
cpu: {{ $val.resources.requests.cpu }}
{{- end}}
{{- end }}
{{- if $val.resources.limits }}
limits:
{{- if $val.resources.limits.memory }}
memory: {{ $val.resources.limits.memory }}
{{- end}}
{{- if $val.resources.limits.cpu }}
cpu: {{ $val.resources.limits.cpu }}
{{- end }}
{{- end }}
{{- end }}
{{- if $val.roles }}
roles:
{{ toYaml $val.roles | nindent 6 }}
{{- end }}
{{- if $val.persistence }}
persistence:
{{- if $val.persistence.hostPath }}
hostPath:
path: {{ $val.persistence.hostPath.path }}
{{- else if $val.persistence.pvc }}
pvc:
{{- if $val.persistence.pvc.storageClass }}
storageClass: {{ $val.persistence.pvc.storageClass }}
{{- end }}
{{- if $val.persistence.pvc.accessModes }}
accessModes:
{{ toYaml $val.persistence.pvc.accessModes | nindent 10 }}
{{- end }}
{{- else if eq (len $val.persistence.emptyDir) 0 }}
emptyDir: {}
{{- end }}
{{- end }}
{{- if $val.additionalConfig }}
additionalConfig:
{{ toYaml $val.additionalConfig | nindent 8 }}
{{- end }}
{{- end }}
{{- if .Values.OpenSearchClusterSpec.security }}
security:
{{- if .Values.OpenSearchClusterSpec.security.config }}
config:
{{- if .Values.OpenSearchClusterSpec.security.config.adminSecret }}
adminSecret:
name: {{ .Values.OpenSearchClusterSpec.security.config.adminSecret.name }}
{{- end }}
{{- if .Values.OpenSearchClusterSpec.security.config.adminCredentialsSecret }}
adminCredentialsSecret:
name: {{ .Values.OpenSearchClusterSpec.security.config.adminCredentialsSecret.name }}
{{- end }}
{{- if .Values.OpenSearchClusterSpec.security.config.securityConfigSecret }}
securityConfigSecret:
name: {{ .Values.OpenSearchClusterSpec.security.config.securityConfigSecret.name }}
{{- end }}
{{- end }}
{{- if .Values.OpenSearchClusterSpec.security.tls }}
tls:
{{- if .Values.OpenSearchClusterSpec.security.tls.transport }}
transport:
{{- if .Values.OpenSearchClusterSpec.security.tls.http.generate }}
generate: {{ .Values.OpenSearchClusterSpec.security.tls.transport.generate }}
{{- end }}
{{- if .Values.OpenSearchClusterSpec.security.tls.transport.secret }}
secret:
name: {{ .Values.OpenSearchClusterSpec.security.tls.transport.secret.name }}
{{- end }}
{{- if .Values.OpenSearchClusterSpec.security.tls.transport.adminDn }}
adminDn:
{{ toYaml .Values.OpenSearchClusterSpec.security.tls.transport.adminDn | nindent 10 }}
{{- end }}
{{- if .Values.OpenSearchClusterSpec.security.tls.transport.nodesDn }}
nodesDn:
{{ toYaml .Values.OpenSearchClusterSpec.security.tls.transport.nodesDn | nindent 10 }}
{{- end }}
{{- end }}
{{- if .Values.OpenSearchClusterSpec.security.tls.http }}
http:
{{- if .Values.OpenSearchClusterSpec.security.tls.http.generate }}
generate: {{ .Values.OpenSearchClusterSpec.security.tls.http.generate }}
{{- end }}
{{- if .Values.OpenSearchClusterSpec.security.tls.http.secret }}
secret:
name: {{ .Values.OpenSearchClusterSpec.security.tls.http.secret.name }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
Loading

0 comments on commit 72d46e2

Please sign in to comment.