What is Helm?
Helm is an open-source packaging tool that helps you install and manage Kubernetes applications. It streamlines the installation and management of complex Kubernetes applications.
At its core, Helm provides a packaging format called Helm charts. A Helm chart is a collection of files that describes a related set of Kubernetes resources. This could be a simple deployment, or something more complex like a full web application stack. The Helm chart contains all the information necessary for installing and configuring the application on Kubernetes.
Helm charts allow you to:
- Package Kubernetes resources in a reusable way
- Deploy and upgrade applications easily
- Share applications with others
- Rollback to previous versions
- Customize applications for different environments
So in summary:
- Helm helps you define, install, and upgrade complex Kubernetes applications
- Helm uses a packaging format called Helm charts
- Charts are bundles of pre-configured Kubernetes resources
By using Helm and charts, you can easily deploy, manage, and update even the most complex Kubernetes applications.
How Helm Works
Helm has a client-server architecture that consists of two components - the Helm client and the Tiller server.
The Helm client is a command line interface (CLI) that end users interact with. It allows you to perform operations like:
- Install and uninstall charts
- Upgrade and rollback releases
- Manage repositories
- Create and package charts
The Helm client connects to the Tiller server to send instructions.
Tiller runs inside your Kubernetes cluster and communicates with the Kubernetes API. It receives instructions from the Helm client and executes them against the Kubernetes cluster.
Tiller manages releases, which are installtions of a chart. When you run a Helm install command, the chart is packaged and sent to Tiller, which installs it on Kubernetes. Tiller maintains the state of installed charts and manages complex operations like upgrades and rollbacks.
This separation of concerns allows Helm to provide simple user experience through its CLI, while Tiller does the heavy lifting of managing releases and interacting directly with Kubernetes. The client never talks to Kubernetes directly, everything goes through Tiller. This client-server architecture makes Helm powerful while keeping it simple to use.
Installing Helm
Before you can start using Helm to manage Kubernetes applications, you'll first need to get Helm installed on your local machine and initialize it in your Kubernetes cluster.
Download and Install the Helm CLI
To install the Helm CLI, follow these steps:
- Download the latest Helm release from the official releases page. Select the package for your OS and architecture.
- Unpack the downloaded release. For example:
- tar -zxvf helm-v3.0.0-linux-amd64.tar.gz
- Find the Helm binary in the unpacked directory and move it to its desired destination. For example:
- mv linux-amd64/helm /usr/local/bin/helm
- Test the installation by running helm version. You should see the client and server versions displayed.
Initialize Helm in Your Kubernetes Cluster
Once the Helm CLI is installed locally, you need to initialize Helm in your Kubernetes cluster. This will install the Tiller component which manages Helm releases.
To initialize Helm, run:
This will install Tiller into the kube-system namespace. Make sure Tiller installed correctly by running helm version and checking the server version.
Have a Kubernetes Cluster Running
Lastly, you'll need a Kubernetes cluster up and running before you can install applications with Helm. Make sure kubectl is configured to connect to your cluster.
With Helm installed locally and initialized in your cluster, you're now ready to start using it to deploy applications!
Helm Charts
Helm uses a packaging format called charts. A chart is a collection of files that describe a related set of Kubernetes resources. Charts provide a way to package an application's dependencies, configurations, and deployment information into a deployable bundle.
A Helm chart contains:
- Templates: A configurable template that defines the Kubernetes resources required to run an application, written in YAML. Things like deployments, services, ingress rules, and persistent volumes can all be defined as templates.
- Values: Default configuration values for the templates. These values can be overridden at deployment time. Defining values avoids hard coding configuration details.
- Charts: Charts can have chart dependencies, allowing reuse of common functionality charts.
- Metadata: Information like the name, version, description, and keywords about the chart.
Charts simplify deploying applications to Kubernetes. Instead of manually defining Kubernetes YAML for an application, you can create a Helm chart that packages everything up in a reusable way. Anyone with the chart can then install the application with a single helm install command.
Many charts for popular applications are available from public chart repositories like the official Helm Hub or Bitnami's chart repository. You can search for and install charts with commands like helm search and helm install. Or if your application needs specific configuration, you can create your own custom charts.
Overall, Helm charts allow you to reuse complex Kubernetes application definitions across environments. By packaging everything into a Helm chart, you can version, share, and install an application without worrying about the underlying details.
Deploying Apps with Helm
Helm allows you to easily deploy applications to Kubernetes using pre-configured charts. Here are the basic steps:
- Find a chart - Helm charts can be found on public repositories like the Helm Hub and Artifact Hub. You can search for charts for common applications like MySQL, MongoDB, Jenkins, and more.
- Customize the chart - Charts have default configurations, but you can customize the deployment by creating a values.yaml file. This sets overrides for things like resource requests, environment variables, volumes, and more.
- Install the chart - Run the helm install command, specifying your custom values file. This will deploy the application to Kubernetes based on the chart. For example:
This will install the MySQL chart as a new release called my-release, using your custom values in values.yaml.
The install command deploys the resources defined in the chart to your Kubernetes cluster. You can check the release status with helm list and helm status.
That's the basic workflow for deploying applications with Helm! You can deploy, update, rollback and delete releases. Helm handles applying changes to Kubernetes to keep your applications running.
Managing Releases
Once you start deploying applications to your Kubernetes cluster with Helm, you'll want to be able to manage those application releases. Helm provides several useful commands for managing releases:
helm list - List all of the releases that have been deployed in the cluster:
This will show all releases along with information like the name, namespace, revision number, updated time, status, and chart name.
helm status - Check the status of a particular release:
This will show you detailed status information about the release, like the resources that were deployed, the state of those resources, and other useful info.
helm rollback - If something goes wrong with a release, rollback to a previous revision:
This will undo the latest upgrade and revert back to the previous release version.
helm upgrade - Upgrade an existing release to deploy an updated version of your app:
This will upgrade the my-release release to the latest mysql chart version.
Managing Helm releases is critical for running applications in production. helm list gives you visibility into what's deployed, helm status helps diagnose issues, and helm rollback gives you an escape hatch if needed. Master these release management commands to run Kubernetes apps smoothly.
Creating Charts
Helm allows you to create your own charts to package and deploy your applications on Kubernetes. This makes it easy to share your apps with others in a reusable way.
To create a new Helm chart, use the helm create command:
This will generate a new chart directory called mychart with the following files:
- charts/ - for chart dependencies
- templates/ - Contains YAML templates for Kubernetes manifests
- values.yaml - Default configuration values
- Chart.yaml - Metadata about the chart like name and version
The templates/ directory contains YAML files that template out Kubernetes manifests for deploying your application. When you install or upgrade the chart, Helm will process these templates and send the resulting manifests to the Kubernetes API.
The values.yaml file contains default configuration values. These can be overwritten at installation time, allowing users to customize the chart when deploying.
You can add additional templates, values, and dependencies to create a fully-featured Helm chart. Some best practices include:
- Follow Helm conventions for naming templates and values
- Parameterize your templates with values to make them configurable
- Set default values in values.yaml
- Add README documentation explaining how to use the chart
By creating charts for your own applications, you can package them up for easy deployment and sharing. Just push your charts to a repository like ChartMuseum and others will be able to find, install, and customize your applications on Kubernetes.
Sharing Helm Charts
One of the most powerful features of Helm is the ability to package Kubernetes manifests, configurations, and documentation into reusable charts that can be shared publicly or privately. Here are some ways to share your own Helm charts:
Host Charts in a Git Repository
You can host Helm charts in a git repository such as GitHub or GitLab. Simply include your packaged chart directory in the repository. You can then share or point others to the raw chart URL to install it directly with Helm.
For example:
Using a git repository makes it easy to track changes, accept contributions, and share your charts both publicly and privately.
Run Your Own Chart Repository
For large organizations with many internal charts, you may want to run your own Helm chart repository. The ChartMuseum project makes this simple by providing a Helm Chart Repository server with support for Amazon S3, Google Cloud Storage, Alibaba Cloud OSS Storage, and more.
You can install ChartMuseum into your cluster and host all your organization's approved charts in one easy-to-manage repository.
Submit to Official Helm Repos
To share your chart with the wider Kubernetes community, consider submitting it to one of the official Helm chart repositories like Artifact Hub or the Kubernetes Charts repo. These provide curated sources of high-quality charts that follow best practices.
Going through the submission process for an official repo helps improve your chart quality through community reviews. And having your chart included makes it available to all Helm users for easy discovery and installation.
Sharing your charts, whether publicly or privately, unlocks the full potential of Helm as a way to distribute reusable Kubernetes applications.
Helm Tips and Tricks
Helm provides a robust toolset for managing Kubernetes applications. Here are some tips and tricks for getting the most out of Helm:
Debug Locally with helm template
The helm template command is useful for debugging charts locally before deploying them. This renders the templates locally without installing anything to your cluster.
This is great for verifying your templates render as expected.
Set Dependencies Between Charts
You can define chart dependencies in the Chart.yaml file. This allows you to break up a large complicated chart into smaller modular charts.
dependencies:- name: mysql version: 0.10.2 repository: https://example.com/charts
Use Helm Tools
The Helm ecosystem provides useful tools:
- ChartMuseum - Chart repository for hosting and sharing charts
- Helmfile - Helm deployment automation
- Helm Diff - Preview helm upgrade changes
- Helm Secrets - Encrypt secrets in your helm charts
Make use of these tools to enhance your Helm workflows.
Reuse Values
Extract common values into a values.yaml file that can be inherited by multiple charts. This avoids duplicating configs.
Abstract Templates
Break templates into partials that can be included from multiple charts to avoid duplication.
Validate Values
Use the schemas.yaml file to validate user-provided values for a chart before installation. This helps avoid errors.
By following these tips, you'll be able to effectively create, debug, and manage production-grade Helm charts.
Getting Help with Helm
Helm has an active open source community that you can tap into for help and advice on using Helm. Here are some ways to connect with the Helm community:
- Read the Helm documentation - The Helm docs are comprehensive and cover installation, using Helm, charts, tips and tricks, Kubernetes integration and more. They should be your first stop when looking for help.
- Join the Helm Slack channel - Meet and chat with other Helm users by joining the #helm channel on the Kubernetes Slack. It's a great place to ask questions and discuss best practices.
- Follow the Helm Twitter account - Follow @helmpack on Twitter to stay up to date with the latest Helm news, releases, tutorials, and events. The Helm team is active on Twitter.
- Attend Helm meetups and conferences - There are Helm meetups in cities around the world. Attending one is a great way to meet the community. There is also an annual Helm Summit conference.
The Helm community is full of experienced users who are willing to help. Don't be afraid to reach out through one of the above channels to get your Helm questions answered!