diff --git a/.ci/Dockerfile b/.ci/Dockerfile index 10da0d11e9..ea1a4e9b09 100644 --- a/.ci/Dockerfile +++ b/.ci/Dockerfile @@ -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 \ @@ -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", "./"] diff --git a/.ci/pipelines/pr-gke.Jenkinsfile b/.ci/pipelines/pr-gke.Jenkinsfile index 77b1e5e6f5..ba645e6c75 100644 --- a/.ci/pipelines/pr-gke.Jenkinsfile +++ b/.ci/pipelines/pr-gke.Jenkinsfile @@ -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 { diff --git a/.gitignore b/.gitignore index 5856f3978b..522f828062 100644 --- a/.gitignore +++ b/.gitignore @@ -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/* diff --git a/Makefile b/Makefile index 5f3b407a0f..b36fdbbb52 100644 --- a/Makefile +++ b/Makefile @@ -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) diff --git a/deploy/README.md b/deploy/README.md index c5e333895d..b8a81135b2 100644 --- a/deploy/README.md +++ b/deploy/README.md @@ -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. @@ -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 \ @@ -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 +``` \ No newline at end of file diff --git a/deploy/eck-elasticsearch/.helmignore b/deploy/eck-elasticsearch/.helmignore new file mode 100644 index 0000000000..f1568daf25 --- /dev/null +++ b/deploy/eck-elasticsearch/.helmignore @@ -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 diff --git a/deploy/eck-elasticsearch/Chart.yaml b/deploy/eck-elasticsearch/Chart.yaml new file mode 100644 index 0000000000..3918fdd0c2 --- /dev/null +++ b/deploy/eck-elasticsearch/Chart.yaml @@ -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 diff --git a/deploy/eck-elasticsearch/examples/hot-warm-cold.yaml b/deploy/eck-elasticsearch/examples/hot-warm-cold.yaml new file mode 100644 index 0000000000..c32d8e995c --- /dev/null +++ b/deploy/eck-elasticsearch/examples/hot-warm-cold.yaml @@ -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 diff --git a/deploy/eck-elasticsearch/templates/NOTES.txt b/deploy/eck-elasticsearch/templates/NOTES.txt new file mode 100644 index 0000000000..e82f862572 --- /dev/null +++ b/deploy/eck-elasticsearch/templates/NOTES.txt @@ -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" . }} diff --git a/deploy/eck-elasticsearch/templates/_helpers.tpl b/deploy/eck-elasticsearch/templates/_helpers.tpl new file mode 100644 index 0000000000..2e4a836687 --- /dev/null +++ b/deploy/eck-elasticsearch/templates/_helpers.tpl @@ -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 }} diff --git a/deploy/eck-elasticsearch/templates/elasticsearch.yaml b/deploy/eck-elasticsearch/templates/elasticsearch.yaml new file mode 100644 index 0000000000..aa5b2fdc89 --- /dev/null +++ b/deploy/eck-elasticsearch/templates/elasticsearch.yaml @@ -0,0 +1,39 @@ +--- +apiVersion: elasticsearch.k8s.elastic.co/v1 +kind: Elasticsearch +metadata: + name: {{ include "elasticsearch.fullname" . }} + labels: + {{- include "elasticsearch.labels" . | nindent 4 }} + annotations: + eck.k8s.elastic.co/license: enterprise + {{- if .Values.annotations }} + {{- toYaml .Values.annotations | indent 4 }} + {{- end }} +spec: + {{- if .Values.updateStrategy }} + updateStrategy: + {{- toYaml .Values.updateStrategy | indent 4 }} + {{- end }} + {{- if .Values.secureSettings }} + secureSettings: + {{- toYaml .Values.secureSettings | indent 2 }} + {{- end }} + {{- if .Values.transport }} + transport: + {{- toYaml .Values.transport | indent 4 }} + {{- end }} + version: {{ required "An Elasticsearch version is required" .Values.version }} + {{- if .Values.monitoring }} + monitoring: + {{- toYaml .Values.monitoring | indent 4 }} + {{- end }} + {{- if .Values.remoteClusters }} + remoteClusters: + {{- toYaml .Values.remoteClusters | indent 2 }} + {{- end }} + {{- if eq (len .Values.nodeSets) 0 }} + {{ fail "At least one nodeSet is required" }} + {{- end }} + nodeSets: +{{ toYaml .Values.nodeSets | indent 4 }} diff --git a/deploy/eck-elasticsearch/templates/tests/elasticsearch_test.yaml b/deploy/eck-elasticsearch/templates/tests/elasticsearch_test.yaml new file mode 100644 index 0000000000..01d43d65b3 --- /dev/null +++ b/deploy/eck-elasticsearch/templates/tests/elasticsearch_test.yaml @@ -0,0 +1,63 @@ +suite: test elasticsearch +templates: + - templates/elasticsearch.yaml +tests: + - it: should render quickstart properly + set: + version: 8.2.0 + release: + name: quickstart + asserts: + - isKind: + of: Elasticsearch + - equal: + path: metadata.name + value: quickstart-eck-elasticsearch + - equal: + path: spec.version + value: 8.2.0 + - it: name override should work properly + set: + nameOverride: override + release: + name: quickstart + asserts: + - isKind: + of: Elasticsearch + - equal: + path: metadata.name + value: quickstart-override + - it: fullname override should work properly + set: + fullnameOverride: override + release: + name: quickstart + asserts: + - isKind: + of: Elasticsearch + - equal: + path: metadata.name + value: override + - it: should render node roles properly + values: + - ../../examples/hot-warm-cold.yaml + release: + name: quickstart + asserts: + - isKind: + of: Elasticsearch + - equal: + path: metadata.name + value: quickstart-eck-elasticsearch + - equal: + path: spec.nodeSets[0].name + value: masters + - equal: + path: spec.nodeSets[1].name + value: hot + - equal: + path: spec.nodeSets[2].name + value: warm + - equal: + path: spec.nodeSets[3].name + value: cold diff --git a/deploy/eck-elasticsearch/values.yaml b/deploy/eck-elasticsearch/values.yaml new file mode 100644 index 0000000000..ca31cf8e48 --- /dev/null +++ b/deploy/eck-elasticsearch/values.yaml @@ -0,0 +1,90 @@ +--- +# Default values for eck-elasticsearch. +# This is a YAML-formatted file. + +# Overridable names of the Elasticsearch resource. +# By default, this is the Release name set for the chart, +# followed by 'eck-elasticsearch'. +# +# nameOverride will override the name of the Chart with the name set here, +# so nameOverride: quickstart, would convert to '{{ Release.name }}-quickstart' +# +# nameOverride: "quickstart" +# +# fullnameOverride will override both the release name, and the chart name, +# and will name the Elasticsearch resource exactly as specified. +# +# fullnameOverride: "quickstart" + +# Version of Elasticsearch. +# +version: 8.2.3 + +# Labels that will be applied to Elasticsearch. +# +labels: {} + +# Annotations that will be applied to Elasticsearch. +# +annotations: {} + +# Settings for configuring stack monitoring. +# ref: https://www.elastic.co/guide/en/cloud-on-k8s/current/k8s-stack-monitoring.html +# +monitoring: {} + +# Control the Elasticsearch transport module used for internal communication between nodes. +# ref: https://www.elastic.co/guide/en/cloud-on-k8s/current/k8s-transport-settings.html +# +transport: {} + +# Settings to control how Elasticsearch will be accessed. +# ref: https://www.elastic.co/guide/en/cloud-on-k8s/current/k8s-accessing-elastic-services.html +# +http: {} + +# Control Elasticsearch Secure Settings. +# ref: https://www.elastic.co/guide/en/cloud-on-k8s/current/k8s-es-secure-settings.html#k8s-es-secure-settings +# +secureSettings: {} + +# Settings for limiting the number of simultaneous changes to an Elasticsearch resource. +# ref: https://www.elastic.co/guide/en/cloud-on-k8s/current/k8s-update-strategy.html +# +updateStrategy: {} + +# Controlling of connectivity between remote clusters within the same kubernetes cluster. +# ref: https://www.elastic.co/guide/en/cloud-on-k8s/current/k8s-remote-clusters.html +# +remoteClusters: {} + +# Node configuration settings. +# The node roles which can be configured here are: +# - "master" +# - "data_hot" +# - "data_cold" +# - "data_frozen" +# - "data_content" +# - "ml" +# - "ingest" +# ref: https://www.elastic.co/guide/en/cloud-on-k8s/current/k8s-node-configuration.html +# +nodeSets: +- name: default + count: 1 + config: + # 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: + requests: + cpu: 1 + limits: + memory: 1Gi diff --git a/deploy/eck-kibana/.helmignore b/deploy/eck-kibana/.helmignore new file mode 100644 index 0000000000..f1568daf25 --- /dev/null +++ b/deploy/eck-kibana/.helmignore @@ -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 diff --git a/deploy/eck-kibana/Chart.yaml b/deploy/eck-kibana/Chart.yaml new file mode 100644 index 0000000000..673ecf1249 --- /dev/null +++ b/deploy/eck-kibana/Chart.yaml @@ -0,0 +1,10 @@ +apiVersion: v2 +name: eck-kibana +description: A Helm chart to deploy Kibana 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/kibana +icon: https://helm.elastic.co/icons/kibana.png diff --git a/deploy/eck-kibana/examples/http-configuration.yaml b/deploy/eck-kibana/examples/http-configuration.yaml new file mode 100644 index 0000000000..0f75f6c39b --- /dev/null +++ b/deploy/eck-kibana/examples/http-configuration.yaml @@ -0,0 +1,37 @@ +--- +# Version of Kibana. +# +version: 8.2.3 + +# Labels that will be applied to Kibana. +# +labels: {} + # key: value + +# Annotations that will be applied to Kibana. +# +annotations: {} + # key: value + +spec: + # Count of Kibana replicas to create. + # + count: 1 + + # Reference to ECK-managed Elasticsearch resource, ideally from {{ "elasticsearch.fullname" }} + # + elasticsearchRef: + name: quickstart-eck-elasticsearch + # namespace: default + http: + service: + spec: + # Type of service to deploy for Kibana. + # This deploys a load balancer in a cloud service provider, where supported. + # + type: LoadBalancer + # tls: + # selfSignedCertificate: + # subjectAltNames: + # - ip: 1.2.3.4 + # - dns: kibana.example.com diff --git a/deploy/eck-kibana/templates/NOTES.txt b/deploy/eck-kibana/templates/NOTES.txt new file mode 100644 index 0000000000..479b7e99df --- /dev/null +++ b/deploy/eck-kibana/templates/NOTES.txt @@ -0,0 +1,6 @@ + +1. Check Kibana status + $ kubectl get kibana {{ include "kibana.fullname" . }} -n={{ .Release.Namespace }} + +2. Check Kibana pod status + $ kubectl get pods --namespace={{ .Release.Namespace }} -l kibana.k8s.elastic.co/name={{ include "kibana.fullname" . }} diff --git a/deploy/eck-kibana/templates/_helpers.tpl b/deploy/eck-kibana/templates/_helpers.tpl new file mode 100644 index 0000000000..f09aca0f58 --- /dev/null +++ b/deploy/eck-kibana/templates/_helpers.tpl @@ -0,0 +1,51 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "kibana.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 "kibana.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 "kibana.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "kibana.labels" -}} +helm.sh/chart: {{ include "kibana.chart" . }} +{{ include "kibana.selectorLabels" . }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- if .Values.labels }} +{{ .Values.labels }} +{{- end }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "kibana.selectorLabels" -}} +app.kubernetes.io/name: {{ include "kibana.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} diff --git a/deploy/eck-kibana/templates/kibana.yaml b/deploy/eck-kibana/templates/kibana.yaml new file mode 100644 index 0000000000..fc9e51767d --- /dev/null +++ b/deploy/eck-kibana/templates/kibana.yaml @@ -0,0 +1,15 @@ +--- +apiVersion: kibana.k8s.elastic.co/v1 +kind: Kibana +metadata: + name: {{ include "kibana.fullname" . }} + labels: + {{- include "kibana.labels" . | nindent 4 }} + annotations: + eck.k8s.elastic.co/license: enterprise + {{- if .Values.annotations }} + {{- toYaml .Values.annotations | indent 4 }} + {{- end }} +spec: + version: {{ required "A Kibana version is required" .Values.version }} + {{- toYaml .Values.spec | nindent 2 }} diff --git a/deploy/eck-kibana/templates/tests/kibana_test.yaml b/deploy/eck-kibana/templates/tests/kibana_test.yaml new file mode 100644 index 0000000000..0581008f76 --- /dev/null +++ b/deploy/eck-kibana/templates/tests/kibana_test.yaml @@ -0,0 +1,66 @@ +suite: test kibana +templates: + - templates/kibana.yaml +tests: + - it: should render quickstart properly + release: + name: quickstart + asserts: + - isKind: + of: Kibana + - equal: + path: metadata.name + value: quickstart-eck-kibana + - equal: + path: spec.version + value: 8.2.3 + - it: name override should work properly + set: + nameOverride: override + release: + name: quickstart + asserts: + - isKind: + of: Kibana + - equal: + path: metadata.name + value: quickstart-override + - it: fullname override should work properly + set: + fullnameOverride: override + release: + name: quickstart + asserts: + - isKind: + of: Kibana + - equal: + path: metadata.name + value: override + - it: should render http service properly + set: + spec.elasticsearchRef.namespace: default + values: + - ../../examples/http-configuration.yaml + release: + name: quickstart + asserts: + - isKind: + of: Kibana + - equal: + path: metadata.name + value: quickstart-eck-kibana + - equal: + path: spec.version + value: 8.2.3 + - equal: + path: spec.count + value: 1 + - equal: + path: spec.elasticsearchRef.name + value: quickstart-eck-elasticsearch + - equal: + path: spec.elasticsearchRef.namespace + value: default + - equal: + path: spec.http.service.spec.type + value: LoadBalancer diff --git a/deploy/eck-kibana/values.yaml b/deploy/eck-kibana/values.yaml new file mode 100644 index 0000000000..d085936240 --- /dev/null +++ b/deploy/eck-kibana/values.yaml @@ -0,0 +1,44 @@ +--- +# Default values for eck-kibana. +# This is a YAML-formatted file. + +# Overridable names of the Kibana resource. +# By default, this is the Release name set for the chart, +# followed by 'eck-kibana'. +# +# nameOverride will override the name of the Chart with the name set here, +# so nameOverride: quickstart, would convert to '{{ Release.name }}-quickstart' +# +# nameOverride: "quickstart" +# +# fullnameOverride will override both the release name, and the chart name, +# and will name the Kibana resource exactly as specified. +# +# fullnameOverride: "quickstart" + +# Version of Kibana. +# +version: 8.2.3 + +# Labels that will be applied to Kibana. +# +labels: {} + +# Annotations that will be applied to Kibana. +# +annotations: {} + +spec: + # Count of Kibana replicas to create. + # + count: 1 + + # Reference to ECK-managed Elasticsearch resource. + # + elasticsearchRef: + name: eck-elasticsearch + # Optional namespace reference to Elasticsearch resource. + # If not specified, then the namespace of the Kibana resource + # will be assumed. + # + # namespace: default diff --git a/deploy/eck-stack/.helmignore b/deploy/eck-stack/.helmignore new file mode 100644 index 0000000000..f1568daf25 --- /dev/null +++ b/deploy/eck-stack/.helmignore @@ -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 diff --git a/deploy/eck-stack/Chart.lock b/deploy/eck-stack/Chart.lock new file mode 100644 index 0000000000..e78185e4ef --- /dev/null +++ b/deploy/eck-stack/Chart.lock @@ -0,0 +1,9 @@ +dependencies: +- name: eck-elasticsearch + repository: file://../eck-elasticsearch + version: 0.1.0 +- name: eck-kibana + repository: file://../eck-kibana + version: 0.1.0 +digest: sha256:5d22239d6c40d5b35b4242db0af9c37ff6c59f3ed2afdd2ab2956ce0992e4320 +generated: "2022-07-19T08:58:27.453007-05:00" diff --git a/deploy/eck-stack/Chart.yaml b/deploy/eck-stack/Chart.yaml new file mode 100644 index 0000000000..2ea45da000 --- /dev/null +++ b/deploy/eck-stack/Chart.yaml @@ -0,0 +1,26 @@ +apiVersion: v2 +name: eck-stack +description: | + A Parent Helm chart for all Elastic stack resources managed by the ECK Operator. + Currently supported: + * Elasticsearch + * Kibana +kubeVersion: ">= 1.20.0-0" +type: application +version: 0.1.0 + +dependencies: + - name: eck-elasticsearch + condition: eck-elasticsearch.enabled + version: "0.1.0" + # uncomment for local testing, and comment + # the helm.elastic.co repository. + # repository: "file://../eck-elasticsearch" + repository: "https://helm.elastic.co" + - name: eck-kibana + condition: eck-kibana.enabled + version: "0.1.0" + # uncomment for local testing, and comment + # the helm.elastic.co repository. + # repository: "file://../eck-kibana" + repository: "https://helm.elastic.co" diff --git a/deploy/eck-stack/README.md b/deploy/eck-stack/README.md new file mode 100644 index 0000000000..2a0dba9aef --- /dev/null +++ b/deploy/eck-stack/README.md @@ -0,0 +1,84 @@ +# ECK-Stack + +ECK Stack is a Helm chart to assist in the deployment of Elastic Stack components, which are +managed by the [ECK Operator](https://www.elastic.co/guide/en/cloud-on-k8s/current/index.html) + +## Supported Elastic Stack Resources + +The following Elastic Stack resources are currently supported. + +- Elasticsearch +- Kibana + +Additional resources will be supported in future releases of this Helm Chart. + +## Prerequisites + +- Kubernetes 1.20+ +- Elastic ECK Operator + +## Installing the Chart + +### Installing the ECK Operator + +Before using this chart, the Elastic ECK Operator is required to be installed within the Kubernetes cluster. +Full installation instructions can be found within [our documentation](https://www.elastic.co/guide/en/cloud-on-k8s/current/k8s-installing-eck.html) + +To install the ECK Operator using Helm. + +```sh +# Add the Elastic Helm Repository +helm repo add elastic https://helm.elastic.co && helm repo update + +# Install the ECK Operator cluster-wide +helm install elastic-operator elastic/eck-operator -n elastic-system --create-namespace +``` + +Additional ECK Operator Helm installation options can be found within [our documentation](https://www.elastic.co/guide/en/cloud-on-k8s/current/k8s-install-helm.html) + +### Installing the ECK Stack Chart + +The following will install the ECK-Stack chart using the default values, which will deploy an Elasticsearch [Quickstart Cluster](https://www.elastic.co/guide/en/cloud-on-k8s/current/k8s-deploy-elasticsearch.html), and a Kibana [Quickstart Instance](https://www.elastic.co/guide/en/cloud-on-k8s/current/k8s-deploy-kibana.html) + +```sh +# Add the Elastic Helm Repository +helm repo add elastic https://helm.elastic.co && helm repo update + +# Install the ECK-Stack helm chart +# This will setup a 'quickstart' Elasticsearch and Kibana resource +$ helm install my-release -n my-namespace elastic/eck-stack --create-namespace +``` + +More information on the different ways to use the ECK Stack chart to deploy Elastic Stack resources +can be found in [our documentation](https://www.elastic.co/guide/en/cloud-on-k8s/current/index.html). + +## Uninstalling the Chart + +To uninstall/delete the `my-release` deployment from the 'my-namespace' namespace: + +```console +$ helm delete my-release -n my-namespace +``` + +The command removes all the Elastic Stack resources associated with the chart and deletes the release. + +## Configuration + +The following table lists the configurable parameters of the eck-stack chart and their default values. + +| Parameter | Description | Default | +| --------- | ----------- | ------- | +| `eck-elasticsearch.enabled` | If `true`, create an Elasticsearch resource (using the eck-elasticsearch Chart) | `true` | +| `eck-kibana.enabled` | If `true`, create a Kibana resource (using the eck-kibana Chart) | `true` | + +Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. + +Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the chart. For example, + +```console +$ helm install my-release -f values.yaml . +``` + +## Contributing + +This chart is maintained at [github.com/elastic/cloud-on-k8s](https://github.com/elastic/cloud-on-k8s/tree/main/deploy/eck-stack). \ No newline at end of file diff --git a/deploy/eck-stack/examples/custom-elasticsearch-kibana.yaml b/deploy/eck-stack/examples/custom-elasticsearch-kibana.yaml new file mode 100644 index 0000000000..4c63921dd5 --- /dev/null +++ b/deploy/eck-stack/examples/custom-elasticsearch-kibana.yaml @@ -0,0 +1,78 @@ +--- +eck-elasticsearch: + # Name of the Elasticsearch resource. + # + fullnameOverride: quickstart + + # Version of Elasticsearch. + # + version: 8.2.3 + + nodeSets: + - name: default + count: 1 + config: + # 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 + volumeClaimTemplates: + - metadata: + name: elasticsearch-data + spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 100Gi + # Adjust to your storage class name + # + # storageClassName: local-storage + +eck-kibana: + # Name of the Kibana resource. + # + fullnameOverride: quickstart + + # Version of Kibana. + # + version: 8.2.3 + + spec: + # Count of Kibana replicas to create. + # + count: 1 + + # Reference to ECK-managed Elasticsearch resource, ideally from {{ "elasticsearch.fullname" }} + # + elasticsearchRef: + name: quickstart + # namespace: default + http: + service: + spec: + # Type of service to deploy for Kibana. + # This deploys a load balancer in a cloud service provider, where supported. + # + type: LoadBalancer + # tls: + # selfSignedCertificate: + # subjectAltNames: + # - ip: 1.2.3.4 + # - dns: kibana.example.com + podTemplate: + spec: + containers: + - name: kibana + env: + - name: NODE_OPTIONS + value: "--max-old-space-size=2048" + resources: + requests: + memory: 1Gi + cpu: 0.5 + limits: + memory: 2.5Gi + cpu: 2 diff --git a/deploy/eck-stack/templates/NOTES.txt b/deploy/eck-stack/templates/NOTES.txt new file mode 100644 index 0000000000..3c91e85b38 --- /dev/null +++ b/deploy/eck-stack/templates/NOTES.txt @@ -0,0 +1,10 @@ +Elasticsearch ECK-Stack {{ .Chart.Version }} has been deployed successfully! + +To see status of all resources, run + +kubectl get elastic -l "app.kubernetes.io/instance"={{ .Release.Name}} + +More information on the Elastic ECK Operator, and its Helm chart can be found +within our documentation. + +https://www.elastic.co/guide/en/cloud-on-k8s/current/index.html diff --git a/deploy/eck-stack/templates/_helpers.tpl b/deploy/eck-stack/templates/_helpers.tpl new file mode 100644 index 0000000000..cef61bdb0d --- /dev/null +++ b/deploy/eck-stack/templates/_helpers.tpl @@ -0,0 +1,48 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "eck-stack.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 "eck-stack.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 "eck-stack.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "eck-stack.labels" -}} +helm.sh/chart: {{ include "eck-stack.chart" . }} +{{ include "eck-stack.selectorLabels" . }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "eck-stack.selectorLabels" -}} +app.kubernetes.io/name: {{ include "eck-stack.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} diff --git a/deploy/eck-stack/templates/tests/elasticsearch_test.yaml b/deploy/eck-stack/templates/tests/elasticsearch_test.yaml new file mode 100644 index 0000000000..6b0aaea11e --- /dev/null +++ b/deploy/eck-stack/templates/tests/elasticsearch_test.yaml @@ -0,0 +1,66 @@ +suite: test elasticsearch +templates: + - charts/eck-elasticsearch/templates/elasticsearch.yaml +tests: + - it: should render quickstart properly + set: + eck-elasticsearch.version: 8.2.0 + eck-kibana.enabled: false + release: + name: quickstart + asserts: + - isKind: + of: Elasticsearch + - equal: + path: metadata.name + value: elasticsearch + - equal: + path: spec.version + value: 8.2.0 + - it: name override should work properly + set: + eck-elasticsearch.nameOverride: override + eck-elasticsearch.fullnameOverride: null + eck-kibana.enabled: false + release: + name: quickstart + asserts: + - isKind: + of: Elasticsearch + - equal: + path: metadata.name + value: quickstart-override + - it: fullname override should work properly + set: + eck-elasticsearch.fullnameOverride: override + eck-kibana.enabled: false + release: + name: quickstart + asserts: + - isKind: + of: Elasticsearch + - equal: + path: metadata.name + value: override + - it: should render custom elasticsearch using values file properly + set: + eck-kibana.enabled: false + values: + - ../../examples/custom-elasticsearch-kibana.yaml + release: + name: quickstart + asserts: + - isKind: + of: Elasticsearch + - equal: + path: metadata.name + value: quickstart + - equal: + path: spec.nodeSets[0].name + value: default + - equal: + path: spec.nodeSets[0].volumeClaimTemplates[0].metadata.name + value: elasticsearch-data + - equal: + path: spec.nodeSets[0].volumeClaimTemplates[0].spec.resources.requests.storage + value: 100Gi diff --git a/deploy/eck-stack/templates/tests/kibana_test.yaml b/deploy/eck-stack/templates/tests/kibana_test.yaml new file mode 100644 index 0000000000..cdff3e7b53 --- /dev/null +++ b/deploy/eck-stack/templates/tests/kibana_test.yaml @@ -0,0 +1,66 @@ +suite: test kibana +templates: + - charts/eck-kibana/templates/kibana.yaml +tests: + - it: should render quickstart properly + release: + name: quickstart + asserts: + - isKind: + of: Kibana + - equal: + path: metadata.name + value: quickstart-eck-kibana + - equal: + path: spec.version + value: 8.2.3 + - it: name override should work properly + set: + eck-kibana.nameOverride: override + release: + name: quickstart + asserts: + - isKind: + of: Kibana + - equal: + path: metadata.name + value: quickstart-override + - it: fullname override should work properly + set: + eck-kibana.fullnameOverride: override + release: + name: quickstart + asserts: + - isKind: + of: Kibana + - equal: + path: metadata.name + value: override + - it: should render custom kibana using values file properly + set: + eck-kibana.spec.elasticsearchRef.namespace: default + values: + - ../../examples/custom-elasticsearch-kibana.yaml + release: + name: quickstart + asserts: + - isKind: + of: Kibana + - equal: + path: metadata.name + value: quickstart + - equal: + path: spec.version + value: 8.2.3 + - equal: + path: spec.count + value: 1 + - equal: + path: spec.elasticsearchRef.name + value: quickstart + - equal: + path: spec.elasticsearchRef.namespace + value: default + - equal: + path: spec.http.service.spec.type + value: LoadBalancer diff --git a/deploy/eck-stack/values.yaml b/deploy/eck-stack/values.yaml new file mode 100644 index 0000000000..e24b479755 --- /dev/null +++ b/deploy/eck-stack/values.yaml @@ -0,0 +1,21 @@ +--- +# Default values for eck-stack. +# This is a YAML-formatted file. + +# If enabled, will use the eck-elasticsearch chart and deploy an Elasticsearch resource. +# +eck-elasticsearch: + enabled: true + # This is adjusting the full name of the elasticsearch resource so that both the eck-elasticsearch + # and the eck-kibana chart work together by default in the eck-stack chart. + fullnameOverride: elasticsearch + +# If enabled, will use the eck-kibana chart and deploy a Kibana resource. +# +eck-kibana: + enabled: true + spec: + # This is also adjusting the kibana reference to the elasticsearch resource named previously so that + # both the eck-elasticsearch and the eck-kibana chart work together by default in the eck-stack chart. + elasticsearchRef: + name: elasticsearch diff --git a/dev-setup.md b/dev-setup.md index 95d682aea0..9464f353ac 100644 --- a/dev-setup.md +++ b/dev-setup.md @@ -11,6 +11,8 @@ Before you start, install the following tools and packages: * [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/) (>= 1.14) * [kubebuilder](https://github.com/kubernetes-sigs/kubebuilder) (>= 2.0.0) * [docker](https://docs.docker.com/) (>= 19.0.0 with optional `buildx` extension for multi-arch builds) +* [helm](https://helm.sh/docs/intro/install/) (>= 3.2.0, preferably 3.9.x) +* [helm unittest](https://github.com/quintush/helm-unittest#install) (only needed if developing helm charts) `helm plugin install https://github.com/quintush/helm-unittest --version 0.2.8` * Kubernetes distribution such as [minikube](https://kubernetes.io/docs/tasks/tools/install-minikube/) or [kind](https://kind.sigs.k8s.io), or access to a hosted Kubernetes service such as [GKE](https://cloud.google.com/kubernetes-engine) or [AKS](https://azure.microsoft.com/en-us/services/kubernetes-service/) ### Get sources diff --git a/docs/orchestrating-elastic-stack-applications/orchestrating-elastic-stack-applications.asciidoc b/docs/orchestrating-elastic-stack-applications/orchestrating-elastic-stack-applications.asciidoc index c4f5476055..71b2008a10 100644 --- a/docs/orchestrating-elastic-stack-applications/orchestrating-elastic-stack-applications.asciidoc +++ b/docs/orchestrating-elastic-stack-applications/orchestrating-elastic-stack-applications.asciidoc @@ -17,6 +17,7 @@ endif::[] - <<{p}-maps>> - <<{p}-enterprise-search>> - <<{p}-beat>> +- <<{p}-stack-helm-chart>> - <<{p}-recipes>> - <<{p}-securing-stack>> - <<{p}-accessing-elastic-services>> @@ -35,6 +36,7 @@ include::agent-fleet.asciidoc[leveloffset=+1] include::maps.asciidoc[leveloffset=+1] include::enterprise-search.asciidoc[leveloffset=+1] include::beat.asciidoc[leveloffset=+1] +include::stack-helm-chart.asciidoc[leveloffset=+1] include::recipes.asciidoc[leveloffset=+1] include::securing-stack.asciidoc[leveloffset=+1] include::accessing-elastic-services.asciidoc[leveloffset=+1] diff --git a/docs/orchestrating-elastic-stack-applications/stack-helm-chart.asciidoc b/docs/orchestrating-elastic-stack-applications/stack-helm-chart.asciidoc new file mode 100644 index 0000000000..139fda79d5 --- /dev/null +++ b/docs/orchestrating-elastic-stack-applications/stack-helm-chart.asciidoc @@ -0,0 +1,69 @@ +:page_id: stack-helm-chart +ifdef::env-github[] +**** +link:https://www.elastic.co/guide/en/cloud-on-k8s/master/k8s-{page_id}.html[View this document on the Elastic website] +**** +endif::[] +[id="{p}-{page_id}"] += Elastic Stack Helm Chart + +Starting from ECK 2.4.0, a Helm chart is available for managing Elastic Stack resources using the ECK Operator. It is available from the Elastic Helm repository and can be added to your Helm repository list by running the following command: + +[source, sh] +---- +helm repo add elastic https://helm.elastic.co +helm repo update +---- + +NOTE: The minimum supported version of Helm is 3.2.0. + +NOTE: ECK Stack Helm Charts are currently being released as an Enterprise licensed feature. + +[float] +[id="{p}-install-elasticsearch-kibana-helm"] +== Installing Elasticsearch and Kibana using the eck-stack Helm Chart + +Similar to the <<{p}-deploy-elasticsearch,quickstart>>, the following section describes how to setup an Elasticsearch cluster with a simple Kibana instance managed by ECK, and how to customize a deployment using the eck-stack Helm chart's values. + +[source,sh] +---- +# Install an eck-managed Elasticsearch and Kibana using the default values, which deploys the quickstart examples. +helm install es-kb-quickstart elastic/eck-stack -n elastic-stack --create-namespace +---- + +[float] +[id="{p}-eck-stack-helm-customize"] +=== Customizing Kibana and Elasticsearch using the eck-stack Helm Chart's example values + +There are example Helm values files for installing and managing a more advanced Elasticsearch and/or Kibana link:{eck_github}/tree/{eck_release_branch}/deploy/eck-stack/examples[in the project repository]. + +To use one or more of these example configurations, use the `--values` Helm option, as seen in the following section. + +[source,sh] +---- +# Install an eck-managed Elasticsearch and Kibana using the Elasticsearch node roles example with hot, warm, and cold data tiers, and the Kibana example customizing the http service. +helm install es-quickstart elastic/eck-stack -n elastic-stack --create-namespace --values https://github.com/elastic/cloud-on-k8s/tree/main/deploy/eck-stack/examples/elasticsearch/hot-warm-cold.yaml --values https://github.com/elastic/cloud-on-k8s/tree/main/deploy/eck-stack/examples/kibana/http-configuration.yaml +---- + +[float] +[id="{p}-eck-stack-individual-components"] +=== Installing individual components of the Elastic Stack using the Helm Charts + +You can install individual components in one of two ways using the provided Helm Charts. + +1. Using Helm values +2. Using the individual Helm Charts directly + +*Using Helm values to install only Elasticsearch* + +[source,sh] +---- +helm install es-quickstart elastic/eck-stack -n elastic-stack --create-namespace --set=eck-kibana.enabled=false +---- + +*Using the eck-elasticsearch Helm Chart directly to install only Elasticsearch* + +[source,sh] +---- +helm install es-quickstart elastic/eck-elasticsearch -n elastic-stack --create-namespace +---- \ No newline at end of file diff --git a/hack/helm/test.sh b/hack/helm/test.sh new file mode 100755 index 0000000000..c3553c81a4 --- /dev/null +++ b/hack/helm/test.sh @@ -0,0 +1,54 @@ +#!/usr/bin/env bash + +# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +# or more contributor license agreements. Licensed under the Elastic License 2.0; +# you may not use this file except in compliance with the Elastic License 2.0. + +# Script to test helm charts + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +check() { + local TEST_DIR="$1" + cd "${TEST_DIR}" || exit + + local SED="sed_gnu" + if [[ "$OSTYPE" =~ "darwin" ]]; then + SED="sed_bsd" + fi + + # Ensure official helm repository is commented out in Chart.yaml + "$SED" -E 's|[[:space:]]+repository: "https://helm\.elastic\.co"| # repository: "https://helm.elastic.co"|g' Chart.yaml + # Uncomment file:// repository stanzas to ensure local changes to repositories are used instead + "$SED" -E 's|.*repository: "file://\.\./(eck-[a-z-]+)"$| repository: "file://../\1"|' Chart.yaml + + echo "Ensuring dependencies are updated for $(basename "${TEST_DIR}") chart." + helm dependency update . 1>/dev/null + + echo "Running 'helm lint' on $(basename "${TEST_DIR}") chart." + helm lint --strict . + + helm unittest -3 -f 'templates/tests/*.yaml' . + + # restore changes to Chart.yaml + git checkout Chart.yaml + + cd - || exit +} + +sed_gnu() { + sed -i "$@" +} + +sed_bsd() { + sed -i '' "$@" +} + +for i in "${SCRIPT_DIR}"/../../deploy/[a-zA-Z0-9]*; do + if [[ ! -d "${i}" ]]; then + continue + fi + if [[ -d "${i}"/templates/tests ]]; then + check "${i}" + fi +done