Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Blocks in containers

Blocks in containers

Lessons learned from containerizing Minecraft.

juliaferraioli

May 19, 2016
Tweet

More Decks by juliaferraioli

Other Decks in Technology

Transcript

  1. Blocks in containers
    lessons learned from containerizing Minecraft

    View full-size slide

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

    View full-size slide

  3. @juliaferraioli 3

    View full-size slide

  4. @juliaferraioli 4
    I’m addicted to Minecraft
    4

    View full-size slide

  5. @juliaferraioli 5

    View full-size slide

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

    View full-size slide

  7. @juliaferraioli 7

    View full-size slide

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

    View full-size slide

  9. @juliaferraioli 9

    View full-size slide

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

    View full-size slide

  11. @juliaferraioli
    Let’s talk about containers
    11

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  14. @juliaferraioli
    We have educational resources
    14
    14

    View full-size slide

  15. @juliaferraioli
    We have cloud provider support
    15
    15

    View full-size slide

  16. @juliaferraioli
    We have meetup upon meetup
    16
    16

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  19. 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


    View full-size slide

  20. @juliaferraioli 20
    20

    View full-size slide

  21. @juliaferraioli
    Phase 1: experimentation
    21

    View full-size slide

  22. @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.

    View full-size slide

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

    View full-size slide

  24. 24
    Where’s the magic?

    View full-size slide

  25. @juliaferraioli
    Phase 2:
    25
    cautious
    containerization

    View full-size slide

  26. @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

    View full-size slide

  27. @juliaferraioli
    Phase 3: problem identification
    27

    View full-size slide

  28. @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

    View full-size slide

  29. @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

    View full-size slide

  30. @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

    View full-size slide

  31. @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.

    View full-size slide

  32. @juliaferraioli
    Lesson(s)
    32

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  36. @juliaferraioli
    Phase 4:
    36
    containerizing ALL the
    things!

    View full-size slide

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

    View full-size slide

  38. @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

    View full-size slide

  39. @juliaferraioli
    Phase 5: freedom!
    39

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  42. @juliaferraioli
    Phase 6: absurdity
    42

    View full-size slide

  43. @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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  46. @juliaferraioli 46

    View full-size slide