kapitan
kapitan copied to clipboard
Targets ordering or/and dependencies
Describe the bug/feature We have a target where we generate grafana dashboards (for example). We tried to use these templates as an input in other targets to create kubernetes configmaps. But didn't find a way to force this target to be the first one (added "00-" prefix to the name, etc). It would be nice control the target generation orders or to add target generation dependencies.
To Reproduce Steps to reproduce the behavior:
- Create a target with the name 00-target. create other targets
- run kapitan compile
- Output of the command shows that some other targets were generated before 00-target.
Expected behavior 00-target should be generated the first.
Maybe you can try to compile the target with grafana configurations first using $ kapitan compile -t <grafana-target-name>
and then use $ kapitan compile
to compile all the targets. Alternatively, you can try labeling your targets under parameters.kapitan.labels
e.g.
parameters:
kapitan:
compile: ...
labels:
type: grafana
parameters:
kapitan:
compile: ...
labels:
type: kubernetes
And then use $ kapitan compile -l type=grafana
followed by $ kapitan compile -l type=kubernetes
@eug-maly curious to know why you have a dependency on the order of compilation? You can always iterate through compiled target names and match/order externally. Alternatively, you should consider @AlphaRoy14 suggestion if you're ok with multi stage compilation.
@ramaro here is an example:
- generate grafana dashboards using jsonnet
- use dashboards from p.1 to generate kubernetes configmaps
- apply changes to kubernetes clusters
@eug-maly If you want, the grafana dashboards and k8s configmaps could each be there own class. The compile stage of a target has a few phases listed here in the docs: https://github.com/deepmind/kapitan/blob/master/docs/compile.md#phases-of-the-compile-command
What you could do is ensure that the grafana class is run first through ordering it before the k8s configmap class in your target definition file. As a part of the k8s configmap class you could reference the generated grafana dashboards as an input:
# k8s-configmap.yml
parameters:
kapitan:
vars:
target: ${target_name}
compile:
- input_type: copy
input_paths:
- compiled/${kapitan:vars:target}/grafana-dashboards/configmap.yml
output_path: .