Managing Kubernetes Application Manifests

Helm Kubernetes
Helm Kubernetes


This post explores tools that simplify Kubernetes application management, focusing on Helm, Kompose, and kapp. Helm streamlines deployment by templating YAML files, making it easier to manage complex applications.

Kompose converts Docker Compose files to Kubernetes manifests, facilitating a smoother transition to Kubernetes for Docker users. kapp allows for managing groups of YAML files as a single application, streamlining deployment processes. Together, these tools enhance efficiency in managing Kubernetes applications.

Helm Kubernetes

Installing Helm, the Kubernetes Package Manager

Use Case

Manually crafting Kubernetes manifests for each deployment is tedious and prone to errors. You’re looking for a more efficient way to deploy applications on Kubernetes.

Solution

Helm is a command-line tool that simplifies the deployment of applications on Kubernetes by allowing you to find, share, and use software built for Kubernetes.

To install Helm, you have a couple of options:

For macOS (Intel) users, using the wget command:

  1. Download the Helm package for your version, say v3.12.3:wget https://get.helm.sh/helm-v3.12.3-darwin-amd64.tar.gz
  2. Unpack the downloaded file:shellCopy codetar -xvf helm-v3.12.3-darwin-amd64.tar.gz
  3. Move the Helm binary to your executable path:sudo mv darwin-amd64/helm /usr/local/bin

Alternatively, for a straightforward installation: Use Helm’s official script to get the latest version installed:

wget -O get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
chmod +x get_helm.sh
./get_helm.sh

Why Helm? Helm treats Kubernetes applications as charts—a collection of all your needed application resources and configurations bundled into one package. These charts are customizable for your deployment needs and are stored in Helm chart repositories for easy access.

For Linux or macOS users who prefer using Homebrew:

brew install helm

In essence, Helm is your go-to for managing Kubernetes applications with ease, significantly reducing the complexity and maintenance overhead of manual configurations.

Expanding Helm’s Reach with Chart Repositories

Use case

You’ve got Helm set up , ready to streamline your Kubernetes deployments. The next step? Diving into the vast sea of available Helm charts to enhance your cluster with pre-configured applications.

Solution

Chart repositories are your treasure troves here, hosting a variety of Helm charts along with the metadata required for Helm to identify and manage these charts. Before deploying any applications with Helm, you need to connect to the repositories where these charts are stored.

Artifact Hub stands out as a central hub for exploring over 10,000 Helm charts provided by numerous publishers. It’s a visual platform that simplifies finding and adding new chart repositories to your Helm setup.

In Practice: To weave Artifact Hub’s extensive chart collection into your command-line operations, Helm offers seamless integration, allowing you to search directly from your terminal.

For instance, if you’re on the lookout for a Redis chart, a simple command bridges you to Artifact Hub’s offerings:

$ helm search hub --list-repo-url redis

This command unveils a list of available Redis charts, detailing versions, descriptions, and repository URLs.

Suppose Bitnami catches your eye, known for its high-quality, ready-to-deploy charts. Adding Bitnami’s chart repository to your Helm configuration is as straightforward as:

$ helm repo add bitnami https://charts.bitnami.com/bitnami

Now What? With the repository added, you’re equipped to deploy charts from Bitnami or any other added repository, significantly enriching your Kubernetes ecosystem with minimal fuss.

Deploying Applications with Helm

Use Case

You’ve successfully added a chart repository to Helm. Now, you’re set to explore the charts within this repository and deploy an application.

Solution

Imagine you’re aiming to deploy Redis using a chart from the Bitnami repository.

Step 1: Update Chart Repository Index First, ensure your local Helm chart repository index is current. This index tracks the charts in your connected repositories.

$ helm repo update

You’ll see a confirmation message once the update is complete.

Step 2: Find the Redis Chart Next, search for Redis in the Bitnami repository:

$ helm search repo bitnami/redis

You’ll get a list of available Redis charts, including versions and descriptions.

Step 3: Deploy Redis To deploy Redis, use the helm install command:

$ helm install redis bitnami/redis

This command creates a Helm release named “redis” using the chart’s default configuration. Helm releases allow you to manage a set of Kubernetes resources as a unified entity.

Step 4: Verify the Deployment After deployment, check that the Redis pods are up and running:

$ kubectl get all -l app.kubernetes.io/name=redis

You should see the Redis pods, services, and stateful sets listed, indicating that the deployment was successful.

Important Notes:

  • The output from helm install might include critical information, such as passwords or service details, often stored in Kubernetes secrets.
  • To manage your Helm deployments, helm list will show you what’s currently deployed, and helm status <release_name> provides detailed information about a specific release.

By following these steps, you can easily deploy and manage applications on Kubernetes using Helm, starting with the popular Redis data store as an example.

Exploring Helm Chart Parameters

Use Case

You’re gearing up to deploy a Helm chart but wish to tailor it to your needs. How do you uncover the chart’s configurable options and their preset values?

Solution

Charts come with adjustable parameters that let you fine-tune your deployment. These settings, along with their default values, are detailed in a chart’s Values file. To peek into these defaults, Helm arms you with a command:

$ helm show values bitnami/redis
...
...
## @param architecture Redis® architecture. Allowed values: `standalone` or
`replication`
##
architecture: replication
...
...

This command unveils the adjustable parameters for the Redis chart by Bitnami, such as the deployment architecture, which can be either standalone or replication, with a default set to replication.

Deep Dive: Beyond the Values file, the chart’s Readme often houses a wealth of documentation on these parameters, providing a deeper understanding of how to customize your deployment effectively. For a comprehensive look at what you can tweak, including explanations and default settings, consult the chart’s Readme:

$ helm show readme bitnami/redis
...
...
### Redis® common configuration parameters

| Name | Description | Value |
| -------------------------- | --------------------------------| ------------- |
| `architecture` | Redis® architecture... | `replication` |
| `auth.enabled` | Enable password authentication | `true` |
...
...

This document mirrors the Readme you’d find on Artifact Hub, ensuring you have access to detailed and specific instructions for deploying and managing the chart.

Takeaway: Before deploying a Helm chart, leveraging the helm show values and helm show readme commands empowers you to customize your deployment to match your exact requirements, ensuring a smooth and tailored application deployment experience.

Removing Helm-Deployed Applications

Use Case

You’ve deployed an application using Helm but now need to remove it from your Kubernetes cluster.

Solution

Helm simplifies not just the deployment but also the removal of applications. When you deploy an application with Helm, it’s managed as a “release.” To remove an application, you effectively delete this release, which, in turn, removes all associated Kubernetes resources.

For instance, if you’ve deployed Redis with Helm and decided it’s time to uninstall it, you’d proceed as follows:

$ helm uninstall redis
release "redis" uninstalled

Executing this command tells Helm to remove the “redis” release. Helm then deletes all Kubernetes resources tied to this release, effectively cleaning up your cluster.

What Happens Next: Post-uninstallation, Helm ensures that all resources associated with the release are deleted, reclaiming any cluster resources that were in use. This action makes Helm not just a powerful tool for deploying applications but also for managing your cluster’s resource lifecycle efficiently.

Packaging Your Application with Helm

Use Case

Challenge: You’ve developed an application that requires multiple Kubernetes manifests for deployment and you’re looking to streamline this process by packaging it as a Helm chart.

Solution: The helm create and helm package commands are your friends here. They will help you generate a Helm chart template and package your application into a chart, respectively.

Step 1: Create Your Chart Start by creating the basic structure of your Helm chart. Open your terminal and run:

$ helm create teckbootcamps

This command creates a directory named teckbootcamps with a standard chart structure. Here’s what you’ll see:

$ tree teckbootcamps/ 

teckbootcamps/
├── Chart.yaml
├── charts
├── templates
│   ├── NOTES.txt
│   ├── _helpers.tpl
│   ├── deployment.yaml
│   ├── hpa.yaml
│   ├── ingress.yaml
│   ├── service.yaml
│   ├── serviceaccount.yaml
│   └── tests
│       └── test-connection.yaml
└── values.yaml

3 directories, 10 files
  • Chart.yaml: Contains metadata about your chart.
  • values.yaml: Stores configuration values that can be overridden at install time.
  • templates/: Where your Kubernetes YAML files (templates) go.
  • charts/: For any charts your chart depends on.

Step 2: Adapt the Chart to Your Application Now, customize the scaffold to suit your application. If you already have Kubernetes manifests, replace the default templates with your own. You can also modify values.yaml to include any configurable options your templates should support.

Step 3: Test Your Chart Before packaging, you might want to test the chart locally:

$ helm install teckbootcamps-app ./teckbootcamps

This step helps ensure everything is set up correctly.

Step 4: Package Your Chart Once you’re happy with the setup, package your chart into a distributable format:

$ helm package teckbootcamps/

This command generates a .tar.gz file, which is your redistributable chart.

Step 5: Share Your Chart If you’re looking to share your chart with others, move the packaged chart to your chart repository and update the repository’s index with:

$ helm repo index .

Ensure your Helm is aware of your repository (as discussed in Recipe 6.2). Now, anyone who has added your repository can find your chart with helm search repo teckootcamps

Takeaway: By creating your own Helm chart, you not only make deploying your application easier but also enable others to deploy it in their own environments with minimal hassle. Helm charts are a powerful tool for managing Kubernetes applications, providing an efficient way to package, share, and deploy applications across various environments.

Author

  • Mohamed BEN HASSINE

    Mohamed BEN HASSINE is a Hands-On Cloud Solution Architect based out of France. he has been working on Java, Web , API and Cloud technologies for over 12 years and still going strong for learning new things. Actually , he plays the role of Cloud / Application Architect in Paris ,while he is designing cloud native solutions and APIs ( REST , gRPC). using cutting edge technologies ( GCP / Kubernetes / APIGEE / Java / Python )

    View all posts
0 Shares:
You May Also Like