2

I've one question regard the helm dependency, when you decleare that one chart B is dependent on chart A , when it starts to install chart B, after the A is up and running? , how does helm know that, liveness prob ? something else?

Jenney
  • 171
  • 6
  • 18

1 Answers1

3

There is no such thing as

install chart B, after the A is up and running

right now in helm.

It will just template and feed all the resources you have in your chart and in all it's dependencies to k8s API server.

You can take a look at Chart hooks and Chart tests - maybe they will be useful for solving your problem.

You can read more about the order the resources are applied in Helm install in certain order

Vüsal
  • 2,580
  • 1
  • 12
  • 31
  • Thanks 1+, even if I create some umbrella chart ? 1+ – Jenney Oct 28 '21 at 11:24
  • 1
    Yes, there is no such a concept in helm. Umbrella chart is just a term. Technically it's just a chart with some dependencies. Usually people create umbrella charts to group related components and deploy/install them together. – Vüsal Oct 28 '21 at 12:05
  • Is there any way that you can think of that I can solve this issue using helm ? – Jenney Oct 28 '21 at 12:09
  • 1
    What is your issue? Why do you need to have a dependency between your components? In a distributed world there must not be a hard dependency between any services, anyone should be ready, that any of the services to which it talks can be out of service anytime. For example DB, if you have a service that connects to DB on startup and does something, and at the time the DB is not yet available - let it fail or retry, if you let it fail - k8s will restart it anyway. – Vüsal Oct 28 '21 at 12:13
  • 1
    our issue is like following: we have two charts which I need to install one after other, but the trick here that Before I install chart B I need to run some simple /short script and only than install the B chart, how we could achieve that ? – Jenney Oct 28 '21 at 13:39
  • My question was more like why is there a need to install one after the other? Maybe you don't need to do it that way? – Vüsal Oct 28 '21 at 13:48
  • I have same use-case. I have pre-install,pre-upgrade hook which creates database, import dump(on dev) and run migrations(prod) - so these hooks fails, because MariaDB dependency is installed after hooks. So I basically need all the dependencies, installed and healthy, before install of my app. – CappY Oct 28 '21 at 17:59
  • All I'm saying is that your components must be ready to reconcile. For example, an app starts and there is no database - no problem, let it fail - kubernetes will restart it again and at that time there will be a database (hopefully). Or, you need to run DB migrations - again, most of the DB migration tools are ready to be run concurrently. Even if more than 1 app try to apply DB migration at the same time - it should be fine, because they use locks (Lock the migration history table for example). – Vüsal Oct 29 '21 at 08:41
  • If an app A needs B to start, and at the time of start B is not present - then it's fine for A to fail and be restarted. Or, keep retrying without failing. If you use k8s - you should be ready for this kind of situation. – Vüsal Oct 29 '21 at 08:42
  • @Vusal it won't happens like that. HELM Hooks first waits until they finish and AFTER that they will send other manifest. So basically my migrations will always fail, and never suceed, because RDBMS is installed only AFTER MIGRATIONS succeed, but they never do. – CappY Oct 29 '21 at 15:04
  • I would use k8s jobs instead of helm hooks for what you described. – Vüsal Oct 29 '21 at 15:31
  • @Vusal but how you guarantee that Deployment will wait for Job to finish? Otherwise deployment could eventually deploy first and code will search for non-existing column, and that will result in fatal error. And still, the hook IS a job. – CappY Oct 29 '21 at 19:23
  • "Otherwise deployment could eventually deploy first and code will search for non-existing column". If we'are talking about DB migrations - then a decent migration tool won't let the app start or provide a way to validate the state of migration. In one of our projects we use Flyway and we do exactly the same, if there is a migration in progress the app won't become live (liveness probes will fail) - and either will be restarted or become live at the next attempt to check liveness by kubernetes (in k8s you can specify how many probes must be done, before considering pod as a failed one) – Vüsal Oct 31 '21 at 10:45