Learnitweb

Helm Dry Run

Introduction

Helm provides a powerful feature called “dry run” that allows you to simulate an installation or upgrade without actually applying any changes to your Kubernetes cluster. This feature is particularly useful for debugging and verifying that the Kubernetes resources will be created as expected before committing the deployment.

In this tutorial, we will walk through the process of running a dry run for a Helm installation and understanding the different sections of the output.

Running a Helm Dry Run

Step 1: Open the Command Line

Ensure you have Helm installed and configured on your system. Open a terminal or command prompt.

Step 2: Execute the Dry Run Command

Run the following command to perform a dry run for a MySQL installation:

helm install mydb bitnami/mysql --values /path/to/values.yaml --dry-run
  • mydb is the release name for this installation.
  • bitnami/mysql is the Helm chart name.
  • --values /path/to/values.yaml specifies the values file you created earlier.
  • --dry-run tells Helm to simulate the installation without applying changes.

Step 3: Understanding the Dry Run Output

When you execute the above command, Helm will process the first four phases of an installation but will not apply the changes to Kubernetes. The output is divided into three key sections:

1. Release Information

  • Displays the name, namespace, and deployment status.
  • Since this is a dry run, the status will be PENDING_INSTALL instead of DEPLOYED.
  • Example:
NAME: mydb
LAST DEPLOYED: Fri Mar 19 10:00:00 2025
NAMESPACE: default
STATUS: PENDING_INSTALL
REVISION: 1

2. Kubernetes Template Output

  • This section contains all the Kubernetes resource definitions generated from the Helm chart.
  • Templates include ServiceAccount, Secrets, ConfigMaps, Services, and StatefulSets.
  • Example output snippet:
---
# ServiceAccount definition
auth:
  create: true
  serviceAccountName: mydb-mysql
---
# Secret definition
apiVersion: v1
kind: Secret
metadata:
  name: mydb-mysql
---
# ConfigMap definition
apiVersion: v1
kind: ConfigMap
metadata:
  name: mydb-mysql-config
  • Each section is separated by ---.
  • These templates help ensure that the correct resources will be created with the appropriate values.

3. Release Notes

  • The final section provides a summary of important details such as database credentials, connection instructions, and post-installation steps.
  • Example:
NOTES:
MySQL root password: $(MYSQL_ROOT_PASSWORD)
To connect to your database, run the following command:
kubectl run mydb-mysql-client --rm --tty -i --image=mysql -- bash

Benefits of Using Helm Dry Run

  1. Debugging: Helps identify errors in chart templates before deployment.
  2. Template Validation: Ensures all Kubernetes objects are properly generated.
  3. Value Substitution: Confirms that the provided values are correctly injected into templates.
  4. Previews Changes: Before performing an actual upgrade, see how the deployment would change.