Top Helm Chart frequently asked interview questions.
Q: What is Helm and why is it used in Kubernetes?
A : Helm is a package manager for Kubernetes that helps you define, install, and manage Kubernetes applications. It is often referred to as "the Kubernetes package manager" similar to how apt is for Ubuntu or yum is for CentOS.Helm uses a packaging format called charts. A chart is a collection of files that describe a related set of Kubernetes resources. A single chart might be used to deploy something simple, like a memcached pod, or something complex, like a full web app stack with HTTP servers, databases, caches, and so on.
Key benefits of using Helm:
- Simplified Deployment - Allows you to deploy complex applications with a single command
- Version Control - Provides versioning for your Kubernetes manifests
- Reusability - Charts can be shared and reused across teams and organizations
- Rollback Capability - Easy rollback to previous versions if something goes wrong
- Configuration Management - Centralized management of configuration values
Q: What is the structure of a Helm chart?
A : A Helm chart is organized as a collection of files inside a directory. The directory name is the name of the chart (without versioning information). The typical structure of a Helm chart looks like this:mychart/ Chart.yaml # A YAML file containing information about the chart LICENSE # OPTIONAL: A plain text file containing the license for the chart README.md # OPTIONAL: A human-readable README file values.yaml # The default configuration values for this chart values.schema.json # OPTIONAL: A JSON Schema for imposing a structure on the values.yaml file charts/ # A directory containing any charts upon which this chart depends crds/ # Custom Resource Definitions templates/ # A directory of templates that, when combined with values, will generate valid Kubernetes manifests templates/NOTES.txt # OPTIONAL: A plain text file containing short usage notesThe most important files are:
- Chart.yaml - Contains metadata about the chart (name, version, description, etc.)
- values.yaml - Default configuration values that can be overridden during installation
- templates/ - Directory containing Kubernetes manifest templates that use Go templating
Q: What are the main differences between Helm 2 and Helm 3?
A : Helm 3 introduced several significant changes compared to Helm 2:1. Removal of Tiller:
Helm 2 used a server-side component called Tiller that ran inside the Kubernetes cluster. Helm 3 completely removed Tiller, making Helm a fully client-side tool. This eliminates security concerns related to Tiller having elevated permissions.
2. Three-Way Strategic Merge Patches:
Helm 3 uses a three-way strategic merge patch strategy. This means Helm considers the old manifest, the live state, and the new manifest when generating a patch. This provides more accurate upgrades.
3. Release Names are now Scoped to the Namespace:
In Helm 2, release names had to be unique across the entire cluster. In Helm 3, release names are scoped to the namespace, allowing the same release name to be used in different namespaces.
4. Secrets as the Default Storage Driver:
Helm 3 stores release information in Secrets by default (Helm 2 used ConfigMaps). This is more secure and aligns with Kubernetes best practices.
5. Chart Dependencies:
Helm 3 moved chart dependencies from requirements.yaml to Chart.yaml, simplifying the chart structure.
6. JSON Schema Validation:
Helm 3 added support for values schema validation using JSON Schema, helping catch configuration errors early.
Q: How do you pass custom values when installing a Helm chart?
A : There are multiple ways to pass custom values when installing or upgrading a Helm chart:1. Using a values file:
helm install myrelease mychart -f custom-values.yaml2. Using --set flag for individual values:
helm install myrelease mychart --set image.tag=1.2.33. Using --set-string for forcing string values:
helm install myrelease mychart --set-string nodeSelector."kubernetes\.io/role"=master4. Using multiple values files (later files override earlier ones):
helm install myrelease mychart -f values1.yaml -f values2.yaml5. Combining multiple approaches:
helm install myrelease mychart -f custom-values.yaml --set image.tag=1.2.3The order of precedence (highest to lowest) is:
- Values passed via --set or --set-string
- Values from files specified with -f
- Default values from values.yaml in the chart
Q: What are Helm hooks and when would you use them?
A : Helm hooks allow chart developers to intervene at certain points in a release's lifecycle. Hooks work like regular templates but have special annotations that cause Helm to utilize them differently.Available hooks include:
- pre-install - Executes after templates are rendered, but before any resources are created in Kubernetes
- post-install - Executes after all resources are loaded into Kubernetes
- pre-delete - Executes on a deletion request before any resources are deleted from Kubernetes
- post-delete - Executes on a deletion request after all release resources have been deleted
- pre-upgrade - Executes on an upgrade request after templates are rendered, but before any resources are updated
- post-upgrade - Executes on an upgrade request after all resources have been upgraded
- pre-rollback - Executes on a rollback request after templates are rendered, but before any resources are rolled back
- post-rollback - Executes on a rollback request after all resources have been modified
- test - Executes when the Helm test subcommand is invoked
apiVersion: batch/v1
kind: Job
metadata:
name: "{{ .Release.Name }}-db-migration"
annotations:
"helm.sh/hook": pre-install
"helm.sh/hook-weight": "-5"
"helm.sh/hook-delete-policy": before-hook-creation
spec:
template:
spec:
containers:
- name: db-migration
image: "{{ .Values.dbMigration.image }}"
command: ["migrate", "up"]
restartPolicy: Never
Q: How do you manage chart dependencies in Helm?
A : In Helm 3, chart dependencies are managed through the Chart.yaml file. Dependencies are other charts that your chart requires to function properly.Example Chart.yaml with dependencies:
apiVersion: v2
name: myapp
description: A Helm chart for my application
version: 1.0.0
dependencies:
- name: postgresql
version: 11.6.12
repository: https://charts.bitnami.com/bitnami
condition: postgresql.enabled
- name: redis
version: 16.8.7
repository: https://charts.bitnami.com/bitnami
alias: cache
tags:
- cache
Key fields for dependencies:
- name - The name of the chart
- version - The version of the chart (can use version ranges like "~1.2.3")
- repository - The repository URL where the chart is located
- condition - A YAML path to a boolean value that enables/disables the chart
- tags - Labels that can be used to enable/disable groups of charts
- alias - An alternative name for the chart, useful when including the same chart multiple times
helm dependency update mychart/This downloads all dependencies into the charts/ subdirectory.