Nested projects environment

Hi guys,

basically what I am trying to do is to have a high-level project that would allow me to deploy my whole environment (which consists of multiple individual sub-projects), while also being able to manage (deploy and remove) those individual sub-projects. However, whenever I try to run something from sub-project directory - the whole project is still deployed. Can you please recommend something?


Hi Michael!

That’s a great question. The notion of sub-projects has been on our roadmap for quite awhile now but we haven’t found time to action it. We’re also debating the design, it’s a complex feature and a lot to consider.

That being said, there are workarounds but I think I’d need to understand your use case a little bit better before suggesting one.

First off, does the sub-project directory have a project level Garden config file? I.e. a config file that has kind: Project. Because Garden should always find the “nearest” project config and deploy the services that belong it. And not anything higher in the tree. So it sounds like the sub project is missing a config with kind: Project.

Second, are those sub-projects a logical group of modules that have the same runtime environment (i.e. the all run in the same Kubernetes cluster) or is there more to it? In that case, you might be able to achieve what you’re after with some templating hacks, e.g. by leaning on the the disabled field in the module config.

And if there’s anything else you can share about the structure of these sub-projects and your use case, then that would be super helpful.

1 Like

Hi Eysi,

I do miss a kind:Project in sub-project - will try it first of all. Regarding modules - they all go into the same runtime environment when deployed on project level, so will try your other suggestion if first is not enough.


So, adding kind:Project to sub-project solved my original issue, thanks! However, now I am fighting the opposite thing - when I run “deploy” from the root project - it also tries to deploy all services from sub-project - which I want to exclude as these are configured differently. I tried to add the appropriate garden.yml to .gardenignore - but it does not help.
Note that my sub-projects are git sub-modules - and based on what I read in Garden docs - looks like .gardenignore skips sub-modules… Any suggestion for this?

Thanks again!

So I tried to work around it by defining separate variable in sub-project:
allow-private-deployment: allow

and then setting “disabled” flag on the module:

    kind: Module
    disabled: ${var.allow-private-deployment != "allow"}

This still did not work if the module name was the same in both configurations - was getting:
Module myservice is declared multiple times (in '' and 'modules/myservice/garden.yml')

So I renamed the module in my parent project - and this allowed me to deploy the whole configuration. However, now I cannot deploy the same chart from inside the git project that hosts this chart - getting
invalid ownership metadata error (because the deployed name is different from the one I try to deploy)…

Really need to just be able to somehow ignore garden files in sub-modules… :slight_smile:


Hey @michael. I think the modules.exclude field might be what you’re looking for: Project Configuration - Garden

Garden will ignore any modules that match that filter. Think that would do the trick?

Got it working, thanks Jon!

1 Like