Skip to main content

Using Helm Charts for Deployment

1. Understanding Helm

Concept Description Usage
Helm Chart Package format for Kubernetes applications Used to define, install, and upgrade even the most complex Kubernetes applications
Helm Release An instance of a Helm chart Represents a specific deployment of a chart in a Kubernetes cluster
Values File YAML file containing configuration values for a chart Allows customization of default settings during chart installation
Helm Repository Remote location storing Helm charts Used to store and share charts (e.g., Artifact Hub, private repositories)

Example: Installing a Chart with Values

helm install my-release stable/elasticsearch \
  --values ./my-values.yaml
Note: Helm charts are composed of templates, values, and a chart.yaml file.

Key Features of Helm

  • Template engine for Kubernetes manifests
  • Version control and release management
  • Dependency management between charts
  • Supports custom value files for configuration

2. Adding Elastic Helm Repository

Command Description Notes
helm repo add elastic https://helm.elastic.co Add the official Elastic Helm repository Required before installing any Elastic stack components via Helm

Example: Adding the Elastic Helm Repository

helm repo add elastic https://helm.elastic.co
helm repo update
Note: Ensure you have helm CLI installed and configured to interact with your Kubernetes cluster.

3. Installing Elasticsearch Chart

Parameter Default Value Description
elasticsearch.enabled true Enables or disables the Elasticsearch chart
elasticsearch.image docker.elastic.co/elasticsearch/elasticsearch:8.15.3 Image to use for Elasticsearch pods
elasticsearch.replicas 1 Number of Elasticsearch nodes to deploy
elasticsearch.resources.limits.cpu 1000m Maximum CPU limit for Elasticsearch pods
elasticsearch.resources.limits.memory 2Gi Maximum memory limit for Elasticsearch pods
elasticsearch.persistence.enabled true Enables persistent volumes for data storage
elasticsearch.persistence.size 10Gi Size of the persistent volume for Elasticsearch data

Example: Installing Elasticsearch Chart with Custom Values

elasticsearch:
  enabled: true
  image: docker.elastic.co/elasticsearch/elasticsearch:8.15.3
  replicas: 3
  resources:
    limits:
      cpu: 1000m
      memory: 2Gi
  persistence:
    enabled: true
    size: 20Gi
Note: Ensure that the Kubernetes cluster has sufficient resources to support the specified Elasticsearch configuration.

4. Installing Kibana Chart

Parameter Default Value Description
image.repository docker.elastic.co/kibana/kibana Kibana Docker image repository
image.tag 8.15.3 Kibana Docker image tag (latest stable)
service.type ClusterIP Kubernetes service type for Kibana
resources.limits.cpu 1000m CPU limit for Kibana pod
resources.limits.memory 2Gi Memory limit for Kibana pod
ingress.enabled false Enable Ingress for Kibana access

Example: Install Kibana Chart with Custom Values

helm repo add elastic https://helm.elastic.co
helm install my-kibana elastic/kibana \
  --set image.tag=8.15.3 \
  --set service.type=LoadBalancer \
  --set ingress.enabled=true \
  --set ingress.hosts[0]=kibana.example.com
Note: Ensure Elasticsearch is running and accessible before installing Kibana.
Warning: The Kibana chart requires Elasticsearch to be deployed with the same Helm release or accessible via a known service endpoint.

5. Installing Filebeat Chart

Parameter Default Value Description
image.repository docker.elastic.co/beats/filebeat Filebeat Docker image repository
image.tag 8.15.3 Filebeat Docker image tag
image.pullPolicy IfNotPresent Docker image pull policy
serviceAccount.create true Whether to create a service account for Filebeat
serviceAccount.name filebeat Name of the service account to use or create
tolerations [] Tolerations for scheduling Filebeat pods

Example: Installing Filebeat Chart with Custom Values

image:
  repository: docker.elastic.co/beats/filebeat
  tag: 8.15.3
  pullPolicy: Always

serviceAccount:
  create: true
  name: filebeat-sa

tolerations:
  - key: "node-role.kubernetes.io/master"
    operator: "Equal"
    value: "true"
    effect: "NoSchedule"
Note: Ensure that the Kubernetes cluster has the necessary permissions and that the Elastic Stack is properly configured before installing Filebeat.

6. Customizing Values

Example: Overriding Elasticsearch Configuration

elasticsearch:
  config:
    elasticsearch.yml: |
      network.host: 0.0.0.0
      http.port: 9200
      discovery.type: single-node
Value Path Description Default Notes
elasticsearch.config.elasticsearch.yml Configuration file content for Elasticsearch network.host: localhost YAML formatted configuration
elasticsearch.resources.limits.cpu Maximum CPU limit for Elasticsearch pod 1000m Resource limit in millicores
elasticsearch.resources.requests.memory Memory request for Elasticsearch pod 1Gi Resource request in bytes
kibana.config.kibana.yml Configuration file content for Kibana server.host: "0.0.0.0" YAML formatted configuration
logstash.config.logstash.yml Configuration file content for Logstash pipeline.threads: 1 YAML formatted configuration
Note: Values can be overridden using helm install --set key=value or by providing a custom values.yaml file.

7. Upgrading Releases

Example: Upgrade a Release

helm upgrade my-release elastic/elasticsearch
Option Values Description
--set key=value Set values on the command line
--values file.yaml Specify values in a YAML file
--version 1.2.3 Specify a version constraint for the chart
--atomic true Rollback on failure
--timeout 300s Time to wait for any individual Kubernetes operation
Note: Ensure that the new version of the chart is compatible with your existing configuration.
Warning: Upgrading may cause downtime if not configured properly.

8. Rolling Back Releases

Action Description Command
View release history Lists all previous versions of a release helm history <release-name>
Rollback to previous version Revert to a specific revision number helm rollback <release-name> <revision>
Rollback to last successful version Revert to the most recent working release helm rollback <release-name> -1

Example: Rolling Back a Release

helm history my-elk-stack
helm rollback my-elk-stack 3
Note: Ensure that the target revision has been successfully deployed before rolling back to avoid downtime or data loss.

9. Configuring Persistent Storage

Parameter Description Default Value Notes
elasticsearch.persistence.enabled Enables persistent storage for Elasticsearch false Set to true to enable persistent volumes
elasticsearch.persistence.storageClass Storage class to use for persistent volumes "" If not set, uses default storage class
elasticsearch.persistence.size Size of the persistent volume claim 10Gi Adjust based on data size requirements
elasticsearch.persistence.accessModes Access modes for the persistent volume ["ReadWriteOnce"] Valid values: ReadWriteOnce, ReadOnlyMany, ReadWriteMany

Example: Enabling Persistent Storage

elasticsearch:
  persistence:
    enabled: true
    storageClass: "fast-ssd"
    size: "50Gi"
    accessModes:
      - ReadWriteOnce
Note: Persistent storage is crucial for data durability in Elasticsearch clusters.
Warning: Changing storage size after deployment may not be supported in all environments.

10. Setting Resource Requests

Resource Type Property Default Value Description
requests.cpu 500m Half a CPU core
requests.memory 512Mi 512 Mebibytes of RAM
limits.cpu 1000m One full CPU core
limits.memory 1Gi 1 Gibibyte of RAM

Example: Helm Values Configuration

elasticsearch:
  resources:
    requests:
      cpu: "500m"
      memory: "512Mi"
    limits:
      cpu: "1000m"
      memory: "1Gi"

kibana:
  resources:
    requests:
      cpu: "250m"
      memory: "256Mi"
    limits:
      cpu: "500m"
      memory: "512Mi"
Note: Setting appropriate resource requests and limits is crucial for stable deployment in Kubernetes environments.

11. Configuring Ingress

Property Description Default Value Notes
ingress.enabled Enables or disables the Ingress resource false Set to true to enable Ingress
ingress.hosts[0].host Hostname for the Ingress rule elk-stack.local Must be a valid DNS name or IP address
ingress.hosts[0].paths[0] Path for the Ingress rule / Can be any valid path pattern
ingress.annotations Annotations to be added to the Ingress resource {} Used for configuring TLS, authentication, etc.
ingress.tls Enables TLS for the Ingress resource [] Must include secret name and host names

Example: Basic Ingress Configuration

ingress:
  enabled: true
  hosts:
    - host: elk-stack.example.com
      paths:
        - path: /
          pathType: Prefix
  annotations:
    kubernetes.io/ingress.class: nginx
    cert-manager.io/cluster-issuer: letsencrypt-prod
  tls:
    - secretName: elk-stack-tls
      hosts:
        - elk-stack.example.com
Note: Ensure that the Ingress controller is installed and configured in your cluster before enabling this feature.

12. Managing Helm Releases

Action Description Command
Install Release Deploy a new release from a chart helm install [RELEASE_NAME] [CHART]
Upgrade Release Update an existing release with new values or chart version helm upgrade [RELEASE_NAME] [CHART]
Rollback Release Revert to a previous release version helm rollback [RELEASE_NAME] [REVISION]
List Releases Show all installed releases helm list
Show Release Info Display details of a specific release helm show [RELEASE_NAME]
Delete Release Uninstall a release completely helm uninstall [RELEASE_NAME]

Example: Install ELK Stack Release

helm install elasticsearch stable/elasticsearch
helm install kibana stable/kibana

Example: Upgrade Release with New Values

helm upgrade elasticsearch stable/elasticsearch --set replicas=3

Managing Helm Release Lifecycle

  1. Install chart using helm install
  2. Verify deployment with helm list
  3. Update configuration using helm upgrade
  4. Revert changes if needed with helm rollback
  5. Cleanup with helm uninstall when done
Note: Helm releases are tracked in the Kubernetes cluster under the helm namespace. Ensure proper RBAC permissions for managing releases.

Was this article helpful?