Skip to content

Commit

Permalink
ECK Resources Helm Chart (#5781)
Browse files Browse the repository at this point in the history
* Adding initial revision of eck-stack, and eck-kibana charts.

* Update Chart.yaml to have kubeversion.
Add README.
Add notes for post-installtion.
Update values with more docs

* Update values file with more information.

* adding es resource

* Making things consistent across charts.

* Adding newlines
Adding top yaml markers

* Add public documentation for eck-stack helm chart.
Update example values to work properly.

* Adding helm test script.
Adding minimal tests for eck-stack helm chart.

* add newline

* Add makefile entry.
remove unused bits from script.
Fix naming in helm chart.

* Add helm test to ci checks

* make chart.yaml consistent

* Adding newlines
Updating wording in documentation.

* Update newline

* Update readme for eck-stack

* remove todo from eck-stack readme

* quote things to passify spellcheck

* Quote more vars.
Use $() instead of ``

* Fix sc2045

* Updates from first round of reviews.

* Update the documentation.
Run the dependencies prior to linting.

* Fix shellcheck

* Add note that ECK stack helm charts are enterprise

* Update license note in docs/orchestrating-elastic-stack-applications/stack-helm-chart.asciidoc

Co-authored-by: Peter Brachwitz <peter.brachwitz@gmail.com>

* Update verbiage deploy/eck-stack/README.md

Co-authored-by: Peter Brachwitz <peter.brachwitz@gmail.com>

* Update verbiage deploy/eck-stack/README.md

Co-authored-by: Peter Brachwitz <peter.brachwitz@gmail.com>

* Add 'the' to documentation in  docs/orchestrating-elastic-stack-applications/stack-helm-chart.asciidoc

Co-authored-by: Peter Brachwitz <peter.brachwitz@gmail.com>

* add 'the' again to docs in  docs/orchestrating-elastic-stack-applications/stack-helm-chart.asciidoc

Co-authored-by: Peter Brachwitz <peter.brachwitz@gmail.com>

* Comment out affinity section, as it won't work by default.
Adjust kibana elasticsearcRef to be default for release name 'quickstart'.
Adjust wording for reference.

* Update public documentation to be more clear.

* Add dedicated master nodes to dedicated examples

* Fix elasticsearch test in eck-elasticsearch chart
comment out namespace in elasticsearchref in kibana example.
adjust kibana tests to tests for specifying namespace for elasticsearchref.
s/fullNameOverride/fullnameOverride
remove eck-stack examples with only ES or Kibana.
Add eck-stack example with both ES and Kibana customizations.
Adjust eck-stack tests for new example.

* Fix missing default labels in Elasticsearch.
Fix random '{}' in annotatinos in ES/Kibana.

* Make default quickstart elasticsearchRef work by default.

* Removing logic that inserts namespace for elasticsearchRef, as operator interally handles it.

* Move to referencing https://helm.elastic.co helm repository.

* Fix helm tests

* Add helm test to pr ci pipeline

* Add helm to ci-tools container.

* Handling Review comments

* Adjust default readme in deploy directory
Adjust default values for eck-elasticsearch and eck-kibana.
Debug helm unittest script in CI

* Debugging helm unittest

* Fix shellcheck complaining about debugging messages.

* Try and run helm unittest directly

* Install the correct plugin, with static version

* Adjust default values for eck-elasticsearch, and eck-kibana for the eck-stack chart.

* Fix test for default elasticsearch name

* Remove debugging from helm test script.

* Adjust chart.yaml back to using helm.elastic.co repository.

* Use sed to force local changes during helm testing, and not charts in helm.elastic.co.

* Making shellcheck happy

* Add helm documentation to dev-setup.md.

Co-authored-by: framsouza <francismara.souza@elastic.co>
Co-authored-by: Peter Brachwitz <peter.brachwitz@gmail.com>
  • Loading branch information
3 people committed Jul 26, 2022
1 parent 17e01bc commit 74a941b
Show file tree
Hide file tree
Showing 35 changed files with 1,330 additions and 8 deletions.
8 changes: 8 additions & 0 deletions .ci/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ ENV DOCKER_BUILDX_VERSION=0.8.2
ENV GOTESTSUM_VERSION=1.8.0
ENV EKSCTL_VERSION=0.74.0
ENV ECK_DIAG_VERSION=1.1.0
ENV HELM_VERSION=3.9.1

# golangci-lint
RUN curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh \
Expand Down Expand Up @@ -82,6 +83,13 @@ RUN curl -fsSLO "https://github.com/weaveworks/eksctl/releases/download/v${EKSCT
mv eksctl /usr/local/bin/eksctl && \
rm eksctl_Linux_amd64.tar.gz

RUN curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 && \
chmod 700 get_helm.sh && \
./get_helm.sh -v v${HELM_VERSION} --no-sudo && \
rm get_helm.sh

RUN helm plugin install https://github.com/quintush/helm-unittest --version 0.2.8

# Cache ECK Go dependencies in this Docker image
WORKDIR /go/src/github.com/elastic/cloud-on-k8s
COPY ["go.mod", "go.sum", "./"]
Expand Down
5 changes: 5 additions & 0 deletions .ci/pipelines/pr-gke.Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ pipeline {
sh 'make -C .ci TARGET=reattach-pv ci'
}
}
stage("helm-test") {
steps {
sh 'make -C .ci TARGET=helm-test ci'
}
}
stage("unit-tests") {
steps {
script {
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,6 @@ pkg/controller/common/license/zz_generated.pubkey.go

# ignore validator for Jenkins pipelines
hack/pipeline-validator/validator

# ignore helm chart dependencies in eck-stack chart
deploy/eck-stack/charts/*
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ unit: clean
unit-xml: clean
ECK_TEST_LOG_LEVEL=$(LOG_VERBOSITY) gotestsum --junitfile unit-tests.xml -- -cover ./pkg/... ./cmd/... $(TEST_OPTS)

helm-test:
@hack/helm/test.sh

integration: GO_TAGS += integration
integration: clean generate-crds-v1
ECK_TEST_LOG_LEVEL=$(LOG_VERBOSITY) go test -tags='$(GO_TAGS)' ./pkg/... ./cmd/... -cover $(TEST_OPTS)
Expand Down
26 changes: 18 additions & 8 deletions deploy/README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
# ECK Operator Helm Chart
# ECK Operator, and ECK Resources Helm Charts

[![Artifact HUB](https://img.shields.io/endpoint?url=https://artifacthub.io/badge/repository/elastic)](https://artifacthub.io/packages/search?repo=elastic)

This directory contains the Helm chart for deploying the ECK operator.
This directory contains the Helm chart for deploying the ECK operator, and charts for deploying any resource in the Elastic Stack individually, or as a group.

See also the [ECK Helm install guide](https://www.elastic.co/guide/en/cloud-on-k8s/current/k8s-install-helm.html).

## Usage
## ECK Operator Helm Chart Usage

Install the CRDs and deploy the operator with cluster-wide permissions to manage all namespaces.

```sh
helm install elastic-operator elastic/eck-operator -n elastic-system --create-namespace
helm install elastic-operator eck-operator -n elastic-system --create-namespace
```

Install the operator restricted to a single namespace.
Expand All @@ -21,7 +19,7 @@ Install the operator restricted to a single namespace.
helm install elastic-operator-crds ./eck/charts/eck-operator-crds

# This step can be done by any user with full access to the my-namespace namespace.
helm install elastic-operator elastic/eck-operator -n my-namespace --create-namespace \
helm install elastic-operator eck-operator -n my-namespace --create-namespace \
--set=installCRDs=false \
--set=managedNamespaces='{my-namespace}' \
--set=createClusterScopedResources=false \
Expand All @@ -31,7 +29,19 @@ helm install elastic-operator elastic/eck-operator -n my-namespace --create-name
View the available settings for customizing the installation.

```sh
helm show values elastic/eck-operator
helm show values eck-operator
```

## ECK Stack Helm Chart Usage

Install a quickstart Elasticsearch and Kibana resource in a cluster controlled by the ECK Operator.

```sh
helm install es-kb-quickstart elastic/eck-stack -n elastic-stack --create-namespace
```

To see all resources installed by the helm chart

```sh
kubectl get elastic -l "app.kubernetes.io/instance"=es-kb-quickstart -n elastic-stack
```
24 changes: 24 additions & 0 deletions deploy/eck-elasticsearch/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
templates/tests
10 changes: 10 additions & 0 deletions deploy/eck-elasticsearch/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v2
name: eck-elasticsearch
description: A Helm chart to deploy Elasticsearch managed by the ECK Operator.
kubeVersion: ">= 1.20.0-0"
type: application
version: 0.1.0
sources:
- https://github.com/elastic/cloud-on-k8s
- https://github.com/elastic/elasticsearch/
icon: https://helm.elastic.co/icons/elasticsearch.png
198 changes: 198 additions & 0 deletions deploy/eck-elasticsearch/examples/hot-warm-cold.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
---
nodeSets:
- name: masters
count: 1
config:
node.roles: ["master"]
# Comment out when setting the vm.max_map_count via initContainer, as these are mutually exclusive.
# For production workloads, it is strongly recommended to increase the kernel setting vm.max_map_count to 262144
# and leave node.store.allow_mmap unset.
# ref: https://www.elastic.co/guide/en/cloud-on-k8s/master/k8s-virtual-memory.html
#
node.store.allow_mmap: false
podTemplate:
spec:
containers:
- name: elasticsearch
resources:
limits:
memory: 8Gi
cpu: 2
# Affinity/Anti-affinity settings for controlling the 'spreading' of Elasticsearch
# pods across existing hosts.
# ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity
# ref: https://www.elastic.co/guide/en/cloud-on-k8s/current/k8s-advanced-node-scheduling.html#k8s-affinity-options
#
# affinity:
# nodeAffinity:
# requiredDuringSchedulingIgnoredDuringExecution:
# nodeSelectorTerms:
# - matchExpressions:
# - key: beta.kubernetes.io/instance-type
# operator: In
# # This should be adjusted to the instance type according to your setup
# #
# values:
# - highio
# Volume Claim settings.
# ref: https://www.elastic.co/guide/en/cloud-on-k8s/2.2/k8s-volume-claim-templates.html
#
volumeClaimTemplates:
- metadata:
name: elasticsearch-data
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Ti
# Adjust to your storage class name
#
# storageClassName: local-storage
- name: hot
count: 1
config:
node.roles: ["data_hot", "data_content", "ingest"]
# Comment out when setting the vm.max_map_count via initContainer, as these are mutually exclusive.
# For production workloads, it is strongly recommended to increase the kernel setting vm.max_map_count to 262144
# and leave node.store.allow_mmap unset.
# ref: https://www.elastic.co/guide/en/cloud-on-k8s/master/k8s-virtual-memory.html
#
node.store.allow_mmap: false
podTemplate:
spec:
containers:
- name: elasticsearch
resources:
limits:
memory: 16Gi
cpu: 4
# Affinity/Anti-affinity settings for controlling the 'spreading' of Elasticsearch
# pods across existing hosts.
# ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity
# ref: https://www.elastic.co/guide/en/cloud-on-k8s/current/k8s-advanced-node-scheduling.html#k8s-affinity-options
#
# affinity:
# nodeAffinity:
# requiredDuringSchedulingIgnoredDuringExecution:
# nodeSelectorTerms:
# - matchExpressions:
# - key: beta.kubernetes.io/instance-type
# operator: In
# # This should be adjusted to the instance type according to your setup
# #
# values:
# - highio
# Volume Claim settings.
# ref: https://www.elastic.co/guide/en/cloud-on-k8s/2.2/k8s-volume-claim-templates.html
#
volumeClaimTemplates:
- metadata:
name: elasticsearch-data
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Ti
# Adjust to your storage class name
#
# storageClassName: local-storage
- name: warm
count: 1
config:
node.roles: ["data_warm"]
# Comment out when setting the vm.max_map_count via initContainer, as these are mutually exclusive.
# For production workloads, it is strongly recommended to increase the kernel setting vm.max_map_count to 262144
# and leave node.store.allow_mmap unset.
# ref: https://www.elastic.co/guide/en/cloud-on-k8s/master/k8s-virtual-memory.html
#
node.store.allow_mmap: false
podTemplate:
spec:
containers:
- name: elasticsearch
resources:
limits:
memory: 16Gi
cpu: 2
# Affinity/Anti-affinity settings for controlling the 'spreading' of Elasticsearch
# pods across existing hosts.
# ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity
# ref: https://www.elastic.co/guide/en/cloud-on-k8s/current/k8s-advanced-node-scheduling.html#k8s-affinity-options
#
# affinity:
# nodeAffinity:
# requiredDuringSchedulingIgnoredDuringExecution:
# nodeSelectorTerms:
# - matchExpressions:
# - key: beta.kubernetes.io/instance-type
# operator: In
# # This should be adjusted to the instance type according to your setup
# #
# values:
# - highstorage
# Volume Claim settings.
# ref: https://www.elastic.co/guide/en/cloud-on-k8s/2.2/k8s-volume-claim-templates.html
#
volumeClaimTemplates:
- metadata:
name: elasticsearch-data
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Ti
# Adjust to your storage class name
#
# storageClassName: local-storage
- name: cold
count: 1
config:
node.roles: ["data_cold"]
# Comment out when setting the vm.max_map_count via initContainer, as these are mutually exclusive.
# For production workloads, it is strongly recommended to increase the kernel setting vm.max_map_count to 262144
# and leave node.store.allow_mmap unset.
# ref: https://www.elastic.co/guide/en/cloud-on-k8s/master/k8s-virtual-memory.html
#
node.store.allow_mmap: false
podTemplate:
spec:
containers:
- name: elasticsearch
resources:
limits:
memory: 8Gi
cpu: 2
# Affinity/Anti-affinity settings for controlling the 'spreading' of Elasticsearch
# pods across existing hosts.
# ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity
# ref: https://www.elastic.co/guide/en/cloud-on-k8s/current/k8s-advanced-node-scheduling.html#k8s-affinity-options
#
# affinity:
# nodeAffinity:
# requiredDuringSchedulingIgnoredDuringExecution:
# nodeSelectorTerms:
# - matchExpressions:
# - key: beta.kubernetes.io/instance-type
# operator: In
# # This should be adjusted to the instance type according to your setup
# #
# values:
# - highstorage
# Volume Claim settings.
# ref: https://www.elastic.co/guide/en/cloud-on-k8s/2.2/k8s-volume-claim-templates.html
#
volumeClaimTemplates:
- metadata:
name: elasticsearch-data
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 20Ti
# Adjust to your storage class name
#
# storageClassName: local-storage
6 changes: 6 additions & 0 deletions deploy/eck-elasticsearch/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

1. Check Elasticsearch resource status
$ kubectl get es {{ include "elasticsearch.fullname" . }} -n={{ .Release.Namespace }}

2. Check Elasticsearch pod status
$ kubectl get pods --namespace={{ .Release.Namespace }} -l elasticsearch.k8s.elastic.co/cluster-name={{ include "elasticsearch.fullname" . }}
51 changes: 51 additions & 0 deletions deploy/eck-elasticsearch/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "elasticsearch.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 "elasticsearch.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 "elasticsearch.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "elasticsearch.labels" -}}
helm.sh/chart: {{ include "elasticsearch.chart" . }}
{{ include "elasticsearch.selectorLabels" . }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- if .Values.labels }}
{{ .Values.labels }}
{{- end }}
{{- end }}

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

0 comments on commit 74a941b

Please sign in to comment.