-
Notifications
You must be signed in to change notification settings - Fork 3
FromStack
Stack developer has an option to compose stacks by including existing stack into a new stack as a base, by specifying fromStack: <filesystem directory>
under top-level meta
in the manifest:
meta:
name: dev
brief: Development version of infra
fromStack: ../infra
Hub CLI elaborate
command process the declaration by searching local filesystem for directory of the specified name.
The content of the parent stack directory must contain hub.yaml
, and, optionally, params.yaml
and params-<ENV>.yaml
where ENV
is a content of ENV
OS environment variable. Parent stack's hub.yaml
may in turn refer to another grandparent stack via fromStack
declaration, and so on.
hub.yaml
manifests are merged by hub elaborate
as follows:
-
meta
is taken from the last stack in order - the child stack. If there are multiplesource
declarations, then the last one wins. -
components
are merged - component with the same name getssource
set to the last stack in order. - Children
requires
are short-circuited to parentprovides
andprovides
are merged. -
lifecycle.order
are appended. In case child stack overrides parent stack component (by name) then the finallifecycle.order
of the stack could be modified - child'sorder
may insert it's components into the original order, see below. -
lifecycle.verbs
are merged.
Parameters are merged in order as usual - params.yaml
files are processed from left to right, child stack parameters are merged into parent parameters with child settings taking precedence over parent settings if both are supplied.
For example:
k8s-aws
stack with
- hub.yaml
- params.yaml
- fine-tuning.yaml
k8s-aws-with-monitoring
stack with fromStack: ../k8s-aws
under directory monitoring/
- hub.yaml
- params.yaml
- params-prod.yaml
- params-dev.yaml
dev-stack
stack with fromStack: ../monitoring
- hub.yaml
- params.yaml
- params-prod.yaml
- params-dev.yaml
After performing elaborate
:
cd dev-stack
hub elaborate hub.yaml params.yaml params-$ENV.yaml
the result is a flat hub.yaml.elaborate
that could be deployed with deploy
. Parameters files merge order for ENV=dev
:
- k8s-aws/params.yaml
- monitoring/params.yaml
- monitoring/params-dev.yaml
- dev-stack/params.yaml
- dev-stack/params-dev.yaml
If there is a parent stack A and a child stack B, with corresponding orders - for stack A:
- eks
- traefik
- dex
and for stack B:
- cert-manager
- traefik
- tls-host-controller
then the final deployment order is:
- eks
- cert-manager
- traefik
- dex
- tls-host-controller
Ie. traefik
is anchoring to the order position in the parent stack and insert every component in order prior to the anchor. Everything else goes after. There could be multiple anchors. You must also repeat anchor component (traefik
) declaration under components
in the child stack. This is a safety measure.
© 2022 EPAM Systems, Inc. All Rights Reserved