What is Helm
- Helm is a package manager for Kubernetes that uses Helm charts to define, install, and upgrade Kubernetes applications.
- Helm charts encapsulate application logic, dependencies, and configurations, making it easier to deploy complex applications consistently
Install Helm
curl https://baltocdn.com/helm/signing.asc | gpg --dearmor | sudo tee /usr/share/keyrings/helm.gpg > /dev/null sudo apt-get install apt-transport-https --yes echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/helm.gpg] https://baltocdn.com/helm/stable/debian/ all main" | sudo tee /etc/apt/sources.list.d/helm-stable-debian.list sudo apt-get update sudo apt-get install helm helm repo list helm repo add bitnami <https://charts.bitnami.com/bitnami> helm repo list helm repo remove bitnami helm repo add bitnami <https://charts.bitnami.com/bitnami>
Search Repo
helm search repo mysql helm search repo database helm search repo database --versions
Install Package
helm install mydb bitnami/mysql helm install tomcat bitnami/tomcat
Check Installation
helm status mydb
Upgrade
ROOT_PASSWORD=$(kubectl get secret --namespace default mydb-mysql -o jsonpath="{.data.mysql-root-password}" | base64 --decode) helm upgrade --namespace default mysql-release bitnami/mysql --set auth.rootPassword=$ROOT_PASSWORD helm uninstall mysql-release
Architecture
Advantages
- Makes application deployment easy
- Standardize and reusable
- Improves developer productivity
- Reduces deployment complexity
Helm 2 Vs Helm 3
- Architecture: Helm 2 has Tiller server-side component, while Helm 3 operates entirely on the client-side.
- Namespaces: Helm 2 has a global scope by default, while in Helm 3 we can create same name charts in different namespace.
- Chart Dependencies: Helm 2 uses a separate "requirements.yaml" file, while Helm 3 includes dependencies within "Chart.yaml".
- Release Management: Helm 2 manages releases with Tiller, while Helm 3 manages releases directly from the Helm CLI.
- Chart Repositories: Helm 2 has built-in repositories, while Helm 3 relies on external repositories or local directories.
- Chart Hooks: Helm 2 and Helm 3 both support hooks, with Helm 3 introducing a new "pre-install" hook.
- Security: Helm 3 removes Tiller, improving security by reducing the attack surface.
Lint
Helm lint is a command in Helm used to perform a static analysis of a Helm chart. It checks the validity and quality of a Helm chart by examining its structure, metadata, and template files.
Chart Structure
mychart |-- Chart.yaml > metadata like name, version, and dependencies. |-- values.yaml > default configuration values for your chart. |-- values.schema.json > used to validate all the values that are provided in values.yaml |-- charts > used to store any dependencies that your chart relies on. |-- templates > define all the K8s manifests regarding your app deployment. |-- NOTES.txt > serves as a post-installation message to provide important details and instructions to users about the deployed application |-- helper.tpl > allows you to organize and encapsulate common logic or complex operations in a separate file, improving code readability and maintainability in Helm charts.
Release
helm create <chart_name> helm create helloworld helm install <release_name> <chart_name> helm install helloworld helloworld helm upgrade <release_name> <chart_name> helm upgrade myrelease ./mychart helm rollback [release] [revision] helm rollback myrelease 1 helm --debug --dry-run helm install --debug --dry-run myrelease ./mychart helm template helm template ./mychart Note: The difference between the two commands is that helm install --dry-run will send things to a Kubernetes cluster, but helm template won't. helm lint helm lint ./mychart Note: This command is used to check a Helm chart for possible issues. It verifies the chart's structure and configuration files. helm uninstall helm uninstall myrelease helm upgrade <release_name> <chart_name> [flags]