Now that #6 is cancelled I'm bouncing around other ideas for solving the CI issue.
Problem
In an automated CI system we want the versions (i.e. image tags) of artifacts to change after new images have been created for software. Somehow this change needs to propagate to kontemplate
.
Potential solutions
There are two approaches that can be taken:
1. Resource set default values
Implement #25 to allow resource sets to contain certain default values within them (as a values.json
which is easy to edit programmatically). This could be implemented with relatively few code changes and would enable CI systems to update the default versions in resource sets after new images have been deployed.
This works well for "always master
"-style deployments, and versions could still be pinned by overriding them in the context. If the context doesn't specify any version then whatever the default is in the resource set will be used.
Example:
# some-api/deployment.yaml
kind: Deployment
# [...]
spec:
template:
spec:
containers:
- image: myrepo/some-api:{{ someApiVersion }}
# [...]
// some-api/values.json
{
"someApiVersion": "1.2.3"
}
# somecontext.yaml
context: somecontext
include:
- name: some-api
This would deploy some-api
with whatever version is specified and it could be overridden in the context (if necessary). This way automatic deploys could be "disabled" for certain artifacts if a CI system applies all environments constantly.
2. Make versions a first-class citizen
In this model, versions could become a first-class field of the ResourceSet
type that is optionally loaded in from a different file. This file would be in JSON format and easy to edit programmatically.
Example:
# somecontext.yaml
context: somecontext
versions: somecontext-versions.json
include:
- name: some-api
// somecontext-versions.json
{
"some-api": "1.2.3"
}
This would set the version
field in that parsed resource set to "1.2.3"
.
CI workflows
Ideally a CI system could run kontemplate apply -f context.yaml
without any further options, i.e. without filtering for certain resource sets, after every change to the repository in which kontemplate configuration is kept.
For the solutions mentioned above the workflows look slightly, but not much, different:
-
After some-api
is built, a subsequent job creates a commit in the kontemplate-config repo that changes the values.json
file of the some-api
resource set.
-
After some-api
is built, a subsequent job creates a commit in the kontemplate-config repo that updates the somecontext-versions.json
file.
The updated kontemplate-config repo triggers a CI run of kontemplate apply
.
Pros & Cons
Intuitively I think that version 1 leads to a nicer CI flow as there aren't multiple files that need to be updated and things are sort of self-contained. Somehow when written down version 2 seems simpler though.