-
Notifications
You must be signed in to change notification settings - Fork 35
Turbo Tip: Working with YAML files
YAML is the primary file format to create and configure resources on kubernetes, including everything to do with the Turbonomic platform. Working with the Custom Resource YAML provides the user a very convenient way, and single place to define the majority of configuration details for Turbonomic. To be successful with YAML file format, there are some simple tips reviewed below.
“YAML Ain’t Markup Language” (abbreviated YAML) is a data serialization language designed to be human-friendly and work well with modern programming languages for common everyday tasks, such as defining configuration parameters. It is intended to be portable and easier than XML and JSON. For more details on YAML refer to the project, and this informative description from Grav. Another great article on YAML tips is here.
Since spacing and indentations matter, and can yield an invalid result or a parameter completely skipped over, you should work with yaml files with an editor that supports using vertical lines associated with indentations to visually spot misalignments. Examples include VSCode, and IntelliJ.
For the Turbonomic Custom Resource, indentation defines where parameters are applied: global or to specific components. Some tips about spacing:
- Spaces should be set with only the space key
- Do not use the tab key
- Indentations use 2 spaces per level
The following example shows examples of specifications that are applied at a global level ({“spec”:{“global”:[{“tag”:”8.0.4”}]}}
) which sets the container image tag for all instances. Then indented we see properties that are global for the remote database ({“spec”:{“properties”:{"global":[{“dbPort”:”6033”}]}}}
) describes a property of dbPort that would be set for remote DB connections. Each line is indented 2 spaces from the higher level:
spec:
global:
repository: icr.io/cpopen/turbonomic
tag: 8.9.1
properties:
global:
dbPort: 6033
kubeturbo:
enabled: true
aws:
enabled: true
A YAML file is read top down, and if there are different parameters that apply to the same component, they need to be combined. The following example shows a YAML where properties for the ui
component of image tag and memory limit resources.
spec:
global:
repository: icr.io/cpopen/turbonomic
tag: 8.9.1
ui:
image:
tag: 8.9.2
properties:
global:
dbPort: 6033
kubeturbo:
enabled: true
aws:
enabled: true
ui:
resources:
limits:
memory: 4Gi
However this YAML will not set both image tag and memory limit resources for the ui
component because they are set in 2 different sections. Instead the memory limits as the last section read in would be applied, and basically overwrite the first set of properties with the image tag.
The following YAML will produce the results to set both image tag and memory limit resources for the ui
component:
spec:
global:
repository: icr.io/cpopen/turbonomic
tag: 8.9.1
ui:
image:
tag: 8.9.2
resources:
limits:
memory: 4Gi
properties:
global:
dbPort: 6033
kubeturbo:
enabled: true
aws:
enabled: true