Open paulczar opened 4 years ago
@paulczar Thanks! I'm not familiar with the lookup
function but is it basically kubectl get -n NAMESPACE KIND NAME
?
Unfortunately, this doesn't seem to comply with how Helmfile works. If we add lookup
, all the lookups would be executed BEFORE all the releases are parsed. Is that really an expected behavior?
Probably a better way would be to enhance hooks so that you can easily write things like this.
How about adding if
to make a hook conditional, and optionally add run
as an alternative to the pair of command
and args
, so that run
and if
seems visually consistent?
hooks:
- events: ["prepare", "cleanup"]
sohwlogs: true
if: ["kubectl", "get", "ns", "{{.Release.namespace}}"]
run: ["kubectl", "create", "ns", "{{.Release.namespace}}"]
I also need this functionality
I am trying to dynamically generate values based on configmap data.
Example:
domain: "example.{{ (lookup "v1" "ConfigMap" .Environment.Values.namespace "cluster-config").data.cluster_domain }}"
Currently when trying to template this we receive:
➜ helmfile -e staging template in ./helmfile.yaml: error during helmfile.yaml.part.0 parsing: template: stringTemplate:21: function "lookup" not defined
This should be relatively easy to implement no?
really hope to add this function
This is a big challenge with the helmfile usage in general. The most updated Bitnami helm charts for example are relying on it, as they have a common library used by all helm charts with lookup function.
Helm 3 now has a lookup template function that lets you check for resources. This would allow us to run hooks based on pre-existing resources... for example helm3 does not currently create namespaces ... we could put a condition around a release that looks something like: