Automatically Updating Helm Chart Referenced in Argo CD Using Renovate - Part 2
Tags: argo, renovate, devops, kubernetes
Published: 2023-05-05 19:23:42

Yesterday, I posted an article titled "Automatically Updating Helm Chart Referenced in Argo CD Using Renovate."

{% embed https://dev.to/corrupt952/automatically-updating-helm-charts-referenced-by-argo-cd-with-renovate-5g79 %}

That method used regexManagers to retrieve version information from GitHub releases specified in the configuration. However, this time I will introduce an even easier and simpler method.

## Recap of Previous Method

The previous method involved adding regexManagers and comments to the lines to be updated.

```javascript
  // renovate.json5
  "regexManagers": [
    {
      "datasourceTemplate": "github-releases",
      "fileMatch": [
        "argocd-config/base/.*\\.yaml"
      ],
      "matchStrings": [
        // e.g.) targetRevision: 5.31.0 # renovate: depName=argoproj/argo-helm extractVersion=^argo-cd-(?<version>.+)$
        " +targetRevision: +(?<currentValue>[^'\" ]+) +# renovate: depName=(?<depName>[^ \\n]+) +(extractVersion=(?<extractVersion>[^\\n]+))?",
      ],
    },
  ]
```

```yaml
# Add comments to the lines to be updated
targetRevision: 5.31.0 # renovate: depName=argoproj/argo-helm extractVersion=^argo-cd-(?<version>.+)$
```

This time, we will make the automatic update process even easier.

## Making It Easier

### Read the Documentation

To make the automatic update process even easier, we first read the documentation for Managers.

{% embed https://docs.renovatebot.com/modules/manager/ %}

The reason for reading the documentation for Managers is that if there are already suitable Managers listed in the documentation, then you can simply write the configuration for that Manager and it will automatically become an update target.

If it is not listed, then write regexManagers, create an issue, or submit a pull request.

Looking through the documentation, it seems that there is a Manager called `argocd`.

![screenshot](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pg87w8yqe9hejshlu76m.png)

{% embed https://docs.renovatebot.com/modules/manager/argocd/ %}

Although it is not clear whether it can be used as is, the Additional Information section suggests that it may be suitable for Argo CD applications.

> The argocd manager has no fileMatch default patterns, so it won't match any files until you configure it with a pattern. This is because there is no commonly accepted file/directory naming convention for argocd YAML files and we don't want to check every single *.yaml file in repositories just in case any of them have ArgoCD definitions.

### Define the Configuration

If there is a definition for `regexManagers`, delete it. Simply define the path to the files to be updated in `fileMatch`.

```javascript
  "argocd": {
    "fileMatch": [
      "argocd-config/base/.*\\.yaml",
    ],
  },
```

FYI: https://github.com/corrupt952/home-apps/blob/main/.github/renovate.json5#L19-L23

Updating the configuration in this way will make it an update target. It is much simpler than the previous method.

### PRs Created

{% embed https://github.com/corrupt952/home-apps/pull/39 %}
{% embed https://github.com/corrupt952/home-apps/pull/40 %}
{% embed https://github.com/corrupt952/home-apps/pull/41 %}
{% embed https://github.com/corrupt952/home-apps/pull/42 %}
{% embed https://github.com/corrupt952/home-apps/pull/43 %}

### Conclusion

That was a simple way to automatically update the Argo CD application using Renovate.

Please try it out for yourself, even if you just install it for now.