Post

Kubernetes | Helm Commands with YAML File Examples

Helm Commands with YAML File Examples

Helm is a powerful package manager for Kubernetes that simplifies the deployment and management of containerized applications. In this guide, we’ll explore some common Helm commands and provide detailed examples of Helm Chart YAML files.

Helm Commands

Initialize a Helm Chart

To create a new Helm chart, you can use the following command:

1
helm create mychart

This command generates the necessary directory structure and files for your chart.

Installing a Chart

To install a Helm chart, you can use the following command:

1
helm install my-release ./mychart

Here, my-release is the name you give to the release, and ./mychart is the path to your Helm chart.

Upgrading a Chart

To upgrade a Helm release, you can use the following command:

1
helm upgrade my-release ./mychart

This command is used to apply changes to a deployed release.

Uninstalling a Chart

To uninstall a Helm release, you can use the following command:

1
helm uninstall my-release

This command removes the release and associated resources.

Helm Chart YAML Examples

Chart.yaml

The Chart.yaml file provides metadata about your Helm chart. Here’s an example:

1
2
3
4
5
apiVersion: v2
name: mychart
description: A Helm chart for my application
version: 0.1.0
appVersion: 1.0.0

values.yaml

The values.yaml file contains configuration values for your Helm chart. Here’s an example:

1
2
3
4
5
6
7
8
9
replicaCount: 1
image:
  repository: nginx
  tag: stable
  pullPolicy: IfNotPresent
service:
  name: mychart-service
  type: ClusterIP
  port: 80

Deployment.yaml

The Deployment.yaml file is part of your Helm chart’s templates and defines a Kubernetes Deployment. Here’s an example:

1
2
3
4
5
6
7
8
9
10
11
12
13
apiVersion: apps/v1
kind: Deployment
metadata:
  name: 
spec:
  replicas: 
  template:
    spec:
      containers:
        - name: 
          image: ":"
          ports:
            - containerPort: 80

Service.yaml

The Service.yaml file defines a Kubernetes Service for your application. Here’s an example:

1
2
3
4
5
6
7
8
9
10
apiVersion: v1
kind: Service
metadata:
  name: 
spec:
  selector:
    app: 
  ports:
    - port: 
      targetPort: 80

What Next?

These are just a few examples of Helm commands and YAML files used in Helm charts. Helm makes it easier to package, deploy, and manage Kubernetes applications, allowing you to define and version your application configurations in a structured way.

This post is licensed under CC BY 4.0 by the author.