Slide 1

Slide 1 text

Blocks in containers lessons learned from containerizing Minecraft

Slide 2

Slide 2 text

@juliaferraioli 2 Julia Ferraioli Software Engineer Open Source @ Google Empathy in tech advocate ML enthusiast

Slide 3

Slide 3 text

@juliaferraioli 3

Slide 4

Slide 4 text

@juliaferraioli 4 I’m addicted to Minecraft 4

Slide 5

Slide 5 text

@juliaferraioli 5

Slide 6

Slide 6 text

@juliaferraioli 6 Okay, I’m addicted to Minecraft and Lego 6

Slide 7

Slide 7 text

@juliaferraioli 7

Slide 8

Slide 8 text

@juliaferraioli 8 Alright, I’m addicted to Minecraft, Lego, and cloud 8

Slide 9

Slide 9 text

@juliaferraioli 9

Slide 10

Slide 10 text

@juliaferraioli 10 Fine! I’m addicted to Minecraft, Lego, cloud, and containers 10

Slide 11

Slide 11 text

@juliaferraioli Let’s talk about containers 11

Slide 12

Slide 12 text

@juliaferraioli 14%-36% 12 Running in production The New Stack: http://bit.ly/containers-in-prod

Slide 13

Slide 13 text

What’s the barrier here? 13 CC image courtesy of Kevin: https://flic.kr/p/7EUqHX

Slide 14

Slide 14 text

@juliaferraioli We have educational resources 14 14

Slide 15

Slide 15 text

@juliaferraioli We have cloud provider support 15 15

Slide 16

Slide 16 text

@juliaferraioli We have meetup upon meetup 16 16

Slide 17

Slide 17 text

17 CC image courtesy of Andrew Albosta: https://flic.kr/p/ab3VhW Missing the link between here and awesometown

Slide 18

Slide 18 text

We need a toy… problem 18 CC image courtesy of Glenn Calvin: https://flic.kr/p/5LfNZM

Slide 19

Slide 19 text

19 ❔ ● ...that predate the surge in container popularity? ● ...that are understood/used by many? ● ...that are complex enough that containerization makes sense ...but simple enough to tackle? What sort of fully-baked apps do we have... 19 ❔ ❔

Slide 20

Slide 20 text

@juliaferraioli 20 20

Slide 21

Slide 21 text

@juliaferraioli Phase 1: experimentation 21

Slide 22

Slide 22 text

@juliaferraioli Uh, hello Minecraft? What does Minecraft need? FROM debian:latest RUN apt-get update && apt-get install -y curl openjdk-7-jre ENV MC_VERSION 1.8.9 ENV BASE_URL https://s3.amazonaws.com/Minecraft.Download/versions ENV SERVER_FILE minecraft_server RUN mkdir /opt/mc WORKDIR /opt/mc RUN curl $BASE_URL/$MC_VERSION/$SERVER_FILE.$MC_VERSION.jar \ -o minecraft.jar && chmod u+x minecraft.jar CMD java -Xmx1024M -Xms1024M -jar minecraft.jar nogui 22 Java. It needs Java.

Slide 23

Slide 23 text

23 CC image courtesy of Josh Wedin: https://flic.kr/p/amAXdF This is kind of old hat

Slide 24

Slide 24 text

24 Where’s the magic?

Slide 25

Slide 25 text

@juliaferraioli Phase 2: 25 cautious containerization

Slide 26

Slide 26 text

@juliaferraioli Building and testing ➜ ~ docker build -t juliaferraioli/mc:v1 . ➜ ~ docker run -p 25565:25565 -d juliaferraioli/mc:v1 d7d5e58f8833952b51d33c9c63a2b763f1a290d33270245a518d17d689f45f39 ➜ ~ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES well, . 26

Slide 27

Slide 27 text

@juliaferraioli Phase 3: problem identification 27

Slide 28

Slide 28 text

@juliaferraioli I build and run but nothing happens! `-d` means detached => when our CMD exits, the container exits => `java -Xmx1024M -Xms1024M -jar minecraft.jar nogui` must have exited 28

Slide 29

Slide 29 text

@juliaferraioli Okay, let’s remove the flag ➜ ~ docker run -p 25565:25565 juliaferraioli/mc:v1 29 [16:33:54] [Server thread/INFO]: Starting minecraft server version 1.9.2 [16:33:54] [Server thread/INFO]: Loading properties [16:33:54] [Server thread/WARN]: server.properties does not exist [16:33:54] [Server thread/INFO]: Generating new properties file [16:33:54] [Server thread/WARN]: Failed to load eula.txt [16:33:54] [Server thread/INFO]: You need to agree to the EULA in order to run the server. Go to eula.txt for more info. [16:33:54] [Server thread/INFO]: Stopping server

Slide 30

Slide 30 text

@juliaferraioli Ohhhhhh... 30 startServer.sh ● If there’s already an accepted EULA... ● or if we accepted through the ENV... ● go ahead and start the server. ● Else, prompt the user to read the EULA and exit the script CC image courtesy of Betsy Weber: https://flic.kr/p/nE6i31

Slide 31

Slide 31 text

@juliaferraioli Uh, hello Minecraft? (Reprise) What does Minecraft need? FROM debian:latest RUN apt-get update && apt-get install -y curl openjdk-7-jre ENV MC_VERSION 1.8.9 ENV BASE_URL https://s3.amazonaws.com/Minecraft.Download/versions ENV SERVER_FILE minecraft_server RUN mkdir /opt/mc WORKDIR /opt/mc COPY startServer.sh /opt/mc/ RUN curl $BASE_URL/$MC_VERSION/$SERVER_FILE.$MC_VERSION.jar \ -o minecraft.jar && chmod u+x minecraft.jar startServer.sh CMD ./startServer.sh 31 Java. It needs Java. And an accepted EULA.

Slide 32

Slide 32 text

@juliaferraioli Lesson(s) 32

Slide 33

Slide 33 text

33 Storage becomes complicated CC image courtesy of Windell Oskay: https://flic.kr/p/4hAC16

Slide 34

Slide 34 text

34 Storage stays complicated CC image courtesy of Windell Oskay: https://flic.kr/p/4hAC16

Slide 35

Slide 35 text

35 Ephemerality is hard to grok CC image courtesy of Spielbrick Films: https://flic.kr/p/bxSAE4

Slide 36

Slide 36 text

@juliaferraioli Phase 4: 36 containerizing ALL the things!

Slide 37

Slide 37 text

@juliaferraioli I’m the conductor of this orchestra 37 CC image courtesy of Brian Alano: https://flic.kr/p/npdy7U

Slide 38

Slide 38 text

@juliaferraioli I’m the conductor of this orchestra ➜ ~ kubectl run mc --image=gcr.io/octopodes-go-bloop/mc:v2 \ --env="EULA=true" --port=25565 ➜ ~ kubectl expose deployment mc type=LoadBalancer ➜ ~ kubectl describe services mc 38

Slide 39

Slide 39 text

@juliaferraioli Phase 5: freedom! 39

Slide 40

Slide 40 text

40 Breaking out of the machine CC image courtesy of Shadowman39: https://flic.kr/p/q1oivr

Slide 41

Slide 41 text

41 Lack of boundaries is freeing CC image courtesy of Chris Sampson: https://flic.kr/p/C4Ebc4

Slide 42

Slide 42 text

@juliaferraioli Phase 6: absurdity 42

Slide 43

Slide 43 text

@juliaferraioli Resources ● Minecraft EDU: http://bit.ly/mc-edu ● Dockercraft: http://bit.ly/dockercraft ● Kubernetes: http://bit.ly/k8s-for-users ● Beyond ‘Screen Time’: http://bit.ly/beyond-the-screen ● Where’s the Ball?: http://bit.ly/wheres-the-ball ● Docker documentation: http://bit.ly/docs-docker ● Kubecraft (!!!): http://bit.ly/kubecraft 43

Slide 44

Slide 44 text

@juliaferraioli 44 CC image courtesy of Sheila Thomson: https://flic.kr/p/bxCySn Thanks!

Slide 45

Slide 45 text

@juliaferraioli Uh oh! 45 CC image courtesy of Frédérique Voisin-Demery: https://flic.kr/p/t7Kmn9

Slide 46

Slide 46 text

@juliaferraioli 46