Latest news about Bitcoin and all cryptocurrencies. Your daily crypto news habit.
Simplify your Kubernetes deployments
If you know what the title means, youâre likely looking to get right into the meat of this tutorial. Iâll keep the introduction brief.
What is Helm?
Helm is a tool for templating and applying Kubernetes resources into a Kubernetes cluster. It advertises itself as the ânpm of k8sâ, which is a description I have found thoroughly unhelpful. Instead, read this articleâââit explains it beautifully.
Why do you want your own Helm Repository?
From this point onwards, Iâm going to assume youâre familiar with what a âhelm chartâ is. If youâre not, read the linked article.
Youâve got some options when you want to deploy your applications into Helm. You either have a helm chart per application or a helm chart for a group of applications. For example, you either have your auth-service-helm-chart or you have your java-applications-helm-chart. What are the pros and cons of either?
A chart per application
Pros: You can implement logic specific to an app or service within your chart.
Cons: If youâve got Microservices (and chances are in k8s you do), youâre going to end up with a lot of disparate charts all over the place. Lots of repetition and difficult to manage at scale. Creating new applications also requires more effort, youâve got to wire up a chart correctly.
A chart for many applications
Pros: One chart is easier to manage. Your charts are all in one place (a chart repo).
Cons: Youâre going to need to be very careful that specific applications donât bleed into the shared chartâs logic. Everything needs to be generic.
I donât like repetition
As such, I opted for the shared chart approach. This created a new problemâââwhere the hell do we host a chart? Enter the helm s3Â plugin.
Install the Plugin
To configure a local helm CLI to use this plugin, the following commands need to be invoked:
helm plugin install https://github.com/hypnoglow/helm-s3.git
Wire up the S3Â Bucket
A Helm Repository needs to have an index.yaml at its root. You can use the helm CLI to initialise it, but itâs easier just to wire this up with a spot of terraform. Instead of running two commands or depending on the helm CLI being correctly configured, run one command and rely exclusively on terraform.
resource "aws_s3_bucket" "helm_central" {
bucket = "my-helm-central-bucket"
acl = "private"
}
resource "aws_s3_bucket_object" "object" {
bucket = "${aws_s3_bucket.helm_central.bucket}"
key = "charts/index.yaml"
source = "/path/to/my/files/index.yaml"
}
This terraform requires a file called index.yaml in a local directory. The file I used looks like this:
apiVersion: v1
entries: {}
Note, this will create a key âchartsâ where your bundled charts will go. Also, your S3 bucket will not be accessible from the internet and youâll need to regulate access through IAMÂ roles.
Tell Helm about your new Bucket
Now youâve got a bucket, you need to inform your local Helm CLI that the s3 bucket exists and it is a usable Helm repository. To do this, you make use of the s3Â plugin:
helm repo add my-charts s3://my-helm-central-bucket/charts
Note: Wherever youâre running the helm command from will need appropriate IAM access to this S3 bucket. Either to read, write or both.
Test it out!
Pull down an existing chart, package it up and push it to your new repository.
# This will download the tar.gz from your stable central repository.helm fetch stable/rabbitmq
# This will push that new tar.gz into your private repository.helm s3 push rabbitmq-<version>.tgz my-charts
If that is successful, congratulations! Youâve just wired up your very own chart repository.
Using S3 As a Helm Repository was originally published in Hacker Noon on Medium, where people are continuing the conversation by highlighting and responding to this story.
Disclaimer
The views and opinions expressed in this article are solely those of the authors and do not reflect the views of Bitcoin Insider. Every investment and trading move involves risk - this is especially true for cryptocurrencies given their volatility. We strongly advise our readers to conduct their own research when making a decision.