피드 구독

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!


저자 소개

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

채널별 검색

automation icon

오토메이션

기술, 팀, 인프라를 위한 IT 자동화 최신 동향

AI icon

인공지능

고객이 어디서나 AI 워크로드를 실행할 수 있도록 지원하는 플랫폼 업데이트

open hybrid cloud icon

오픈 하이브리드 클라우드

하이브리드 클라우드로 더욱 유연한 미래를 구축하는 방법을 알아보세요

security icon

보안

환경과 기술 전반에 걸쳐 리스크를 감소하는 방법에 대한 최신 정보

edge icon

엣지 컴퓨팅

엣지에서의 운영을 단순화하는 플랫폼 업데이트

Infrastructure icon

인프라

세계적으로 인정받은 기업용 Linux 플랫폼에 대한 최신 정보

application development icon

애플리케이션

복잡한 애플리케이션에 대한 솔루션 더 보기

Original series icon

오리지널 쇼

엔터프라이즈 기술 분야의 제작자와 리더가 전하는 흥미로운 스토리