Set up a Helm v3 chart repository in Amazon S3 - AWS Prescriptive Guidance

Set up a Helm v3 chart repository in Amazon S3

Created by Abhishek Sharma (AWS)

Environment: PoC or pilot

Technologies: DevOps; Containers & microservices; Modernization

Workload: All other workloads

AWS services: Amazon S3

Summary

This pattern helps you to manage Helm v3 charts efficiently by integrating the Helm v3 repository into Amazon Simple Storage Service (Amazon S3) on the Amazon Web Services (AWS) Cloud. To use this pattern, you must be familiar with Kubernetes and with Helm, which is a Kubernetes package manager. Using Helm repositories to store charts and control chart versions can improve mean time to restore (MTTR) during outages. 

This pattern uses AWS CodeCommit for Helm repository creation, and it uses an S3 bucket as a Helm chart repository, so that the charts can be centrally managed and accessed by developers across the organization.

Prerequisites and limitations

Prerequisites 

  • An active AWS account

  • Python version 2.7.12 or later

  • pip

  • A virtual private cloud (VPC) with subnets and an Amazon Elastic Compute Cloud (Amazon EC2) instance 

  • Git installed on the EC2 instance

  • AWS Identity and Access Management (IAM) access to create the S3 bucket

  • IAM (programmatic or role) access to Amazon S3 from the client machine

  • AWS CodeCommit repository

  • AWS Command Line Interface (AWS CLI)

Product versions

  • Helm v3

  • Python version 2.7.12 or later

Architecture

Target technology stack 

  • Amazon S3

  • AWS CodeCommit

  • Helm

  • Kubectl

  • Python and pip

  • Git

  • helm-s3 plugin

Target architecture 

Helm repository in CodeCommit, EC2 instance with Helm, Git, and helm-s3, Helm charts in Amazon S3.

Automation and scale

  • You can incorporate Helm into your existing continuous integration/continuous delivery (CI/CD) automation tool to automate the packaging and version control of Helm charts (out of scope for this pattern).

  • GitVersion or Jenkins build numbers can be used to automate version control of the charts.

Tools

  • Helm – Helm is a package manager for Kubernetes that helps you install and manage applications on your Kubernetes cluster.

  • Amazon S3 – Amazon Simple Storage Service (Amazon S3) is storage for the internet. You can use Amazon S3 to store and retrieve any amount of data at any time, from anywhere on the web.

  • helm-s3 plugin – The helm-s3 plugin supports interaction with Amazon S3. It can be used with either Helm v2 or Helm v3.

Best practices

< Author remove these notes: Provide a list of guidelines and recommendations that can help users implement this pattern more effectively.>

Epics

TaskDescriptionSkills required

Install the Helm v3 client.

To download and install the Helm client on your local system, run the following command: sudo curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash

Cloud Administrator, DevOps Engineer

Validate the Helm installation.

To validate the Helm client, run the following command: helm version --short

Cloud Administrator, DevOps Engineer
TaskDescriptionSkills required

Create an S3 bucket for Helm charts.

Create a unique S3 bucket. In the bucket, create a folder called stable/myapp. The example in this pattern uses s3://my-helm-charts/stable/myapp as the target chart repository.

Cloud Administrator, DevOps Engineer

Install the helm-s3 plugin for Amazon S3.

To install the helm-s3 plugin on your client machine, run the following command: helm plugin install https://github.com/hypnoglow/helm-s3.git

Cloud Administrator, DevOps Engineer

Initialize the Amazon S3 Helm repository.

To initialize the target folder as a Helm repository, use the following command: helm s3 init s3://my-helm-charts/stable/myapp 

The command creates an index.yaml file in the target to track all the chart information that is stored at that location.

Cloud Administrator, DevOps Engineer

Verify the newly created Helm repository.

To verify that the index.yaml file was created, run the following command: aws s3 ls s3://my-helm-charts/stable/myapp/

Cloud Administrator, DevOps Engineer

Add the Amazon S3 repository to Helm on the client machine.

To add the target repository alias to the Helm client machine, use the following command: helm repo add stable-myapp s3://my-helm-charts/stable/myapp/

Cloud Administrator, DevOps Engineer
TaskDescriptionSkills required

Clone your Helm charts.

If no local Helm charts are present on in your CodeCommit repository, clone them from your GitHub repo by running the following command: git clone <url_of_your_helm_source_code>.git

Cloud Administrator, DevOps Engineer

Package the local Helm chart.

To package the chart that you created or cloned, use the following command: helm package ./my-app  

As an example, this pattern uses the my-app chart. The command packages all the contents of the my-app chart folder into an archive file, which is named using the version number that is mentioned in the Chart.yaml file.

Cloud Administrator, DevOps Engineer

Store the local package in the Amazon S3 Helm repository.

To upload the local package to the Helm repository in Amazon S3, run the following command: helm s3 push ./my-app-0.1.0.tgz stable-myapp

In the command, my-app is your chart folder name, 0.1.0 is the chart version mentioned in Chart.yaml, and stable-myapp is the target repository alias.

Cloud Administrator, DevOps Engineer

Search for the Helm chart.

To confirm that the chart appears both locally and in the Amazon S3 Helm repository, run the following command: helm search repo stable-myapp

Cloud Administrator, DevOps Engineer
TaskDescriptionSkills required

Modify and package the chart.

In values.yaml, set the replicaCount value to 1, and then package the chart, this time changing the version in Chart.yaml to 0.1.1. Version control is ideally achieved through automation by using tools like GitVersion or Jenkins build numbers in a CI/CD pipeline. Automating the version number is out of scope for this pattern. To package the chart, run the following command: helm package ./my-app/

Cloud Administrator, DevOps Engineer

Push the new version to the Helm repository in Amazon S3.

To push the new package, version of 0.1.1, to the my-helm-charts Helm repository in Amazon S3, run the following command: helm s3 push ./my-app-0.1.1.tgz stable-myapp

Cloud Administrator, DevOps Engineer

Verify the updated Helm chart.

To confirm that the updated chart appears both locally and in the Amazon S3 Helm repository, run the following commands.

helm repo update

helm search repo stable-myapp

Cloud Administrator, DevOps Engineer
TaskDescriptionSkills required

Search for all versions of the my-app chart.

To view all the available versions of a chart, run the following command with the --versions flag: helm search repo my-app --versions 

Without the flag, Helm by default displays the latest uploaded version of a chart.

DevOps Engineer

Install a chart from the Amazon S3 Helm repository.

Automated installation is out of scope for this pattern, but you can manually install. The search results from the previous task show the multiple versions of the my-app chart. To install the new version (0.1.1) from the Amazon S3 Helm repository, use the following command: helm upgrade --install my-app-release stable-myapp/my-app --version 0.1.1 --namespace dev

DevOps Engineer
TaskDescriptionSkills required

Review the details for a specific revision.

Automated rollback is out of scope for this pattern, but you can roll back to an earlier version manually. Before you switch or roll back to a working version, and for an additional layer of validation before installing a revision, view which values were passed to each of the revisions by using the following command: helm get values --revision=2 my-app-release

DevOps Engineer

Roll back to a previous version.

Automated rollback is out of scope for this pattern. To manually roll back to a previous revision, use the following command: helm rollback my-app-release 1 

This example is rolling back to revision number 1.

DevOps Engineer

Related resources