Track version of k8s that should be supported by the operators
The Sylva operator are tested against a precise k8s version. This version should be tracked and updated when Sylva is upgrading supported version See !125 (comment 2235667523)
Today, here's an example of how to manage and aligne the Kubernetes version for each operator, and ensure that the corresponding binaries, such as kubebuilder, kube-apiserver, or etcd, are properly aligned with the supported version. This is example already done into the Makefile and manage by renovate:
The update is done thanks to github-tags, but in our case we want to update K8s thanks to a common values from k8s_version defined https://gitlab.com/sylva-projects/sylva-core/-/blob/main/charts/sylva-units/values.yaml#L7367
1-Test with well known datasource and depName functions
# renovate: datasource=github-tags depName=kubernetes-sigs/controller-tools VersionTemplate=envtest-v
ENVTEST_K8S_VERSION = 1.29.0
The renovate configuration could be added for each operator on makefile (renovate.json)
{
"description": "Track K8S version in suite_test.go file",
"customType": "regex",
"fileMatch": ["internal/controller/suite_test.go"],
"matchStrings": [
".*\/\/ renovate: datasource=(?<datasource>.*?) depName=(?<depName>.*?)( VersionTemplate=(?<VersionTemplate>.*))[\\w\\W]+(?<currentValue>\\d+.\\d+.\\d+)"
]
}
Basic idea, it's to generate K8S_Version tag in our Sylva repo, and then to call in basic test done here with a simple https://gitlab.com/e-wyckens/workload-cluster-operator/-/commit/71fd5b2689ae656b6d37aceb0210e205dc14d533
Regex based on datasource and depName
https://regex101.com/r/yFN1s4/1
in Makefile
# renovate: datasource=gitlab-tags depName=sylva-projects/sylva-core versioning=semver registryUrl=https://gitlab.com
ENVTEST_K8S_VERSION = 1.0.0
In renovate.json
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"packageRules": [
{
"description": "Track _VERSION variables from Makefile",
"matchManagers": ["regex"],
"matchUpdateTypes": ["major", "minor", "patch"]
}
],
"customManagers": [
{
"description": "Track _VERSION variables from Makefile",
"customType": "regex",
"fileMatch": ["Makefile"],
"matchStrings": [
"\\s+# renovate: datasource=(?<datasource>.*?) depName=(?<depName>.*?)( versioning=(?<versioning>.*?))?( registryUrl=(?<registryUrl>.*?))?\\s.*?_VERSION = (?<currentValue>.*)\\s"
]
}
]
}
Conclusions :
The solution is working, but it is not efficient because it is not aligned with the sylva-units charts (values.yaml).
Additionally, a helpful idea proposed by @loic.nicolle in comment 2367574539 of sylva-projects/sylva-elements/container-images/litmus-tests is to align all versions in the Makefile operator from a single sylva-units values chart.
2-Test with customerManager and customDatasources
In Makefile
# renovate: versioning=semver
MYENVTEST_K8S_VERSION = 1.0
In renovate.json
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:recommended"
],
"prConcurrentLimit": 0,
"prHourlyLimit": 0,
"packageRules": [
{
"description": "Track _VERSION variables from Makefile",
"matchManagers": ["regex"],
"matchUpdateTypes": ["major", "minor", "patch"]
}
],
"customManagers": [
{
"customType": "regex",
"fileMatch": ["Makefile"],
"depNameTemplate": "ENVTEST_K8S_VERSION",
"datasourceTemplate": "custom.myglobalvalues",
"matchStrings": [
".*?_VERSION = (?<currentValue>.*)"
],
"versioningTemplate": "loose"
}
],
"customDatasources": {
"myglobalvalues": {
"defaultRegistryUrlTemplate": "https://gitlab.com/sylva-projects/sylva-core/-/raw/main/charts/sylva-units/values.yaml",
"format": "yaml",
"transformTemplates": [
"{\"releases\":[{\"version\": $string(k8s_version_short)}],\"homepage\":\"https://gitlab.com/sylva-projects/sylva-core/-/raw/main/charts/sylva-units/values.yaml\",\"changelogUrl\":\"https://gitlab.com/sylva-projects/sylva-core/-/raw/main/.gitlab/README.md\"}"
]
}
}
}
Result PR:
Conclusions:
The solution is quite better than the first one, and manage and align all operator version with a single one values in yaml from sylva-units charts
Reference
- sylva-projects/sylva-elements/workload-cluster-operator#27 (closed) -> sylva-projects/sylva-elements/workload-cluster-operator!249 (merged)
- sylva-projects/sylva-elements/sylva-units-operator#28 (closed)
- sylva-projects/sylva-elements/heat-operator#25 (closed) -> see sylva-projects/sylva-elements/heat-operator!223 (merged)
