Skip to content

Helm_Lab_06 | Plugins

deepak gupta edited this page Dec 11, 2020 · 13 revisions

Helm Lab 06

In this section of the lab, we'll discuss about helm plugins. And briefly would be taking consideration of S3 and Diff plugin.

To get going, let's take a brief look at a Helm pulgin.

Introduction about Helm Plugin

Helm plugins are add-on tools that integrate seamlessly with Helm. They provide a way to extend the core feature set of Helm.

Helm plugins have the following features:

  • They can be added and removed from a Helm installation without impacting the core Helm tool.
  • They can be written in any programming language.
  • They integrate with Helm, and will show up in helm help and other places.

Installing a Plugin

$ helm plugin install <path|url>

OR

If you have a plugin tar distribution, simply untar the plugin into the $HELM_PLUGINS directory. You can also install tarball plugins directly from url by issuing helm plugin install https://domain/path/to/plugin.tar.gz

Time to start

helm-s3

The Helm plugin that provides s3 protocol support. This allows you to have private Helm chart repositories hosted on Amazon S3

Prerequisites

  • AWS CLI For the latest version of the AWS CLI, use the following command block:
$ curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
$ sudo installer -pkg AWSCLIV2.pkg -target /
$ aws --version

AWS CLI Installation Reference Link

After this here we are providing you all with a bucket named helmbucket69 So that you don't have to create bucket for yourself.

We need to configure AWS CLi to communicate with AWS account to perform our lab and play with helm-s3 plugin

$ aws configure
AWS Access Key ID: XXXXXXXXXXXXXX
AWS Secret Access Key: XXXXXXXXXXXXXX
Default region name: ap-south-1
Default output format: json

Note: Ask your instructor to provide AWS access key

It's Time

Install

The installation itself is simple as:

$ helm plugin install https://github.com/hypnoglow/helm-s3.git <--version 0.10.0> # If required version flag can be used

$ helm plugin list
NAME    VERSION DESCRIPTION
s3      0.10.0  The plugin allows to use s3 protocol to upload, fetch charts and to work with repositori...

To use the plugin, you do not need any special dependencies. Or the installer can download versioned release with prebuilt binary from github releases.

Helm version mode

The plugin is able to detect if you are using Helm v2 or v3 automatically. If, for some reason, the plugin does not detect Helm version properly, you can set HELM_S3_MODE environment variable to value 2 or 3 to force the mode.

Example:

# We have Helm version 3:
$ helm version --short
v3.0.0+ge29ce2a

# For some reason, the plugin detects Helm version badly:
$ helm s3 version --mode
helm-s3 plugin version: 0.10.0
Helm version mode: v3

# Force the plugin to operate in v3 mode:
$ HELM_S3_MODE=3 helm s3 version --mode
helm-s3 plugin version: 0.10.0
Helm version mode: v3

Initialize

To create a new repository, use init:

$ helm s3 init s3://helmbucket69/charts

This command generates an empty index.yaml and uploads it to the S3 bucket under /charts .

To work with this repo by it's name, first you need to add it using native helm command:

$ helm repo add <team_repo_name> s3://helmbucket69/charts

List repo added:-

$ helm repo list

NAME            URL
ethanhunt       s3://helmbucket69/charts/

Check any chart is present in the repo intialized:-

$ helm search repo <team_repo_name>
No results found

Package

Crete package of your helm Chart

$ helm package gowebapp/
Successfully packaged chart and saved it to: /home/gowebapp-0.1.0.tgz

Push

Now you can push your own chart to this repo:

$ helm s3 push /home/gowebapp-0.1.0.tgz <team_repo_name>

On push, both remote and local repo indexes are automatically updated (that means you don't need to run helm repo update).

Your pushed chart is available:

$ helm search repo <team_repo_name>
                                   
NAME                    CHART VERSION   APP VERSION     DESCRIPTION
ethanhunt/gowebapp      0.1.0           1.16.0          A Helm chart for GoWebApp                      

However, in some cases you want to replace existing chart version. To do so, add --force flag to a push command:

helm s3 push --force /tmp/gowebapp-0.1.0.tgz <team_repo_name>

Pull

To pull the chart in local system to run:

$ helm pull <team_repo_name>/gowebapp


$ ls -lrt | grep goweb
-rw-r--r--  1 staff staff      1289 Dec 11 08:31 gowebapp-0.1.0.tgz

Install

To install the shared chart

$ helm install goweb-app <team_repo_name>/gowebapp
NAME: goweb-app
LAST DEPLOYED: Fri Dec 11 03:26:08 2020
NAMESPACE: helmforce
STATUS: deployed
REVISION: 1
NOTES:
1. Get the application URL by running these commands:
  export POD_NAME=$(kubectl get pods --namespace helmforce -l "app.kubernetes.io/name=gowebapp,app.kubernetes.io/instance=goweb-app" -o jsonpath="{.items[0].metadata.name}")
  echo "Visit http://127.0.0.1:8080 to use your application"
  kubectl --namespace helmforce port-forward $POD_NAME 8080:80

$ helm ls

NAME            NAMESPACE       REVISION        UPDATED                                 STATUS          CHART           APP VERSION
goweb-app       helmforce       1               2020-12-11 03:26:08.978639622 +0000 UTC deployed        gowebapp-0.1.0  1.16.0

Delete

To delete specific chart version from the repository:

$ helm s3 delete gowebapp --version 0.1.0 <team_repo_name>

As always, both remote and local repo indexes updated automatically.

The chart is deleted from the repo:

$ helm search repo <team_repo_name>
No results found

Uninstall

$ helm plugin remove s3

Bonus

helm-diff

This is a Helm plugin giving your a preview of what a helm upgrade would change. It basically generates a diff between the latest deployed version of a release and a helm upgrade --debug --dry-run. This can also be used to compare two revisions/versions of your helm release.

Install

Pick a release tarball from the releases page.

Unpack the tarball in your helm plugins directory ($(helm home)/plugins).

To check helm plugins directory:

$ helm env

HELM_BIN="helm"
HELM_DEBUG="false"
HELM_PLUGINS="/root/.local/share/helm/plugins"
HELM_REGISTRY_CONFIG="/root/.config/helm/registry.json"
HELM_REPOSITORY_CACHE="/root/.cache/helm/repository"
HELM_REPOSITORY_CONFIG="/root/.config/helm/repositories.yaml"
HELM_NAMESPACE="helmforce"
HELM_KUBECONTEXT=""

Install

Here, getting tar package of plugin and unpacking it in plugins directory, which we can get using above command helm env

$ curl -L https://github.com/databus23/helm-diff/releases/download/v3.1.3/helm-diff-linux.tgz | tar -C /root/.local/share/helm/plugins -xzv

To check plugin setup:

$ helm plugin list

NAME    VERSION DESCRIPTION
diff    3.1.3   Preview helm upgrade changes as a diff
s3      0.10.0  The plugin allows to use s3 protocol to upload, fetch charts and to work with repositori...

Usage

revision:

$ helm diff revision -h

This command compares the manifests details of a named release.

It can be used to compare the manifests of 
 
 - lastest REVISION with specified REVISION
	$ helm diff revision [flags] RELEASE REVISION1
   Example: 
	$ helm diff revision my-release 2

 - REVISION1 with REVISION2
	$ helm diff revision [flags] RELEASE REVISION1 REVISION2
   Example: 
	$ helm diff revision my-release 2 3

Usage:
  diff revision [flags] RELEASE REVISION1 [REVISION2]

Flags:
  -h, --help                   help for revision
      --suppress stringArray   allows suppression of the values listed in the diff output
  -q, --suppress-secrets       suppress secrets in the output

Global Flags:
      --no-color   remove colors from the output

Used:-

$ helm diff revision goweb-app 2 1

rollback:

$ helm diff rollback -h

This command compares the laset manifests details of a named release 
with specific revision values to rollback.

It forecasts/visualizes changes, that a helm rollback could perform.

Usage:
  diff rollback [flags] [RELEASE] [REVISION]

Examples:
  helm diff rollback my-release 2

Flags:
  -h, --help                   help for rollback
      --suppress stringArray   allows suppression of the values listed in the diff output
  -q, --suppress-secrets       suppress secrets in the output

Global Flags:
      --no-color   remove colors from the output

Used:-

helm diff rollback goweb-app 1

Shows the difference between previous release values which will get updated if you rollback to previous version.

upgrade:

This to be used need helm requires at least helm version 3.1.0-rc.1

$ helm diff upgrade -h
Show a diff explaining what a helm upgrade would change.

This fetches the currently deployed version of a release
and compares it to a chart plus values.
This can be used visualize what changes a helm upgrade will
perform.

Usage:
  diff upgrade [flags] [RELEASE] [CHART]

Examples:
  helm diff upgrade my-release stable/postgresql --values values.yaml

Flags:
  -h, --help                   help for upgrade
      --detailed-exitcode      return a non-zero exit code when there are changes
      --post-renderer string   the path to an executable to be used for post rendering. If it exists in $PATH, the binary will be used, otherwise it will try to look for the executable at the given path
      --reset-values           reset the values to the ones built into the chart and merge in any new values
      --reuse-values           reuse the last release's values and merge in any new values
      --set stringArray        set values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)
      --suppress stringArray   allows suppression of the values listed in the diff output
  -q, --suppress-secrets       suppress secrets in the output
  -f, --values valueFiles      specify values in a YAML file (can specify multiple) (default [])
      --version string         specify the exact chart version to use. If this is not specified, the latest version is used

Global Flags:
      --no-color   remove colors from the output