Exercises
Exercise 0: Setting Up Helm Autocomplete and Completion
Before you work with Helm, enable shell completion so you can discover subcommands and options faster. Helm can generate a completion script for PowerShell and for bash (typical on Linux, macOS, and Git Bash). Use the option that matches your environment.
Step 1: Generate the autocomplete script
helm completion powershell | Out-File -FilePath $PROFILE -Append
echo 'source <(helm completion bash)' >> ~/.bashrc
The generated configuration is appended to your PowerShell profile. The $PROFILE variable is the path to that profile, which loads each time you start PowerShell.
The bash panel appends a common completion loader line to your ~/.bashrc (Bash 4+).
Exercise 1: Creating Charts and Working with Repositories
In this exercise, you will create a Helm chart, explore its structure, work with repositories, and create a chart using a starter template.
Step 1: Create a New Chart
Create a new Helm chart named my-first-chart:
helm create my-first-chart
helm create my-first-chart
Step 2: List All of the Files Created
List all of the files that were created in the chart directory:
Get-ChildItem -Path .\my-first-chart -Recurse
ls -R my-first-chart
# or list every file with paths:
# find my-first-chart -type f
This command shows you the complete directory structure of your new chart, including all subdirectories and files.
Step 3: Delete the Chart
Remove the chart directory that you just created:
Remove-Item -Path .\my-first-chart -Recurse -Force
rm -rf my-first-chart
Step 4: Add the Jetstack Repository
Add the Jetstack Helm repository to your local Helm configuration:
helm repo add jetstack https://charts.jetstack.io
helm repo add jetstack https://charts.jetstack.io
Step 5: Pull the Jetstack Chart
Update your repository information and pull a chart from the Jetstack repository.
First, update your local repository cache:
helm repo update
helm repo update
Then, pull a chart from the Jetstack repository (for example, the cert-manager chart):
helm pull jetstack/cert-manager
helm pull jetstack/cert-manager
This downloads the chart package to your current directory.
Step 6: Create a New Helm Chart with Jetstack as the Starter
Create a new Helm chart using a Jetstack starter template.
--starter does not accept a repository chart reference such as jetstack/cert-manager; it looks up a starter by name in Helm’s starters directory.
First, unpack the cert-manager chart into that directory, then create your chart from it:
helm pull jetstack/cert-manager --untar `
--untardir "$(helm env HELM_DATA_HOME)\starters"
helm create my-jetstack-chart --starter cert-manager
helm pull jetstack/cert-manager --untar \
--untardir "$(helm env HELM_DATA_HOME)/starters"
helm create my-jetstack-chart --starter cert-manager
Alternatively, --starter accepts an absolute path to an unpacked chart directory.
This creates a new chart based on the Jetstack starter template, giving you a foundation that follows Jetstack’s chart structure and best practices.
|
A starter provides only the templates and values.
|
Exercise 2: Finding RBAC Settings for cert-manager
In this exercise, you will explore the cert-manager Helm chart to find its RBAC (Role-Based Access Control) settings.
You will examine the default values and use templating to see what RBAC resources would be created.
Step 1: Add the Jetstack Repository
If you have not already added the Jetstack repository, add it now:
helm repo add jetstack https://charts.jetstack.io
helm repo add jetstack https://charts.jetstack.io
Update your repository cache to ensure you have the latest chart information:
helm repo update
helm repo update
Step 2: Show What the Default Values Are
View the default values for the cert-manager chart:
helm show values jetstack/cert-manager
helm show values jetstack/cert-manager
This command displays all the default configuration values for the cert-manager chart.
Look through the output to find RBAC-related settings, which are typically under sections like rbac, serviceAccount, or global.rbac.
Step 3: Template the Install with Default Values
Use the helm template command to render the cert-manager chart with default values and examine the RBAC resources that would be created:
helm template cert-manager jetstack/cert-manager
helm template cert-manager jetstack/cert-manager
This command renders all the Kubernetes manifests that would be created when installing cert-manager.
Search through the output for RBAC resources such as:
-
ServiceAccountresources -
ClusterRoleresources -
ClusterRoleBindingresources -
Roleresources -
RoleBindingresources
You can also filter the output to show only RBAC-related resources by piping the output through Select-String (or grep on macOS, Linux, or Git Bash):
helm template cert-manager jetstack/cert-manager |
Select-String -Pattern `
"^kind: (ServiceAccount|ClusterRole|ClusterRoleBinding|Role|RoleBinding)"
helm template cert-manager jetstack/cert-manager | \
grep -E \
"^kind: (ServiceAccount|ClusterRole|ClusterRoleBinding|Role|RoleBinding)"
The ^ anchors the match at the start of the line, so the indented kind: fields inside roleRef and subjects are not counted.
This helps you quickly identify all RBAC-related resources that the chart would create.
Exercise 3: Exploring Local Helm Configuration
In this exercise, you will explore Helm’s local configuration and settings.
You will examine Helm’s environment variables and inspect the structure of registry and repository configuration files.
Step 1: Identify Helm’s Current Settings
Use the helm env command to display Helm’s current environment settings:
helm env
helm env
This command shows important Helm configuration paths and settings, including:
-
The location of Helm’s configuration directory
-
The location of the cache directory
-
The location of the data directory
-
Plugin and registry paths
These paths tell you where Helm stores its configuration files and cached data on your system.
Always treat helm env as the source of truth: the locations depend on your operating system and can be changed with the HELM_CONFIG_HOME, HELM_CACHE_HOME, and HELM_DATA_HOME environment variables (or the XDG_CONFIG_HOME, XDG_CACHE_HOME, and XDG_DATA_HOME variables, which Helm also honors).
You can also print a single setting by passing its name, which is handy in scripts:
helm env HELM_CONFIG_HOME
helm env HELM_CONFIG_HOME
If nothing has been overridden, the default locations are:
| Operating system | Configuration (HELM_CONFIG_HOME) |
Cache (HELM_CACHE_HOME) |
Data (HELM_DATA_HOME) |
|---|---|---|---|
Linux |
|
|
|
macOS |
|
|
|
Windows |
|
|
|
Step 2: Show the Structure of the Repository Configuration
Helm stores repository information in a configuration file whose path is reported by helm env as HELM_REPOSITORY_CONFIG.
By default, it is repositories.yaml in the configuration directory from the table above.
View the repository configuration file:
Get-Content (helm env HELM_REPOSITORY_CONFIG)
cat "$(helm env HELM_REPOSITORY_CONFIG)"
If the command reports that the file does not exist, you have not added any repositories yet.
Add one (for example, with helm repo add) and try again.
This shows you the structure of your repository configuration, including all repositories you have added, their URLs, and metadata.
Step 3: Show the Structure of the Registry Configuration
Helm also maintains configuration for OCI registries, at the path reported by helm env as HELM_REGISTRY_CONFIG (by default, registry/config.json in the configuration directory).
View the registry configuration file:
Get-Content (helm env HELM_REGISTRY_CONFIG)
cat "$(helm env HELM_REGISTRY_CONFIG)"
If you have not logged in to a registry with helm registry login yet, the file may not exist.
It contains authentication and configuration information for OCI registries that you have logged into.
It may include credentials, registry URLs, and other registry-specific settings.
You can also explore the Helm configuration directory structure:
Get-ChildItem -Path (helm env HELM_CONFIG_HOME) -Recurse
ls -R "$(helm env HELM_CONFIG_HOME)"
# or, show every file: find "$(helm env HELM_CONFIG_HOME)" -type f
This shows you all Helm configuration files and directories, giving you a complete view of Helm’s local configuration structure.