Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ordering #137

Closed
Stono opened this issue May 10, 2018 · 19 comments
Closed

Ordering #137

Stono opened this issue May 10, 2018 · 19 comments

Comments

@Stono
Copy link
Contributor

Stono commented May 10, 2018

Firstly,
Thanks for this project, it's awesome - you've saved me a big headache.

However, quick Q. I need to control the order in which the charts are deployed.

Is there any way (hacky or not) that I can do that, without using labels and having two helmfile runs?

@sstarcher
Copy link
Contributor

not currently

@mumoshu
Copy link
Collaborator

mumoshu commented May 11, 2018

@Stono Hi! Just curious but why do you want the ordering?

@Stono
Copy link
Contributor Author

Stono commented May 11, 2018

Hello @mumoshu!
Great question, let me try and explain...

We have a helmfile which can take an empty kubernetes cluster and turn it into what we call the "delivery platform", however the components need to be deployed in a certain order, for a variety of reasons:

  • We need to deploy a chart which contains CustomResourceDefinitions before we deploy a chart which creates instances of those CustomResources
  • We use a service mesh, which uses a MutatingWebhookHandler in order to inject the sidecar into Pods as they're deployed. This needs to be configured before any Deployments, ReplicaSets or Pods are deployed.

As a result, we've ended up with a bit of a hacky script that looks like this:

echo "Creating MutatingWebhookHandler certificates..."
cd manual
./install-sidecar-injection.sh
cd ..

echo "Deploying istio (first phase)..."
helmfile --selector component=istio,order=1 sync --args="--wait --timeout=300"

echo "Adding the MutatingWebhookHandler..."
kubectl apply -f manual/istio-sidecar-injector-with-ca-bundle.yaml

echo "Deploying istio (second phase)..."
helmfile --selector component=istio,order!=1 sync --args="--wait --timeout=300"

echo "Deploying everything else..."
helmfile --selector component!=istio sync --args="--wait --timeout=300"

screen shot 2018-05-11 at 09 22 26

@mumoshu
Copy link
Collaborator

mumoshu commented May 25, 2018

@Stono Hi. Thank you so much for the detailed explanation!
Makes sense.

Btw, would this suggested feature #151 (comment) help your use-case, too?

@Stono
Copy link
Contributor Author

Stono commented May 25, 2018 via email

@gtaylor
Copy link

gtaylor commented May 27, 2018

To throw in another usage case, we have Helm charts for Roles and RoleBindings. IIRC, the latter will fail if you try to bind a Role that doesn't exist yet.

We also Chart StorageClasses, which have to be the very first thing provisioned (our default storage class, in particular).

@mumoshu
Copy link
Collaborator

mumoshu commented Jun 6, 2018

I have a WIP PR for #151 with lexical ordering at #160. Would you mind taking a look?

@sstarcher
Copy link
Contributor

@gtaylor what's the logic for having roles and rolebindings in separate charts and not in the same chart?

@gtaylor
Copy link

gtaylor commented Jun 6, 2018

You don't always need both.

@sstarcher
Copy link
Contributor

I don't understand why you would have roles, but not bind them to anything. Seems like they go together to me and I would also enable/disable them through flags instead of having them in separate charts, but I don't have your full use-case.

@Stono
Copy link
Contributor Author

Stono commented Jun 7, 2018

We create roles on clusters for specific user types at the point of cluster bootstrapping, ClusterRoleBindings are added at a later date.

Roles and RoleBindings don't need to go in separate charts however, I believe you can do a rolebinding to a non-existent role and k8 just resolves them later when the role exists.

mumoshu added a commit that referenced this issue Jun 14, 2018
Resolves #151 #137

Notes:

- You can have either helmfile.d or helmfile.yaml/charts.yaml, not both
@mumoshu
Copy link
Collaborator

mumoshu commented Aug 30, 2018

#247 would allow more granular control over ordering.

@mumoshu
Copy link
Collaborator

mumoshu commented Sep 21, 2018

@Stono Can we close this as resolved via #160 #266, and #339?

@mumoshu
Copy link
Collaborator

mumoshu commented May 14, 2019

As answered in #591, I think sub-helmfiles can be used for ordering. It was known to be very repetitive, but after #587 the repetition is greatly reduced.

Closing this as resolved, but please feel free to reopen or create an another issue if you have any other request! Thanks.

@mumoshu mumoshu closed this as completed May 14, 2019
@borgilb
Copy link

borgilb commented Aug 30, 2019

@mumoshu looked at the docs but not 100% sure how ordering works.

Can I just do this and they will be installed in the order that they are specified?

releases:
- name: chart-that-installs-a-crd
  chart: stable/chart-that-installs-a-crd
- name: chart-that-uses-that-crd
  chart: chart-that-uses-that-crd

@mumoshu
Copy link
Collaborator

mumoshu commented Aug 30, 2019

Nope. Releases are handled concurrently per --concurrency N where the default value for N is the number of releases in each helmfile.yaml :)

@andrewnazarov
Copy link
Contributor

Thus basically you can achieve some ordering by setting concurrency to 1 :) But probably it's better to do something like this:

helmfiles:
- install-crd.yaml

releases:
- name: chart-that-uses-that-crd
   chart: chart-that-uses-that-crd

@mumoshu
Copy link
Collaborator

mumoshu commented Sep 1, 2019

@andrewnazarov Thanks for the comment! Yeah I think that's correct.

Also see #715 that will give you concurrency AND ordering without splitting helmfile.yaml files.

raxod502-plaid pushed a commit to raxod502-plaid/helmfile that referenced this issue Jun 30, 2022
Signed-off-by: yxxhero <aiopsclub@163.com>
@michaelruigrok
Copy link

For those here today, you can use needs to specify required order/dependencies
https://helmfile.readthedocs.io/en/latest/#dag-aware-installationdeletion-ordering-with-needs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants