sylva-units: facilitate the definition of additional health checks for Helm-based components
Context:
- by default, for Helm-based components, the only resources that Flux waits on is what Helm is waiting on: deployments, pods, PVCs and Services (https://helm.sh/docs/intro/using_helm/#helpful-options-for-installupgraderollback)
- some rare components (today only Rancher) also create their own resources behind the scene, which of course Flux can't be aware of and can't wait
As a result, we may have a unit X with a dependency on Helm-based unit Y, which starts too early because Y became apparently ready although some resources defined in Y (e.g. a CRD, a Secret, a Deployment not directly defined by Y Helm chart) aren't ready yet.
Since each unit in sylva-unit is a FluxCD Kustomization (a Helm-based component is a Kustomization defining a HelmRelease), we can make use of the Kustomization.spec.healthChecks field to add pointers to additional things not naturally taken into account by Helm.
By default when a Kustomization defines a HelmRelease, we use wait: true and the state of the HelmRelease defines the state of the Kustomization.
We can add a healthChecks, like this, for instance on the existence of a CRD:
units:
foo:
helmrelease_spec:
..
kustomization_spec:
- kind: CustomResourceDefinition
name: Foo
...but if we do this, the Kustomization will not check anymore the foo HelmRelease.
Instead of requiring developers who want to add healthChecks to think about including the HelmRelease explicitly among healthChecks, we can extend the sylva-units templating code to automatically include it if healthChecks are defined.