SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.
SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.
Successfully reported this slideshow.
Activate your 14 day free trial to unlock unlimited reading.
Yaml FTW! Infrastructure as code is eating the world (well, part of it). YAML, JSON, TOML, HCL and several other languages tend to describe the desired state of your infrastructure controlled by the STATE MACHINE. How does it work? Let’s dive into an illustrated journey behind the machinery of various tools like Terraform, Ansible, Kubernetes.
Yaml FTW! Infrastructure as code is eating the world (well, part of it). YAML, JSON, TOML, HCL and several other languages tend to describe the desired state of your infrastructure controlled by the STATE MACHINE. How does it work? Let’s dive into an illustrated journey behind the machinery of various tools like Terraform, Ansible, Kubernetes.
45.
Declarations, not actions
Yaml is good for defining serialized data and declared state
But it does not support constructs for variables, functions, deep
references
And it is not so good for imperative/sequential scripts (I'm looking at
you Ansible)
?
•
•
•
45
61.
Pluto's status
$ use apply solar_system.yml
use: Modifying Pluto...
use: Pluto's metadata modified in 10ns
fume: libraries on Earth have been updated
to reflect changes in Pluto's status
01.
02.
03.
04.
05.
61
64.
Let's check it
$ use apply solar_system.yml
use: Creating "MyComet"...
use: MyCommet is created
fume: WARNING: Unknown object is aproaching planet "Earth"
01.
02.
03.
04.
64
65.
Let's remove the code
$ use apply solar_system.yml
use: all is up-to-date. no changes have been applied.
fume: WARNING: Unknown object is aproaching planet "Earth"
01.
02.
03.
65
66.
Compensating actions
$ use delete comet/MyComet
use: Comet "MyComet" has been destroyed
01.
02.
66
107.
Ansible machine
Signs of state management, idempotance is not always achievable.
Can be parallel only on node level, not resource (task) level.
No model for resource dependencies.
Imperative logic elements implemented in a declarative, but hardly
readable way ( register , set_fact , when ).
•
•
•
•
107
110.
Kubernetes machine
api-server will accept any valid object definition.
Will it be created and running? Eventually, it should.
Run-time state validation.
Not all attributes are changeable.
Custom resource definitions (+ operators).
Queries and dependencies only through labels.
•
•
•
•
•
•
110
117.
Side effects are real
Know the tool
Know which resources you are managing
Know the side effects
•
•
•
117
118.
Tools
There are tools for tools: linters, IDE plugins, schema validators.
118
119.
Everything is a spectrum
Avoid dichotomy (bad/good, persistent/volatlie etc.), use a spectrum to
define your relationship with a tool/language.
119
120.
Keep it sane
If you need a complex logic, use a %&?# programming language or a
better declarative language with functions and variables.
Infrastructure-as-code does not mean you should use the same data
language all over the place.
Do not use YAML for imperative logic. Do not let the history repeating.
•
•
•
120