Do it in code (not YAML)! Unlock power of Kotlin DSL for Kubernetes

A presentation at DevNexus 2020 in February 2020 in Atlanta, GA, USA by Viktor Gamov

Slide 1

Slide 1

Do it in code (not YAML)! Unlock power of Kotlin DSL for Kubernetes February, Atlanta, GA 2019 @gamussa @gamussa || #devnexus @devnexus || @confluentincc @confluentinc

Slide 2

Slide 2

3 @gamussa | #devnexus | @confluentinc

Slide 3

Slide 3

Raffle, yay! Follow @gamussa Post some 📸 🖼 🏋 😂 Tag @gamussa Hashtag #devnexus

Slide 4

Slide 4

5 Evolution for YAML in the company Scripts - No YAML Ansible - YAML @gamussa | #devnexus Helm - YAML | ? @confluentinc

Slide 5

Slide 5

#dangerzone! Following slides may cause pain! @gamussa | #devnexus | @confluentinc

Slide 6

Slide 6

7 @gamussa | #devnexus | @confluentinc

Slide 7

Slide 7

8 @gamussa | #devnexus | @confluentinc

Slide 8

Slide 8

9 @gamussa | #devnexus | @confluentinc

Slide 9

Slide 9

10 @gamussa | #devnexus | @confluentinc

Slide 10

Slide 10

Slide 11

Slide 11

12 BASH ??? YAML @gamussa | #devnexus | @confluentinc

Slide 12

Slide 12

13 Why yaml? @gamussa | #devnexus | @confluentinc

Slide 13

Slide 13

14 Why, yaml? Why? ● Initial Release in 2001 ● Originally Yet Another Markup Language ● Repurposed as YAML Ain’t Markup Language ● From Wiki: “commonly used for configuration files” ● End goal is to declare something ● YAML is not going anywhere any time soon 😫 @gamussa | #devnexus | @confluentinc

Slide 14

Slide 14

15 Types? What are you talking about? @gamussa | #devnexus | @confluentinc

Slide 15

Slide 15

16 @gamussa | #devnexus | @confluentinc

Slide 16

Slide 16

17 Ok. There is a schema tho https://json-schema.org/ @gamussa | #devnexus | @confluentinc

Slide 17

Slide 17

18 @gamussa | #devnexus | @confluentinc

Slide 18

Slide 18

Yaml is ok… for small things

Slide 19

Slide 19

20 @gamussa | #devnexus | @confluentinc

Slide 20

Slide 20

21 @gamussa | #devnexus | @confluentinc

Slide 21

Slide 21

22 if «everything as code» Why I do write so much yaml? @gamussa | #devnexus | @confluentinc

Slide 22

Slide 22

23 Evolution for YAML in the company Ansible - YAML sh and make - No YAML @gamussa | #devnexus Helm - YAML | @confluentinc Kotlin DSL - No YAML

Slide 23

Slide 23

24 Let’s talk Kubernetes @gamussa | #devnexus | @confluentinc

Slide 24

Slide 24

KUBERNETES @gamussa | #devnexus | @confluentinc

Slide 25

Slide 25

26 Kubernetes Architecture Actually JSON image source: Janakiram MSV

Slide 26

Slide 26

27 @gamussa | #devnexus | @confluentinc

Slide 27

Slide 27

28 🤔 THINGS TO THINK ABOUT YAML FOR K8S AT SCALE ●How to avoid copy-pasting? ●How to provide common primitives? ●How to allow customization for teams? ●How to test incremental changes? ●Some tools to analyze current state of clusters @gamussa | #devnexus | @confluentinc

Slide 28

Slide 28

29 INGRESS EXAMPLE @gamussa | #devnexus | @confluentinc

Slide 29

Slide 29

30 KOTLIN DSL FOR KUBERNETES @gamussa | #devnexus | @confluentinc

Slide 30

Slide 30

31 DSL generation ●Generates DSLs from fabric8 types ●Generates fabric8 types from deployed CRDs 😅 @gamussa | #devnexus | @confluentinc

Slide 31

Slide 31

32 Confluent operator architecture @gamussa | #devnexus | @confluentinc

Slide 32

Slide 32

33 a custom Kubernetes controller PODS API Server StatefulSets PVs Controllers & Custom Controllers Custom Resources Master Node Worker Node | Applications run on Kubernetes ● Applications use objects like StatefulSets, Configmaps, PVs ● Custom Controllers create custom resources that provide unique application functionality: ConfigMaps Scheduler @gamussa ● Nodes and pods are where #devnexus | @confluentinc ○ Upgrades, elasticity, Kafka Operational Logic

Slide 33

Slide 33

34 KOTLIN POWER: BUILDERS @gamussa | #devnexus | @confluentinc

Slide 34

Slide 34

35 KOTLIN POWER: EXTENSION FUNCTIONS @gamussa | #devnexus | @confluentinc

Slide 35

Slide 35

36 KOTLIN POWER: EXTENSION FUNCTIONS @gamussa | #devnexus | @confluentinc

Slide 36

Slide 36

https://gamov.dev/devnexus-dsl-2020

Slide 37

Slide 37

https://github.com/fkorotkov/k8s-kotlin-dsl

Slide 38

Slide 38

I GUESS YOU FOLKS ARE NOT READY FOR THIS YET 39 BUT YOUR KIDS ARE GONNA LOVE IT @gamussa | #devnexus | @confluentinc

Slide 39

Slide 39

Thanks! @gamussa viktor@confluent.io https://slackpass.io/confluentcommunity #kubernetes @gamussa | @ #devnexus | @confluentinc

Slide 40

Slide 40

41