Exercises

Exercise 0: Setting Up Helm Autocomplete for PowerShell

Before you begin working with Helm commands, set up autocomplete to make your workflow more efficient.
Helm provides autocomplete support for PowerShell that will help you discover commands and options as you type.

Step 1: Generate the Helm Autocomplete Script

Generate the PowerShell autocomplete script for Helm:

helm completion powershell | Out-File -FilePath $PROFILE -Append

This command generates the Helm autocomplete configuration and appends it to your PowerShell profile.
The $PROFILE variable points to your PowerShell profile file, which is loaded every time you start PowerShell.

Step 2: Reload Your PowerShell Profile

If you are currently in a PowerShell session, reload your profile to activate the autocomplete:

. $PROFILE

Alternatively, close and reopen your PowerShell window to load the updated profile.

Step 3: Verify Autocomplete is Working

Test that autocomplete is working by typing `helm ` (with a space) and pressing the Tab key.
You should see available Helm commands appear as suggestions.
You can continue pressing Tab to cycle through the available options.

Autocomplete will now help you discover Helm commands, subcommands, and flags as you work through the exercises.

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

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

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

Step 4: Add the Jetstack Repository

Add the Jetstack Helm repository to your local Helm configuration:

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

Then, pull a chart from the Jetstack repository (for example, the cert-manager chart):

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

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

Update your repository cache to ensure you have the latest chart information:

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

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

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:

helm template cert-manager jetstack/cert-manager | Select-String -Pattern "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

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

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

helm env | Select-String "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

Alternatively, find the exact path using:

helm env | Select-String "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

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