<p>I have an umbrella chart with multiple sub-charts, I simply want to make sure that subchart1 runs before subchart2, etc. How can we define the order of subchart execution?</p>

<p>Seems like hook-weights only apply relative to the chart that declares them.</p>

Z Y .
<p>Here is a part of the Helm <a href="https://helm.sh/docs/topics/charts/#operational-aspects-of-using-dependencies" rel="noreferrer">documentation</a> related to execution order of charts:</p>
<blockquote>
<p>The above sections explain how to specify chart dependencies, but how
does this affect chart installation using helm install and helm
upgrade?</p>
<p>Suppose that a chart named &quot;A&quot; creates the following Kubernetes
objects</p>
<p>namespace &quot;A-Namespace&quot; <br>
statefulset &quot;A-StatefulSet&quot; <br>
service &quot;A-Service&quot;</p>
</blockquote>
<blockquote>
<p>Furthermore, A is dependent on chart B that creates
objects</p>
<p>namespace &quot;B-Namespace&quot; <br>
replicaset &quot;B-ReplicaSet&quot; <br>
service &quot;B-Service&quot;<br></p>
</blockquote>
<blockquote>
<p>After installation/upgrade of chart A a single Helm release is
created/modified. The release will create/update all of the above
Kubernetes objects in the following order:</p>
<p>A-Namespace <br>
B-Namespace <br>
A-StatefulSet <br>
B-ReplicaSet <br>
A-Service <br>
B-Service<br></p>
</blockquote>
<blockquote>
<p>This is because when Helm installs/upgrades charts, the Kubernetes
objects from the charts and all its dependencies are aggregrated into a single set; then sorted by type followed by name;
and then created/updated in that order. <br>
Hence a single release is created with all the objects for the chart and its dependencies.</p>
<p>The install order of Kubernetes types is given by the enumeration
InstallOrder in kind_sorter.go (<a href="https://github.com/helm/helm/blob/9ad53aac42165a5fadc6c87be0dea6b115f93090/pkg/tiller/kind_sorter.go#L29" rel="noreferrer">Helm v2 source file</a>).</p>
</blockquote>
<p>Part of kind_sorter.go (<a href="https://github.com/helm/helm/blob/9b42702a4bced339ff424a78ad68dd6be6e1a80a/pkg/releaseutil/kind_sorter.go#L27" rel="noreferrer">Helm v3 source</a>) is related to install charts:</p>
<pre><code>var InstallOrder KindSortOrder = []string{
    &quot;Namespace&quot;,
    &quot;NetworkPolicy&quot;,
    &quot;ResourceQuota&quot;,
    &quot;LimitRange&quot;,
    &quot;PodSecurityPolicy&quot;,
    &quot;PodDisruptionBudget&quot;,
    &quot;Secret&quot;,
    &quot;ConfigMap&quot;,
    &quot;StorageClass&quot;,
    &quot;PersistentVolume&quot;,
    &quot;PersistentVolumeClaim&quot;,
    &quot;ServiceAccount&quot;,
    &quot;CustomResourceDefinition&quot;,
    &quot;ClusterRole&quot;,
    &quot;ClusterRoleList&quot;,
    &quot;ClusterRoleBinding&quot;,
    &quot;ClusterRoleBindingList&quot;,
    &quot;Role&quot;,
    &quot;RoleList&quot;,
    &quot;RoleBinding&quot;,
    &quot;RoleBindingList&quot;,
    &quot;Service&quot;,
    &quot;DaemonSet&quot;,
    &quot;Pod&quot;,
    &quot;ReplicationController&quot;,
    &quot;ReplicaSet&quot;,
    &quot;Deployment&quot;,
    &quot;HorizontalPodAutoscaler&quot;,
    &quot;StatefulSet&quot;,
    &quot;Job&quot;,
    &quot;CronJob&quot;,
    &quot;Ingress&quot;,
    &quot;APIService&quot;,
}
</code></pre>
<p>There is a workaround, that can change the default behaviour, shared by <strong>elementalvoid</strong> in this <a href="https://github.com/kubernetes/helm/issues/1228" rel="noreferrer">issue</a>:</p>
<blockquote>
<p>I've been setting my services, secrets, and configmaps as pre-install
hooks to achieve this behavior.</p>
<p>Example:</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: foo
  annotations:
    &quot;helm.sh/hook&quot;: &quot;pre-install&quot;
</code></pre>
</blockquote>
<p>--</p>
<blockquote>
<p>It is possible to define a weight for a hook which will help build a
deterministic executing order. Weights are defined using the following
annotation:</p>
<pre><code>  annotations:
    &quot;helm.sh/hook-weight&quot;: &quot;5&quot;
</code></pre>
<p>Hook weights can be positive or negative numbers but must be
represented as strings. When Tiller starts the execution cycle of
hooks of a <strong>particular Kind</strong> it will sort those hooks in ascending
order.</p>
</blockquote>
<p>More detailed information about hooks can be found here (<a href="https://github.com/helm/helm/blob/9ad53aac42165a5fadc6c87be0dea6b115f93090/docs/charts_hooks.md#hooks" rel="noreferrer">v2 doc</a>, <a href="https://helm.sh/docs/topics/charts_hooks/" rel="noreferrer">v3 doc</a>) and in the source file (<a href="https://github.com/helm/helm/blob/9ad53aac42165a5fadc6c87be0dea6b115f93090/pkg/tiller/hooks.go" rel="noreferrer">helm v2 source</a>, <a href="https://github.com/helm/helm/blob/02ad2b118731d012ea248e3ede800aa28fa71301/pkg/releaseutil/manifest_sorter.go#L54" rel="noreferrer">helm v3 source</a>)</p>
