I have been curating some scripts that help me manage version updates in my GitOps repositories… It’s about time they get shared with the world.
What’s Going On?
I manage the applications in my Kubernetes clusters using Argo CD and a number of Git repositories. Most of the ops-
repositories act as “desired state” repositories.
As part of this management, I have a number of external tools running in my clusters that are installed using their Helm charts. Since I want to keep my installs up to date, I needed a way to update the Helm chart versions as new releases came out.
However.. some external tools do not have their own Helm charts. For that, I have been using a Helm library chart from bjw-s. In that case, I have had to manually find new releases and update my values.yaml
file.
While I have had the Helm chart version updates automated for some time, I just recently got around to updating the values.yaml
file from external sources. Now is a good time to share!
The Scripts
I put the scripts in the ops-automation repository in the Spydersoft organization. I’ll outline the basics of each script, but if you are interested in the details, check out the scripts themselves.
It is worth nothing that these scripts require the git
and helm
command line tools to be installed, in addition to the Powershell Yaml module.
Also, since I manage more than one repository, all of these scripts are designed to be given a basePath
and then a list of directory names for the folders that are the Git repositories I want to update.
Update-HelmRepositoryList
This script iterates through the given folders to find the chart.yaml
files in it. For every dependency in the found chart files, it adds the repository to the local helm if the URL does not already exist.
Since I have been running this on my local machine, I only have to do this once. But, on a build agent, this script should be run every time to make sure the repository list contains all the necessary repositories for an update.
Update-HelmCharts
This script iterates through the given folders to find the chart.yaml
files in it. For every dependency, the script determines if there is an updated version of the dependency available.
If there is an update available, the Chart.yaml
file is updated, and helm dependency update
is run to update the Chart.lock
file. Additionally, commit comments are created to note the version changes.
For each chart.yaml
file, a call to Update-FromAutoUpdate
will be made to make additional updates if necessary.
Update-FromAutoUpdate
This script looks for a file called auto-update.json
in the path given. The file has the following format:
{
"repository": "redis-stack/redis-stack",
"stripVFromVersion": false,
"tagPath": "redis.image.tag"
}
The script looks for the latest release from the repository
in Github, using tag_name
from Github as the version. If the latest release is newer than the current tagPath
in values.yaml
, the script then updates the tagPath
in the values.yaml
file to the new version. The script returns an object indicating whether or not an update was made, as well as a commit comment indicating the version jump.
Right now, the auto-update only works for images that come from Github releases. I have one item (Proget) that needs to search a docker API directly, but that will be a future enhancement.
Future Tasks
Now that these are automated tasks, I will most likely create an Azure Pipeline that runs weekly to get these changes made and committed to Git.
I have Argo configured to not auto-sync these applications, so even though the changes are made in Git, I still have to manually apply the updates. And I am ok with that. I like to stagger application updates, and, in some cases, make sure I have the appropriate backups before running an update. But this gets me to a place where I can log in to Argo and sync apps as I desire.