# Helm Guide<no value>

:toc: right

= Helm Chart

Helm is a very popular package manager for deploying applications on Kubernetes. But those packages can also get outdated pretty quickly. We'll see in this guide how we can automatically update our Helm charts based on third dependencies.

== Requirement

To use this guide, we need the following elements:

1. The Updatecli binary
2. A Helm chart to update
3. A GitHub Personal Access Token

**Updatecli Binary**

Updatecli is a command-line available for Linux/macOS/Windows.

Check out installation instructions on link:https://www.updatecli.io/docs/prologue/installation/[www.updatecli.io/docs/prologue/installation] to know how to install it on your machine.

**Helm chart to update**

Within this example, we'll use a Helm chart from the Jenkins infrastructure project located on link:https://github.com/jenkins-infra/helm-charts[github.com/jenkins-infra/helm-charts].
We want to ensure that the Helm chart is always using the latest chart application which in this case is the jenkins-wiki-exporter.

**GitHub Personal Access Token**

As we are going to interact with resources on Github such as github repository and GitHub packages, we need a personal access token. More information on the GitHub documentation link:https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token[creating-a-personal-access-token]


== Update Pipeline

=== Manifest
Updatecli expects one or multiple pipeline manifests to know what to do.
Then we can use the command `updatecli diff --config manifest.yaml`
The `diff` allows us to run updatecli in dry-mode so we identify what updatecli would change. Then we need to execute `updatecli apply --config manifest.yaml` to run our updatecli pipeline

As you'll see in our updatecli manifest, we define:

1. One "source" resource of a kind "githubRelease" which describes, where to retrieve the latest version of our application, jenkins-wiki-exporter, published on GitHub Release.
2. Two "condition" "resources which need to succeed before updating our Helm chart. In the first condition, we want to ensure that our Helm chart uses the right container name "jenkinsciinfra/jenkins-wiki-exporter". The second condition of a kind "dockerimage", ensures that a Docker image "jenkinsciinfra/jenkins-wiki-exporter" exists on DockerHub where the tag is the same than the source output aka the latest jenkins-wiki-exporter version.
3. A "target" resource of kind "helmChart", has a chart name "charts/jenkins-wiki-exporter" with a file "values.yaml" where the key "image.tag" is set to the latest jenkins-wiki-exporter version. If it's not the case then bump the path version of the chart.
4. A "scms" resource of kind "github", that describes which GitHub repository store the Helm chart "code".
5. A "pullrequest" resource of kind "github", that describes pull-request parameters such as label assigned to the pull request created by Updatecli, and the auto-merge flag.

[source,yaml]
----
# updatecli.yaml
{{<include "assets/code_example/docs/guides/helm-chart/updatecli.yaml">}}
----

Now we can run our updatecli pipeline using the following commands:

```
export GITHUB_TOKEN=xxx
export GITHUB_ACTOR=yyy
updatecli diff --config updatecli.yaml
```

WARNING: Using environment variables to store credentials is convenient for running updatecli from a CI environment. Another option is to use link:https://github.com/mozilla/sops[sops] but in anyway, you should let your credentials unprotected.


**Spoiler Alert**: Command output
[source,yaml]
----
# data.yaml
{{<include "assets/code_example/docs/guides/helm-chart/updatecli.output">}}
----

== Go Further

I hope you liked this guide. Updatecli is used in more scenarios and many more to come. Feel free to reach out if you have questions. Meanwhile, here are additional resources that you can use to go further.

=== Resource

To extend this pipeline, you can find more customization on Updatecli documentation website.

In this pipeline we used the following resources:

* link:https://www.updatecli.io/docs/plugins/yaml/[YAML]
* link:https://www.updatecli.io/docs/plugins/github_release/[GitHub Release]
* link:https://www.updatecli.io/docs/plugins/helm_chart/[Helm Chart]
* link:https://www.updatecli.io/docs/plugins/github/[GitHub Repository]
* link:https://www.updatecli.io/docs/plugins/github_pullrequest/[GitHub Pullrequest]
* link:https://www.updatecli.io/docs/plugins/docker_image/[Docker Image]

=== Additional Workflows

Updatecli shines and saves us time in many other situations such as:

* Automatically updating any YAML
* Automatically updating Dockerfile
* Automatically updating raw File

=== Contributing

As a community-oriented project, all contributions are greatly appreciated!

Here is a non-exhaustive list of possible contributions:

* ⭐️ this link:https://github.com/updatecli/updatecli[updatecli/updatecli] repository.
* Propose a new feature request.
* Highlight an existing feature request with :thumbsup:.
* Contribute to any repository in the link:https://github.com/updatecli/[updatecli] organization
* Share the love

More information is available at link:https://github.com/updatecli/updatecli/blob/main/CONTRIBUTING.adoc[CONTRIBUTING]
