Abonnez-vous au flux

The Helm command for Red Hat OpenShift and Kubernetes makes it possible for you to install an application on your cluster with just one command. Its developers call it a package manager, because it gives you access to "charts" that serve as recipes so your control plane can install a containerized application as easily as a Linux server installs applications using DNF or APT. 

It's a powerful tool that any cloud developer or admin can benefit from. Of course, the first step is to have an OpenShift or Kubernetes cluster. Managed OpenShift, like Red Hat OpenShift Service on AWS (ROSA), is a great option for using Helm. Once you've installed Helm on your control plane, here are the 10 Helm commands you need to know to get started:

1. Search for a package

After installing Helm, you can use it right away to find an installer (a "chart" in Helm terminology) for an application you need to run on your cloud. By default, Helm looks to the Artifact Hub for charts shared by the Helm community. For example, to search the Hub for the Nginx web server:

$ helm search hub nginx

That's confirmation that a chart exists for Nginx. Before you install it using the chart, you must add its repository to your system to ensure you can keep it up to date.

2. Add a repository

Each chart you find in the Artifact Hub lists the repository where the chart is kept. Alternatively, you can add a repository provided by your cloud service provider, your own organization, or one that you've built yourself. 

To add a repository as a search location in Helm, provide a custom name for your own reference along with the URI of the repository. For example, this command adds the Azure Marketplace repository and gives it the short name azmarket:

$ helm repo add azmarket https://marketplace.azurecr.io/helm/v1/repo

3. Install an application

Installing an application with Helm requires just one command. Provide a short name for the specific instance of the application you want to install (this is called a release by Helm and is for your own reference), along with the repo and application name. This command installs Wordpress from the Truecharts repository:

$ helm install mypress truecharts/wordpress

When you give your application a custom short name, you are creating what Helm refers to as a release. Because Helm refers to releases instead of application names, you can install multiple instances of the same application, and they'll operate separately from one another. You can even install different versions:

$ helm install mypress truecharts/wordpress --version 3.0.11
$ helm install yourpress truecharts/wordpress --version 2.9

4. Install an application to a specific namespace

Containers operate within namespaces. Sometimes it's useful to use a chart to install an application to a specific namespace in your cluster. By default applications are installed in the default namespace, but you can use the --namespace option to specify an existing namespace:

$ helm install mypress truecharts/wordpress --namespace webapps

5. List repositories

After you've added a few repositories, it helps to be able to get a list of them for quick reference:

$ helm repo list
NAME        URL
azmarket    https://marketplace.azurecr.io/helm/v1/repo
truecharts  https://charts.truecharts.org/
myrepo      https://example.com/charts

6. Upgrade an application

To upgrade an installed application, use the release name you've given the application along with the chart you want to use to perform the upgrade:

$ helm upgrade yourpress truechart/wordpress --version 3.0.11

7. Rollback an application

Sometimes an upgrade isn't everything you'd hoped it would be. Should a problem arise and you need to rollback an application to a previous version, use the rollback command, along with the release and revision (the version of the application) you want to return to:

$ helm rollback yourpress 2.5

8. Uninstall an application

To remove an application, just provide your release name:

$ helm uninstall mypress

9. Customize a chart

Most charts strive to be as universal as possible, but sometimes you may need to add information about your environment. A chart is just a YAML file, so first use the helm command to view the values contained in it:

$ helm show values truecharts/wordpress | less

Depending on the chart, there may be a lot of output. It's formatted as YAML, so you can either write a new YAML file to override the values you need to change, or you can convert the YAML to dot-notation. For example, the values listed for Truechart's Wordpress include this mapping:

wordpress:
  user: user
  pass: bitnami
  email: user@example.com
  first_name: TrueCharts
  last_name: TrueCharts
  blog_name: Truecharts Blog
  enable_reverse_proxy_headers: true

To set a new user, you'd set wordpress.user, and for a different password you'd set wordpress.pass, and so on. You're using dots instead of indents to denote inheritance.

Set your new values in a file, and then use that file to override the default values during installation:

$ echo "{wordpress.user: tux}" > mypress.yaml
$ helm install mypress -f mypress.yaml truecharts/wordpress

Alternatively, use the --set option to pass new key value pairs as part of your install command:

$ helm install mypress --set "wordpress.user=tux" truecharts/wordpress

10. Dry-run

With the --dry-run option, you can try almost any Helm command without actually committing to it. It's a great way to experiment without risking unexpected failure.

The output can be verbose, so I usually pipe the results to less or a similar pager before executing.

$ helm install mypress -f mypress.yaml truecharts/wordpress --dry-run | less

Using the --dry-run option is one of the best ways to learn Helm. Be bold; try new commands and options. As long as you do it as a dry run first, Helm can help you catch errors before they happen.

Use Helm charts

The more you use Helm, the better you'll come to understand Helm charts, YAML, and even containers and Kubernetes. Seeing the variables involved in a successful deployment is half the battle, so go install Helm and start installing applications on your cloud. You'll be writing your own Helm charts before you know it. When you reach that point, be sure to contribute to Artifact Hub so others can benefit from your hard work!


À propos de l'auteur

Seth Kenlon is a Linux geek, open source enthusiast, free culture advocate, and tabletop gamer. Between gigs in the film industry and the tech industry (not necessarily exclusive of one another), he likes to design games and hack on code (also not necessarily exclusive of one another).

Read full bio
UI_Icon-Red_Hat-Close-A-Black-RGB

Parcourir par canal

automation icon

Automatisation

Les dernières nouveautés en matière d'automatisation informatique pour les technologies, les équipes et les environnements

AI icon

Intelligence artificielle

Actualité sur les plateformes qui permettent aux clients d'exécuter des charges de travail d'IA sur tout type d'environnement

open hybrid cloud icon

Cloud hybride ouvert

Découvrez comment créer un avenir flexible grâce au cloud hybride

security icon

Sécurité

Les dernières actualités sur la façon dont nous réduisons les risques dans tous les environnements et technologies

edge icon

Edge computing

Actualité sur les plateformes qui simplifient les opérations en périphérie

Infrastructure icon

Infrastructure

Les dernières nouveautés sur la plateforme Linux d'entreprise leader au monde

application development icon

Applications

À l’intérieur de nos solutions aux défis d’application les plus difficiles

Original series icon

Programmes originaux

Histoires passionnantes de créateurs et de leaders de technologies d'entreprise