Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Upcoming SlideShare
What to Upload to SlideShare
What to Upload to SlideShare
Loading in …3
×
1 of 135

Yamlware and the state machine

0

Share

Download to read offline

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.

Related Books

Free with a 30 day trial from Scribd

See all

Related Audiobooks

Free with a 30 day trial from Scribd

See all

Yamlware and the state machine

  1. 1. 01
  2. 2. 02
  3. 3. Yamlware Basically, any (configuration|infrastructure|deployment)-as-code software nowadays. “ 03
  4. 4. 04
  5. 5. 05
  6. 6. YAML: Good or bad? 06
  7. 7. YAML is great! 07
  8. 8. For computers YAML is a human friendly data serialization standard for all programming languages. “ 08
  9. 9. For humans YAML is a human friendly data serialization standard for all programming languages. “ 09
  10. 10. 10
  11. 11. 11
  12. 12. YAML is awful! 12
  13. 13. 13
  14. 14. 14
  15. 15. #NoYaml 15
  16. 16. Did you know? 16
  17. 17. Duplicate keys 17
  18. 18. Duplicate keys 18
  19. 19. Indentation 19
  20. 20. Base 60 Using ":" allows expressing integers in base 60, which is convenient for time and angle values. “ 20
  21. 21. Port mappings 25:25 = 25*60 + 25*3600 = 91500 53:53 = ... = 193980 • • 21
  22. 22. Anchors and references 22
  23. 23. Boolean y|Y|yes|Yes|YES| n|N|no|No|NO| true|True|TRUE| false|False|FALSE| on|On|ON| off|Off|OFF 01. 02. 03. 04. 05. 06. 23
  24. 24. 24
  25. 25. Content is trunca 25
  26. 26. Yaml is not Turing- complete!26
  27. 27. Ok, that's unfair! 27
  28. 28. Of course, it's not! It's not a computational language, it's a data language List of maps of lists of maps of maps of lists... • • 28
  29. 29. Is JSON better? 29
  30. 30. No comments 30
  31. 31. XML? Anyone? 31
  32. 32. 32
  33. 33. Stop whining 33
  34. 34. Yaml is a tool! 34
  35. 35. Industry needs a data language We need a simple language, to declare our intent, describe configuration, manage state, share serialized data. 35
  36. 36. Industry needs it, industry creates it36
  37. 37. JSONNET 37
  38. 38. JSON5 38
  39. 39. TOML 39
  40. 40. DHALL 40
  41. 41. YTT 41
  42. 42. YTT 42
  43. 43. HCL/HCL2 43
  44. 44. HCL/HCL2 44
  45. 45. How about a real language? 45
  46. 46. Standards, standards,... 46
  47. 47. 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) • • • 47
  48. 48. 48
  49. 49. The machine 49
  50. 50. 50
  51. 51. The machine Yaml (or any similar language) is just the declaration of WHAT Heavy lifting of HOW is done by the machinery • • 51
  52. 52. 52
  53. 53. 53
  54. 54. New version They just released v1.16 this month 54
  55. 55. U.S.E. 55
  56. 56. CLI 56
  57. 57. 57
  58. 58. 58
  59. 59. Let's play! 59
  60. 60. 60
  61. 61. Pluto's status 61
  62. 62. Pluto's status 62
  63. 63. Pluto's status 63
  64. 64. 64
  65. 65. Comet 65
  66. 66. Let's check it 6666
  67. 67. Let's remove the code 67
  68. 68. Compensating actions 68
  69. 69. 69
  70. 70. That's no moon 70
  71. 71. That's no moon 71
  72. 72. Go! Go! Go! 72
  73. 73. Wait! What? 73
  74. 74. SOL-101: Bug report Earth is overpopulated. We need to scale it up to house more biological forms. 74
  75. 75. Bug fix 75
  76. 76. Push it 76
  77. 77. No way! 77
  78. 78. Backup 78
  79. 79. 10 days later... 79
  80. 80. Real life state machines Kubernetes Terraform CloudFormation Serverless.com Ansible Puppet etc. • • • • • • • 80
  81. 81. Idempotance 81
  82. 82. Idempotance 82
  83. 83. Idempotent 83
  84. 84. Not idempotent 84
  85. 85. More code 85
  86. 86. Declarative catalogue 86
  87. 87. Readability! 87
  88. 88. Pipeline- integratable 88
  89. 89. Resource graph 89
  90. 90. 90
  91. 91. 91
  92. 92. Resource graph Resource depedency cluster detection Parallel execution Automatic ordering • • • 92
  93. 93. Attribute management 93
  94. 94. Attribute management L0: Write-once L1: Updatable, requires extra action to take effect L2: Updatable, forces resource recreation L3: Updatable, applied right-away • • • • 94
  95. 95. Data query 95
  96. 96. 96
  97. 97. Data query 97
  98. 98. Resource deletion 98
  99. 99. Resource deletion 99
  100. 100. Resource recreation 100
  101. 101. Resource protection 101
  102. 102. Dry-run 102
  103. 103. State verification 103
  104. 104. 104
  105. 105. Compensating actions Compensating actions may sometimes be required Not every state change is allowed Any software has bugs! • • • 105
  106. 106. Additional goodies Modularity Module hub (public repository) Module-level dependencies Resource-level dependencies Documentation • • • • • 106
  107. 107. SM-index idempotence maturity language/declarativeness maturity (readiblity) data query richness execution engine maturity (parallel execution, auto-ordering of dependencies, deletion of obsolete objects) modularity maturity documentation maturity (searchable, structured, different level audience) • • • • • • 107
  108. 108. 108
  109. 109. 109
  110. 110. Ansible machine 110
  111. 111. 111
  112. 112. 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 ). • • • • 112
  113. 113. Kubernetes machine 113
  114. 114. 114
  115. 115. 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. • • • • • • 115
  116. 116. kubectl wait 116
  117. 117. Helm 117
  118. 118. Terraform machine 118
  119. 119. 119
  120. 120. Terraform machine Terraform remembers previous state (supports resource deletion). Deployment time validation, no run-time validation. Not YAML, rich expression language. Powerful query capabilities. • • • • 120
  121. 121. Final words 121
  122. 122. Side effects are real Know the tool Know which resources you are managing Know the side effects • • • 122
  123. 123. Tools There are tools for tools: linters, IDE plugins, schema validators. 123
  124. 124. Rainbow Ident 124
  125. 125. Everything is a spectrum Avoid dichotomy (bad/good, persistent/volatlie etc.), use a spectrum to define your relationship with a tool/language. 125
  126. 126. 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. • • • 126
  127. 127. Keep it simple 127
  128. 128. Thank you! 128
  129. 129. 129
  130. 130. 130
  131. 131. References 131
  132. 132. Whining https://arp242.net/yaml-config.html https://noyaml.com https://boyter.org/posts/an-informal-survey-of-10-million-github- bitbucket-gitlab-projects/#yaml-or-yml https://www.darkcoding.net/software/a-developer-goes-to-a-devops- conference/ • • • • 132
  133. 133. Languages https://jsonnet.org/ https://json5.org/ https://dhall-lang.org/ https://get-ytt.io/ https://github.com/bazelbuild/starlark https://github.com/hashicorp/hcl2/blob/master/hcl/hclsyntax/spec.md https://github.com/toml-lang/toml#toml https://www.openpolicyagent.org/docs/latest/policy-language/ https://en.wikipedia.org/wiki/Datalog • • • • • • • • • 133
  134. 134. Tips https://www.redhat.com/sysadmin/yaml-tips https://networkgenomics.com/ansible/ • • 134
  135. 135. Kubernetes https://www.infoq.com/articles/kubernetes-workloads-serverless-era/• 135

×