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+).

Step 2: Reload your profile

. $PROFILE
source ~/.bashrc

Alternatively, close and reopen the PowerShell window, or in bash open a new terminal after the previous echo to ~/.bashrc (if you have not also run source ~/.bashrc in this session yet).

Step 3: Verify

Type `helm `, press the Tab key, and you should see command suggestions. Press Tab again to move through the list.

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.
First, you may need to pull the starter chart or use it directly:

helm create my-jetstack-chart --starter jetstack/cert-manager
helm create my-jetstack-chart --starter jetstack/cert-manager

Alternatively, if you have a local starter, you can specify the path to the starter chart.

This creates a new chart based on the Jetstack starter template, giving you a foundation that follows Jetstack’s chart structure and best practices.

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:
* ServiceAccount resources
* ClusterRole resources
* ClusterRoleBinding resources
* Role resources
* RoleBinding resources

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)"

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.

Step 2: Show the Structure of the Repository Configuration

Helm stores repository information in a configuration file.
First, identify where Helm stores its configuration by checking the output from helm env, or use the default location.
On Windows, this is typically in your user profile directory.

View the repository configuration file:

Get-Content $env:USERPROFILE\.config\helm\repositories.yaml
cat "$HOME/.config/helm/repositories.yaml"

If the file does not exist at that location, you can find the exact path using:

helm env | Select-String "HELM_REPOSITORY_CONFIG"
helm env | grep HELM_REPOSITORY_CONFIG

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.
View the registry configuration file:

Get-Content $env:USERPROFILE\.config\helm\registry.json
cat "$HOME/.config/helm/registry.json"

Alternatively, find the exact path using:

helm env | Select-String "HELM_REGISTRY_CONFIG"
helm env | grep HELM_REGISTRY_CONFIG

This file 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 $env:USERPROFILE\.config\helm\ -Recurse
ls -R "$HOME/.config/helm"
# or, show every file: find "$HOME/.config/helm" -type f

This shows you all Helm configuration files and directories, giving you a complete view of Helm’s local configuration structure.