Sobes.tech
Junior

What are the advantages of using Helm in Kubernetes?

sobes.tech AI

Answer from AI

  • Complexity management: Allows describing and deploying even complex applications consisting of many microservices and dependencies as a single entity.
  • Templating: Uses Go templates to create dynamic Kubernetes manifests, making it easy to customize deployments for different environments (dev, staging, prod) without manually editing YAML files.
  • Reusability: Enables creating and sharing application packages (charts) that can be easily installed and configured across different clusters.
  • Versioning: Manages versions of deployed applications, facilitating rollbacks to previous states in case of issues.
  • Updates and rollbacks: Provides a standardized and reliable way to update applications and automatically rollback on failures.
  • Dependencies: Manages dependencies between application components, ensuring the correct deployment order.
  • Ecosystem: An extensive collection of ready-made charts in repositories (e.g., Artifact Hub), allowing quick deployment of popular applications.

Example structure of a Helm chart:

# Chart.yaml - chart metadata
apiVersion: v2
name: my-app
version: 1.0.0
description: A Helm chart for my application
# values.yaml - default values for templating
replicaCount: 1
image:
  repository: my-dockerhub/my-app
  tag: latest
  pullPolicy: IfNotPresent
service:
  type: ClusterIP
  port: 80
# templates/deployment.yaml - Deployment manifest template
apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "my-app.fullname" . }}
  labels:
    {{- include "my-app.labels" . | nindent 4 }}
spec:
  replicas: {{ .Values.replicaCount }}
  selector:
    matchLabels:
      {{- include "my-app.selectorLabels" . | nindent 6 }}
  template:
    metadata:
      labels:
        {{- include "my-app.selectorLabels" . | nindent 8 }}
    spec:
      containers:
        - name: {{ .Chart.Name }}
          image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
          imagePullPolicy: {{ .Values.image.pullPolicy }}
          ports:
            - name: http
              containerPort: 80
              protocol: TCP