-
Notifications
You must be signed in to change notification settings - Fork 3
Stack design
Igor Lysak edited this page Sep 28, 2022
·
2 revisions
Hub CLI manifest is flexible format that could be overused. Please follow the guidelines below.
- Component's
hub-component.yaml
must not usefromEnv:
to bindkind: user
parameters to the environment variables. The parameters are bound to the environment (if required) on stack level - either inhub.yaml
orparams*.yaml
. - Export parameters to OS environment via
env:
- Set defaults via
value:
. -
kind: user
is for high-level input from user, like domain of the stack, number of worker nodes, etc. -
default:
is forkind: user
- if no value is specified, then - if stdin is a TTY - user is asked by Hub CLI to accept the default or provide value. If not a TTY, then the default is used as value. - Set defaults in
Makefile
ordeploy
shell script, e.g.NAME ?= dev
, so that the component is usable out of CLI lifecycle (modulo templates), and also self-documented. - Do not rely on global environment set prior to stack deployment, e.g.
TF_VAR_name
. They will be filtered out from environment by Hub CLI. See help forhub deploy --os-environment
. - Component parameters defined in
hub-component.yaml
(implicitkind: tech
) are scoped to the current component only. Useoutputs:
to provide values visible by subsequent components, for example:
outputs:
- name: component.postgresql.namespace
- name: component.postgresql.instance
value: ${component.postgresql.name}-rds
- To bind
hub.yaml
level parameter to a value which is not known in advance (component output) usekind: link
:
parameters:
- name: component.cdn.bucket
value: ${component.s3.bucket}
kind: link
-
<component>
is origin fromcomponents/<component>
of Agile Stacks components Git repo. -
<component-name>
is the name of the component in the stack (pg1) - same as${hub.componentName}
:
components:
- name: pg1
source:
dir: components/postgresql-rds
- Finally,
component.*.name
- if required for particular component implementation to avoid collisions and describe the deployment, is something user may want to set, and may become TF_VAR_name, Kubernetes ingress name, etc. on the component level. You may want to default it to${hub.componentName}
inhub-component.yaml
.
For Terraform-based components the shared state is stored as s3://state-bucket/<domain>/<component>/<component-name>/terraform.tfstate
.
- Bind stack instance specific parameters to environment variables via
fromEnv:
so that stack template could be deployed multiple times, and parameterized via environment. - Avoid
fromEnv: TF_VAR_*
. - Avoid setting
env:
- the parameters must be exported by each component in component specific way. This is actually currently disabled by Hub CLI.
- Avoid setting
TF_VAR_*
variable to influence component directly bypassinghub.yaml
/params*.yaml
wiring. Hub CLI will filter these out of children process environment by default--os-environment
. - Set
.envrc
and/or.env
vars forhub.yaml
/params*.yaml
parameters captured viafromEnv
.
© 2022 EPAM Systems, Inc. All Rights Reserved