Skip to content

A Helm chart repository in AWS S3 with auto-generated user documentation. Because user documentation matters.

License

Notifications You must be signed in to change notification settings

dumrauf/s3-helm-chart-repo-with-docs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A Helm Chart Repository in AWS S3 - With Auto-Generated User Documentation!

This repository contains a Terraform module that creates a Helm chart repository using an AWS S3 bucket. The S3 bucket is configured as a static website and contains an auto-generated index.html with instructions on using and managing the Helm chart repository.

A live example can be found at http://dumrauf-helm-chart-repo.s3-website-us-east-1.amazonaws.com.

For further information, see the corresponding article Build Your Own Helm Chart Repository in S3 — With Auto-Generated User Documentation! on How Hard Can It Be?!.

The master branch in this repository is compliant with Terraform v0.12; a legacy version that is compatible with Terraform v0.11 is available in branch terraform@0.11.

You Have

Before you can use the Terraform module in this repository out of the box, you need

Moreover, you probably also have a directory containing the packaged Helm charts along with an index.yaml file.

You Want

After running the Terraform module in this repository you get an S3 bucket that contains auto-generated documentation and can be used to host a Helm chart repository.

Setup

The input variables for the module are defined in settings/example.tfvars to be

region = "<your-region>"

shared_credentials_file = "/path/to/.aws/credentials"

profile = "<your-profile>"

bucket_name = "<your-bucket-name>"

repository_name = "<your-repository-name>"

log_bucket_id = "<your-log-bucket-id>"

Here, you need to replace the example values with your settings.

Moreover, note that the S3 bucket will be named ${var.repository_name}-${var.bucket_name}.

Execution

Initialise Terraform by running

terraform init

As a best practice, create a new workspace by running

terraform workspace new example

The Helm chart repository can be planned by running

terraform plan -var-file=settings/example.tfvars

and created by running

terraform apply -var-file=settings/example.tfvars

Terraform Outputs

The module has CLI outputs as well as template files it generates. Here, the template files contain the auto-generated documentation.

CLI Outputs

The module has two outputs, namely helm_chart_repository_bucket_domain_name and helm_chart_repository_website_endpoint which are the corresponding Terraform attributes of the newly created Helm chart repository bucket. Point your browser to the output of helm_chart_repository_website_endpoint in order to visit your new Helm chart repository as well as to review the auto-generated documentation.

Generated Template Files

The module also generates a Markdown as well as an HTML file. Both files are named ${var.repository_name}-${var.bucket_name}.index.{md,html}. Here, the HTML file is constructed from the rendered Markdown file and intended to be used as an index.html file for the new Helm chart repository. It contains tailored instructions on how to use the Helm chart repository, making it easier for your users to add, use, and remove the Helm chart repository via the helm CLI. Moreover, the index.html file also contains instructions on how to manage the Helm chart repository.

For example inputs

bucket_name = "helm-charts-repo"

repository_name = "dumrauf"

files dumrauf-helm-charts-repo.index.md and dumrauf-helm-charts-repo.index.html are generated.

Here, the contents of file dumrauf-helm-charts-repo.index.html which is automatically uploaded to http://dumrauf-helm-chart-repo.s3-website-us-east-1.amazonaws.com as index.html are

Helm Chart Repository dumrauf

Welcome to the Helm chart repository dumrauf. See below for instructions on how to add or remove this chart repository using helm. If you're the owner of this Helm chart repository, then please refer to the "Managing the Repository" section below.

Using the Repository

This section describes the use of the repository dumrauf. It describes how to add, search, and eventually remove the repository via helm.

Adding the Repository

This chart repository can be added to helm via

helm repo add dumrauf 'https://dumrauf-helm-charts-repo.s3.amazonaws.com'
helm repo update

Here, the latter command is required in order to get the (latest) information about charts from the repository dumrauf.

Searching the Repository

All charts in the repository can be listed via

helm search dumrauf

Removing the Repository

This chart repository can be removed from helm via

helm repo remove dumrauf

Managing the Repository

This section outlines steps for managing Helm chart repository dumrauf. It describes how to upload Helm charts and eventually delete them again.

Uploading Helm Charts

The Helm charts can be uploaded to S3 bucket dumrauf-helm-charts-repo via

aws s3 sync <packaged-charts-directory> s3://dumrauf-helm-charts-repo

Assuming the packaged Helm charts are located in ../packaged-helm-charts/, then they can be uploaded via

aws s3 sync ../packaged-helm-charts/ s3://dumrauf-helm-charts-repo

Deleting All Helm Charts

The Helm charts can be deleted from S3 bucket dumrauf-helm-charts-repo via

aws s3 rm s3://dumrauf-helm-charts-repo --recursive

Note that due to versioning, additional steps may be necessary.

About

The Helm chart repository dumrauf and this documentation was created using https://github.com/dumrauf/s3-helm-chart-repo-with-docs. Create your own Helm chart repository with auto-generated documentation and start serving Helm charts in a matter of seconds.

Deletion

The Helm chart repository can be deleted by running

terraform destroy -var-file=settings/example.tfvars

Credits

This respository uses the following projects for handling markdown:

  1. Showdown from https://github.com/showdownjs/showdown to render the generated markdown entirely in the visitor's browser
  2. The minified GitHub markdown CSS from https://www.npmjs.com/package/github-markdown-css to achieve a GitHub like look and feel of the resulting index.html page

FAQs

Why's the Bucket Not Emptied Before It's Destroyed?

The force_destroy option is deliberately set to false in variables.tf in order to avoid accidental deletion of the contents when running terraform destroy. It's essentially a safety net. Feel free to change and use it at your own risk.

Helm Chart Repositories

For a detailed overview of Helm chart repositories, see the excellent official Helm documentation on https://docs.helm.sh/developing_charts/#the-chart-repository-guide.

About

A Helm chart repository in AWS S3 with auto-generated user documentation. Because user documentation matters.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published