Helm -Commands

 

 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

 

 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Link : Getting Started with Helm Chart | Jhooq

Helm is a package manager for Kubernetes that simplifies the deployment and management of applications. It uses charts, which are collections of pre-configured Kubernetes resources, to define, package, and install applications on a Kubernetes cluster. Here's a list of commonly used Helm commands:

  1. Initialize Helm:

    • helm init or helm repo add stable https://charts.helm.sh/stable: Initializes Helm on your cluster and adds the official Helm stable repository (deprecated since Helm v3).
  2. Managing Repositories:

    • helm repo add <name> <url>: Adds a new repository.
    • helm repo list: Lists the available repositories.
    • helm repo update: Updates the local cache of available charts from the configured repositories.
  3. Search and Inspect Charts:

    • helm search <keyword>: Searches for charts in the configured repositories.
    • helm inspect <chart>: Displays information about a chart.
  4. Installing and Upgrading Charts:

    • helm install <release-name> <chart>: Installs a chart as a new release.
    • helm upgrade <release-name> <chart>: Upgrades an existing release with a new chart version.
    • helm rollback <release-name> <revision>: Rolls back a release to a previous version.
  5. Managing Releases:

    • helm list: Lists all releases on the cluster.
    • helm status <release-name>: Displays the status of a release.
    • helm get <value> <release-name>: Retrieves specific information about a release.
    • helm delete <release-name>: Deletes a release.
  6. Values and Overrides:

    • helm install -f <values-file.yaml> <release-name> <chart>: Installs a chart with values from a specified file.
    • helm install --set <key>=<value> <release-name> <chart>: Sets a value during chart installation.
    • helm upgrade -f <values-file.yaml> <release-name> <chart>: Upgrades a release with new values.
  7. Package Charts:

    • helm package <chart-dir>: Packages a chart directory into a distributable tarball.
  8. Linting and Testing Charts:

    • helm lint <chart>: Lints a chart for potential issues.
    • helm test <release-name>: Runs tests defined in a chart.
  9. Plugin Management:

    • helm plugin install <plugin-name>: Installs a Helm plugin.
    • helm plugin list: Lists installed Helm plugins.
  10. Repository Maintenance:

    • helm repo index .: Creates or updates an index.yaml file for a chart repository.
    • helm repo remove <name>: Removes a repository.
  11. Updating Helm:

    • Helm v2: helm init --upgrade: Upgrades Helm and the Tiller server (deprecated since Helm v3).
    • Helm v3: Helm v3 doesn't have a separate Tiller component.

Remember that command usage and syntax may vary based on the Helm version you are using. It's recommended to consult the official Helm documentation or run helm --help or helm <command> --help for more detailed information about each command and its options.

 

Here’s a detailed explanation of the Helm commands you listed, arranged in an organized manner with examples:

1. helm create

The helm create command is used to create a new Helm chart. It generates the basic file structure for a Helm chart that you can customize with your application configurations.

Example:

bash

helm create my-chart

This command creates a new directory called my-chart with the default Helm chart structure, including templates, values files, and metadata.


2. helm install

The helm install command is used to install a Helm chart (either a local chart or a chart from a repository) onto your Kubernetes cluster. It will deploy the resources defined in the chart to the cluster.

Example:

bash

helm install my-release my-chart

This installs the my-chart chart as a release named my-release.

To install from a repository:

bash

helm install my-release stable/mysql

This installs the MySQL chart from the Helm stable repository.


3. helm upgrade

The helm upgrade command is used when you want to upgrade an existing release to a new version of the chart or a modified configuration file. If you have already installed your Helm chart and you have made some changes to the configuration file, you need to use this command to apply those changes.

Example:

bash

helm upgrade my-release my-chart

This upgrades the my-release release with the latest version of the my-chart chart or changes to its configuration.


4. helm rollback

The helm rollback command is used to roll back a release to a previous version. This is helpful if something goes wrong after an upgrade, and you want to revert to a stable state.

Example:

bash

helm rollback my-release 1

This rolls back my-release to version 1 of the chart.

To rollback to a specific version:

bash

helm rollback my-release 2

You can also roll back to the previous release version using:

bash

helm rollback my-release

5. helm --debug --dry-run

The --dry-run flag simulates an install or upgrade without actually applying the changes to the Kubernetes cluster. This is useful to see what will happen without making any real changes. The --debug flag provides additional logging for debugging purposes.

Example:

bash

helm install my-release my-chart --dry-run --debug

This command performs a dry run of the helm install command, showing the Kubernetes resources that would be created, without actually deploying them.


6. helm template

The helm template command is used to render the Helm chart templates locally without actually installing the chart on the cluster. This allows you to see what Kubernetes YAML files will be generated by your Helm chart.

Example:

bash

helm template my-release my-chart

This will output the rendered Kubernetes YAML files to your terminal, showing the configuration that would be applied to your cluster.


7. helm lint

The helm lint command is used to check the syntax of a chart. It helps to identify potential issues in the Helm chart, such as missing files, syntax errors, or invalid configurations.

Example:

bash

helm lint my-chart

This command will check the chart for any issues and output warnings or errors.


8. helm uninstall

The helm uninstall command is used to uninstall or delete a release from the Kubernetes cluster. This will remove all resources associated with the release.

Example:

bash

helm uninstall my-release

This command uninstalls the release my-release from the Kubernetes cluster.


List Helm Releases

To list all releases, including the ones that are deleted or failed, you can use the following command:

Example:

bash

helm list -a

This will display all the releases, including ones that are in a deleted or failed state.


Rolling Back to the Previous Version

If you want to roll back to the previous version (rather than specifying a version number), you can use the helm rollback command without the version number. Helm will automatically roll back to the last successful version.

Example:

bash

helm rollback my-release

This will roll back the my-release release to the previous version.


Before Running helm install, Run Dry-Run

It's a good practice to run a --dry-run before actually installing a chart to verify what will happen.

Example:

bash

helm install my-release my-chart --dry-run

This command will simulate the install and show you what resources would be created without applying them to the cluster.

The helm template command is used to render the Kubernetes manifests from a Helm chart locally, without actually deploying them to a Kubernetes cluster. This command is useful for inspecting what Kubernetes resources will be created when a chart is installed or upgraded, and it allows you to see the rendered YAML files directly in your terminal.

Purpose of helm template

  • Render Kubernetes Manifests Locally: It takes the templates defined in the Helm chart and renders them into actual Kubernetes YAML files.

  • Dry-Run without Deployment: It allows you to preview the resources that would be created by installing the chart without actually applying them to the Kubernetes cluster.

  • Debugging and Inspection: It’s useful for debugging or inspecting how the chart’s templates will be rendered with the provided configuration.

Command Syntax

bash

helm template <release_name> <chart_name> [flags]
  • <release_name>: The name you want to give to this Helm release (optional when using a chart from a local directory).

  • <chart_name>: The path to the chart you want to render (this can be a local path or a chart from a repository).

  • [flags]: Additional flags you can pass to customize the rendering process.

Example Usage

  1. Basic Example
    Render the Kubernetes manifests from a chart called my-chart with the release name my-release:

    bash

    helm template my-release my-chart

    This will render the YAML files that would be applied to your Kubernetes cluster if you installed the chart.

  2. Using a Chart from a Repository
    If you are using a chart from a Helm repository, you can specify the chart like this:

    bash

    helm template my-release stable/mysql

    This will render the MySQL chart from the Helm stable repository.

  3. Custom Values
    You can also provide custom values (override the default values.yaml file) using the -f or --values flag:

    bash
    helm template my-release my-chart -f custom-values.yaml

    This will render the templates with the values specified in custom-values.yaml.


  4. Using Helm Values in the Command Line
    Alternatively, you can override values directly in the command line with the --set flag:

    bash

    helm template my-release my-chart --set replicaCount=3

    This sets the replicaCount value to 3 in the rendered templates.

  5. Output to a File
    If you want to save the rendered YAML to a file instead of printing it to the terminal, you can use output redirection:

    bash
    helm template my-release my-chart > output.yaml

  6. Including/Excluding Specific Templates
    If you want to include or exclude specific templates during rendering, you can use the --include-crds flag for custom resources or --exclude for specific templates:

    bash
    helm template my-release my-chart --include-crds

  7. Debugging
    If you want to see debug output (including the raw values and the final rendered templates), you can add the --debug flag:

    bash

    helm template my-release my-chart --debug

Summary of Key Flags

  • -f, --values: Specify a custom values file to override the default values.

  • --set: Override specific values on the command line (useful for quick changes).

  • --output-dir: Specify a directory to output the rendered YAML files (instead of printing to stdout).

  • --debug: Show detailed debug output.

  • --include-crds: Include custom resource definitions (CRDs) in the output.

When to Use helm template

  • Previewing Resources: When you want to inspect the generated Kubernetes resources without applying them to the cluster.

  • Debugging: When troubleshooting a chart or inspecting how the templates are rendered with your custom values.

  • Generating YAML for Manual Deployment: If you want to manually apply the Kubernetes manifests to the cluster later using kubectl.

Example Scenario

Let's say you want to deploy a Helm chart, but you're unsure what resources it will create. Instead of installing it immediately, you run helm template to render the resources first:

bash

helm template my-release my-chart

This will display all the Kubernetes resources (like Deployments, Services, etc.) that will be created. If everything looks good, you can proceed with the helm install command.




Summary of Commands:

  • helm create <chart_name>: Creates a new Helm chart.

  • helm install <release_name> <chart_name>: Installs a Helm chart to your Kubernetes cluster.

  • helm upgrade <release_name> <chart_name>: Upgrades an existing release with a new chart or configuration.

  • helm rollback <release_name> <version>: Rolls back a release to a previous version.

  • helm --debug --dry-run: Simulates an install or upgrade, showing the output without applying it.

  • helm template <release_name> <chart_name>: Renders the templates locally without installing.

  • helm lint <chart_name>: Lints a chart to check for errors.

  • helm uninstall <release_name>: Uninstalls a release from the Kubernetes cluster.

  • helm list -a: Lists all releases, including failed or deleted ones.

  • helm rollback <release_name>: Rolls back to the previous release version.

Comments

Popular posts from this blog

Helm - WIth ArgoCD

Helm Chart Directory structure