0
0
Kafkadevops~5 mins

Helm charts for Kafka - Commands & Configuration

Choose your learning style9 modes available
Introduction
Installing and managing Kafka on Kubernetes can be complex. Helm charts simplify this by packaging Kafka configurations and deployment steps into reusable templates, making setup and updates easier.
When you want to deploy Kafka quickly on a Kubernetes cluster without writing complex YAML files.
When you need to manage Kafka configurations consistently across multiple environments.
When you want to upgrade Kafka versions or configurations with minimal manual changes.
When you want to share your Kafka deployment setup with your team or community.
When you want to automate Kafka deployment as part of your CI/CD pipeline.
Config File - values.yaml
values.yaml
replicaCount: 3
image:
  repository: bitnami/kafka
  tag: 3.5.1
  pullPolicy: IfNotPresent
service:
  type: ClusterIP
  port: 9092
zookeeper:
  enabled: true
  replicaCount: 3
  image:
    repository: bitnami/zookeeper
    tag: 3.8.1
    pullPolicy: IfNotPresent
resources:
  limits:
    cpu: 500m
    memory: 1Gi
  requests:
    cpu: 250m
    memory: 512Mi
persistence:
  enabled: true
  size: 8Gi
  storageClass: standard

This values.yaml file configures the Kafka Helm chart:

  • replicaCount: Number of Kafka broker pods.
  • image: Docker image details for Kafka.
  • service: Defines Kafka service type and port.
  • zookeeper: Enables embedded Zookeeper with its own replicas and image.
  • resources: CPU and memory limits and requests for Kafka pods.
  • persistence: Enables persistent storage with size and storage class.

This file customizes the Kafka deployment on Kubernetes using Helm.

Commands
Add the Bitnami Helm chart repository which contains the Kafka chart.
Terminal
helm repo add bitnami https://charts.bitnami.com/bitnami
Expected OutputExpected
"bitnami" has been added to your repositories
Update your local Helm chart repository cache to get the latest charts.
Terminal
helm repo update
Expected OutputExpected
Hang tight while we grab the latest from your chart repositories... ...Successfully got an update from the "bitnami" chart repository Update Complete.
Install Kafka using the Bitnami Helm chart with your custom configuration from values.yaml.
Terminal
helm install my-kafka bitnami/kafka -f values.yaml
Expected OutputExpected
NAME: my-kafka LAST DEPLOYED: Sat Jun 10 12:00:00 2023 NAMESPACE: default STATUS: deployed REVISION: 1 TEST SUITE: None
-f - Specify a custom values file to override default chart settings
Check the status of Kafka pods to ensure they are running after installation.
Terminal
kubectl get pods -l app.kubernetes.io/name=kafka
Expected OutputExpected
NAME READY STATUS RESTARTS AGE my-kafka-0 1/1 Running 0 1m my-kafka-1 1/1 Running 0 1m my-kafka-2 1/1 Running 0 1m
-l - Filter pods by label selector
Key Concept

If you remember nothing else from this pattern, remember: Helm charts package complex Kafka deployment details into simple commands and configuration files for easy Kubernetes management.

Common Mistakes
Not adding the Helm repository before trying to install the Kafka chart.
Helm cannot find the Kafka chart without the repository added, causing installation failure.
Always run 'helm repo add bitnami https://charts.bitnami.com/bitnami' before installing the chart.
Forgetting to update the Helm repo cache after adding a new repository.
Helm may use outdated chart information, leading to errors or installing old versions.
Run 'helm repo update' after adding or before installing charts to get the latest versions.
Installing Kafka without specifying a values file when custom settings are needed.
Kafka will deploy with default settings that may not fit your resource or persistence needs.
Use the '-f values.yaml' flag to apply your custom configuration during installation.
Summary
Add the Bitnami Helm repository to access Kafka charts.
Update Helm repositories to get the latest chart versions.
Install Kafka using Helm with a custom values.yaml file for configuration.
Verify Kafka pods are running using kubectl with label filtering.