Commit 91e7f6bf authored by Jonathan Chauncey's avatar Jonathan Chauncey

docs(docs/charts_hooks.md): Add information about hook weights

parent 05d0fcb7
...@@ -58,16 +58,18 @@ hooks, the lifecycle is altered like this: ...@@ -58,16 +58,18 @@ hooks, the lifecycle is altered like this:
1. User runs `helm install foo` 1. User runs `helm install foo`
2. Chart is loaded into Tiller 2. Chart is loaded into Tiller
3. After some verification, Tiller renders the `foo` templates 3. After some verification, Tiller renders the `foo` templates
4. Tiller executes the `pre-install` hook (loading hook resources into 4. Tiller prepares to execute the `pre-install` hooks (loading hook resources into
Kubernetes) Kubernetes)
5. Tiller waits until the hook is "Ready" 5. Tiller sorts hooks by weight (assigning a weight of 0 by default) and by name for those hooks with the same weight in ascending order.
6. Tiller loads the resulting resources into Kubernetes. Note that if the `--wait` 6. Tiller then loads the hook with the lowest weight first (negative to positive)
7. Tiller waits until the hook is "Ready"
8. Tiller loads the resulting resources into Kubernetes. Note that if the `--wait`
flag is set, Tiller will wait until all resources are in a ready state flag is set, Tiller will wait until all resources are in a ready state
and will not run the `post-install` hook until they are ready. and will not run the `post-install` hook until they are ready.
7. Tiller executes the `post-install` hook (loading hook resources) 9. Tiller executes the `post-install` hook (loading hook resources)
8. Tiller waits until the hook is "Ready" 10. Tiller waits until the hook is "Ready"
9. Tiller returns the release name (and other data) to the client 11. Tiller returns the release name (and other data) to the client
10. The client exits 12. The client exits
What does it mean to wait until a hook is ready? This depends on the What does it mean to wait until a hook is ready? This depends on the
resource declared in the hook. If the resources is a `Job` kind, Tiller resource declared in the hook. If the resources is a `Job` kind, Tiller
...@@ -114,6 +116,7 @@ metadata: ...@@ -114,6 +116,7 @@ metadata:
# This is what defines this resource as a hook. Without this line, the # This is what defines this resource as a hook. Without this line, the
# job is considered part of the release. # job is considered part of the release.
"helm.sh/hook": post-install "helm.sh/hook": post-install
"helm.sh/hookWeight": "-5"
spec: spec:
template: template:
metadata: metadata:
...@@ -154,3 +157,12 @@ When subcharts declare hooks, those are also evaluated. There is no way ...@@ -154,3 +157,12 @@ When subcharts declare hooks, those are also evaluated. There is no way
for a top-level chart to disable the hooks declared by subcharts. And for a top-level chart to disable the hooks declared by subcharts. And
again, there is no guaranteed ordering. again, there is no guaranteed ordering.
It is also possible to define a weight for a hook which will help build a deterministic executing order. Weights are defined using the following annotation:
```
annotations:
"helm.sh/hookWeight": "5"
```
Hook weights can be positive or negative numbers but must be represented as strings. When Tiller starts the execution cycle of hooks of a particular Kind it will sort those hooks in ascending order.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment