Helm Chart 101
Helm is a package manager for Kubernetes that simplifies the deployment and management of applications on a Kubernetes cluster. It helps in defining, installing, and upgrading even complex Kubernetes applications using configurations called Helm charts.
Here’s a basic rundown of Helm concepts:
- Chart: A Helm chart is a collection of files that describe a Kubernetes application. It contains YAML-formatted templates for Kubernetes manifest files and metadata. Charts can be customized through values files to suit specific deployment needs.
- Release: When you install a Helm chart onto a Kubernetes cluster, it creates an instance of that chart called a release. Releases are individual deployments of a chart.
- Repository: A Helm repository is a place where charts are stored and shared. Official Helm charts are often available in public repositories, but you can also create your private repositories to manage your charts.
- Values: Helm allows the customization of charts using values files. These files contain configurable parameters that are used to modify the default behavior of the chart.
- Template: Helm uses Go template language to generate Kubernetes manifest files from the chart’s templates. These templates can contain placeholders and logic to create dynamic configurations.
Helm Commands:
helm install
: Installs a chart onto your Kubernetes cluster.helm upgrade
: Upgrades a release to a new version of a chart.helm uninstall
: Uninstalls a release from the cluster.helm list
: Lists all releases deployed on the cluster.helm repo add
: Adds a chart repository to Helm.helm repo update
: Updates local Helm repository cache.
Basic Workflow:
- Install Helm: Install Helm on your local machine and initialize it on your Kubernetes cluster.
- Explore Repositories: Discover available charts by exploring Helm repositories, including both official and community-maintained charts.
- Customize Values: Customize values in a chart’s
values.yaml
file or create your ownmy-values.yaml
to override default configurations. - Install/Upgrade: Use
helm install
to deploy a chart onto the cluster. Usehelm upgrade
to update a release with changes. - Manage Releases: Use
helm list
to see the deployed releases andhelm uninstall
to remove a release when necessary.
Installation:
- Installing Helm:
- Visit the Helm GitHub releases page or Helm’s official site.
- Choose the appropriate installation method for your OS (Linux, macOS, or Windows).
- Follow the installation instructions provided.
- Initialise Helm:
- After installation, initialize Helm on your Kubernetes cluster by running:
helm init
.
- After installation, initialize Helm on your Kubernetes cluster by running:
Basic Commands:
- Adding Repositories:
- To add a repository:
helm repo add <repository_name> <repository_url>
. - Example:
helm repo add stable https://charts.helm.sh/stable
.
- To add a repository:
- Updating Repositories:
- Refresh local repository cache:
helm repo update
.
- Refresh local repository cache:
- Installing a Chart:
- Use
helm install
to deploy a chart onto your cluster. - Example:
helm install my-release stable/mysql
.
- Use
- Customizing Values:
- Customize values in a chart using
--set
flag or by creating a separate values file:helm install my-release -f values.yaml stable/mysql
.
- Customize values in a chart using
- Upgrading a Release:
- To update a release:
helm upgrade my-release stable/mysql
. - If using a values file:
helm upgrade my-release -f new-values.yaml stable/mysql
.
- To update a release:
- Listing Releases:
- To list releases deployed on the cluster:
helm list
.
- To list releases deployed on the cluster:
- Uninstalling a Release:
- Remove a release:
helm uninstall my-release
.
- Remove a release:
Best Practices:
- Version control your Helm charts and values files.
- Use namespaces to organize your deployments.
- Regularly update Helm and your Helm repositories for the latest features and security patches.
- Be cautious while upgrading releases to avoid breaking changes.
Helm simplifies Kubernetes application management by providing a standardised way to package, configure, and deploy applications, ensuring scalability, repeatability, and maintainability within Kubernetes environments.