helm / helm/helm

Add support for ordering of resources within a chart for Custom Resources

Open
#8,439 77 comments 84 reactions 1 assignee Claimed by @ashokponkumar View on GitHub
feature in progress
Dominant language
Go
Stars
30.2k
Forks
7.8k
Avg merge
18h 51m
Merged PRs (30d)
41

Description

### Background

Custom Resources need a way to be ordered when deployed in certain cases. For example, When creating a [SCC](https://docs.openshift.com/enterprise/3.0/admin_guide/manage_scc.html) and service account as part of a helm chart, since it is not ordered to be created before deployment and other resources, the scc does not have an effect on the pods.

### Solution 1

~~The simplest fix might be to just add kind "SecurityContextConstraints" just after "ServiceAccount" in the kind_sorter.go file.
https://github.com/helm/helm/blob/release-3.0/pkg/releaseutil/kind_sorter.go~~

### Solution 2 - Generic for all Custom Resources

Similar to how we have an ordering requirement for known resources in the InstallOrder, users want the capability to order custom resources too. For example a custom resource like SCC need to be applied before creation of any pods.

To enable this capability we can follow the same approach we use for hooks. Essentially add a annotation "helm.sh/order-weight" which can take an integer value (+ve or -ve). This will behave the same way as "helm.sh/hook-weight", but for resources not covered by hooks.

Here is how it will work:

The first resources to be installed will be all resources that have negative weights, and then those with zero or no weights, and then those with positive weights. All in ascending order.
For resources which have same weight, Install order is preserved for known resources.

PR [here](https://github.com/helm/helm/pull/8448) showing the solution.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.