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

Google Managed VMs Sudoku Lab

Google Managed VMs Sudoku Lab

Basic App engine tutorial, Docker introduction and Managed VMs tutorial.

GoogleCloudPlatform

November 13, 2014
Tweet

More Decks by GoogleCloudPlatform

Other Decks in Programming

Transcript

  1. Sudoku Solver Codelab
    On Google App Engine Managed VMs

    View full-size slide

  2. Ludovic Champenois
    Guillaume Binet
    Éamonn McManus
    Mandy White
    Martin Gorner
    Alexis Moussine Pouchkine

    View full-size slide

  3. Google App Engine
    Python, Java, PHP, Go, ...

    View full-size slide

  4. Hello World
    Sudoku V1
    Introduction to docker
    Sudoku V2 with a Custom Runtime
    2:30
    pm
    2:45
    pm
    3:30
    pm
    4:00
    pm
    Introduction
    2:00
    pm

    View full-size slide

  5. Hello World
    Sudoku V1
    Introduction to docker
    Sudoku V2 with a Custom Runtime
    2:30
    pm
    2:45
    pm
    3:30
    pm
    4:00
    pm
    Introduction
    2:00
    pm

    View full-size slide

  6. IaaS
    Infrastructure-as-a-Service
    PaaS
    Platform-as-a-Service
    SaaS
    Software-as-a-Service
    Exploring the Cloud

    View full-size slide

  7. Storage
    Cloud Storage Cloud SQL
    Cloud
    Datastore
    Compute
    Compute
    Engine
    App Engine
    App Services
    BigQuery
    Cloud
    Endpoints
    Google Cloud Platform
    Container
    Engine

    View full-size slide

  8. Simple to Scale
    - Autoscale
    Easy to develop
    - Free to start
    - Build and test locally
    - Focus on App Code
    Google App Engine
    Trivial to manage
    - Fully managed
    - No patches/updates
    - 24x7 operation by
    Google SREs

    View full-size slide

  9. build and deploy vm images
    • Curated runtimes
    • Rich services
    • Auto-everything
    • … just add code
    ● Managed collections
    ● Declarative + Dynamic
    Reimagining Compute
    Compute as a Continuum
    Platform
    Cluster
    • Basic atom
    • Run anything
    VM
    Manage less, get more
    Fewer constraints
    build and deploy containers build and deploy apps

    View full-size slide

  10. The Continuum of Computing
    Managed
    VMs
    IaaS
    Infrastructure-as-a-Service
    PaaS
    Platform-as-a-Service
    Virtualized hardware Abstracted computing power

    View full-size slide

  11. Hello World
    Sudoku V1
    Introduction to docker
    Sudoku V2 with a Custom Runtime
    2:30
    pm
    2:45
    pm
    3:30
    pm
    4:00
    pm
    Introduction
    2:00
    pm

    View full-size slide

  12. Hello World
    Check and decompress the devkit from the USB key:
    $ cp /usb_mount_point/appengine-offline-devkit-v3.zip* ˜
    # Check with the "mount" command where it is mounted
    # The copy will take a while
    $ cd
    $ shasum -c appengine-offline-devkit-v4.zip.sha1
    $ unzip appengine-offline-devkit-v4.zip
    [Win] Copy the file into your home directory and unzip it in place.
    $ cd appengine-offline-devkit
    Follow the README there and specific steps for your platform.
    $ boot2docker up

    View full-size slide

  13. Hello World
    Clone the codelab repo in a working directory with:
    $ git clone https://github.com/GoogleCloudPlatform/appengine-java-vm-sudoku-sample.git
    $ cd appengine-java-vm-sudoku-sample
    Ask to be added to one of the devoxx2014-[1-25].appspot.com projects.
    login using gcloud with: gcloud auth login
    Set your application ID with: $ gcloud config set project devoxx2014-XX

    View full-size slide

  14. Hello World
    Checkout the helloworld branch with:
    $ git checkout helloworld
    Check README.md to copy paste the commands.
    1. Run the app locally
    Dig out the logs with:
    $ boot2docker ssh
    $ cd /var/log/app_engine/sd-solver-java/default/1/0/
    $ ls -la
    2. Deploy the app

    View full-size slide

  15. Hello World
    Sudoku V1
    Introduction to docker
    Sudoku V2 with a Custom Runtime
    2:30
    pm
    2:45
    pm
    3:30
    pm
    4:00
    pm
    Introduction
    2:00
    pm

    View full-size slide

  16. Sudoku V1
    $ git checkout textbased
    Your mission:
    1. Pass the content of the file to the solver and return it directly as a
    flat string representation of 81 chrs : “000002034…” with 0 = empty
    spots to solve.
    2. Store the solution in the Datastore and return it from the Datastore
    if it already exists.
    3. Use Objectify to cache the result before trying the Datastore and
    otherwise solve it if it is the first time we have seen this puzzle.

    View full-size slide

  17. Hello World
    Sudoku V1
    Introduction to docker
    Sudoku V2 with a Custom Runtime
    2:30
    pm
    2:45
    pm
    3:30
    pm
    4:00
    pm
    Introduction
    2:00
    pm

    View full-size slide

  18. Introduction to Docker
    > docker images
    > docker run -i -t busybox /bin/sh
    # touch tmp/hello ← within the container
    > $(boot2docker shellinit) ← from another terminal
    > docker ps
    # exit ← this exits the container

    View full-size slide

  19. Introduction to Docker
    $ docker ps -a | head
    $ docker logs e80719744b02
    $ docker commit e80719744b02 busybox/touched
    $ docker images | grep busybox/touched
    Those steps can be "programmed" in a kind of Makefile : Dockerfile
    $ git checkout docker
    $ cat opencv_build/Dockerfile

    View full-size slide

  20. GCE
    instance
    Introduction to Docker
    Dev machine
    boot2docker virtual machine (VirtualBox)
    gcloud preview app run
    Docker daemon
    Docker client
    boot2docker
    docker
    container
    (module)
    docker
    container
    (module)
    docker
    container
    (module)
    docker
    registry
    Private
    docker
    registry
    docker push
    docker pull
    APIs
    Emulated APIs
    Proxy / LB
    Proxy

    View full-size slide

  21. Hello World
    Sudoku V1
    Introduction to docker
    Sudoku V2 with a Custom Runtime
    2:30
    pm
    2:45
    pm
    3:30
    pm
    4:00
    pm
    Introduction
    2:00
    pm

    View full-size slide

  22. Sudoku V2 with a Custom Runtime
    $ docker inspect google/appengine-java
    [...] "Entrypoint": [ "/home/vmagent/jetty_run.sh" ], ← what we run
    [...] "ExposedPorts": { "8080/tcp": {} }, ← what we expose
    $ git checkout docker
    $ cat src/main/webapp/Dockerfile
    Your mission :
    - Fix the Dockerfile to make the native version run.
    - Run locally, Deploy to the Cloud.
    - Try your app from your mobile phone.

    View full-size slide

  23. Advanced Cloud Debugging
    Push your project to a github repo
    In the Admin Console https://console.developers.google.com
    - See the Source Code/ Browse Menu
    - Register your git repo
    - Navigate to a Java Class. Click the “eye”-like button
    - Set a Watch Point
    - Make your application hit this code path
    More info at https://cloud.google.com/tools/cloud-debugger

    View full-size slide

  24. Hello World
    Sudoku V1
    Introduction to docker
    Sudoku V2 with a Custom Runtime
    2:30
    pm
    2:45
    pm
    3:30
    pm
    4:00
    pm
    Introduction
    2:00
    pm
    Congrats!
    Done...

    View full-size slide

  25. App Engine Managed VMs
    https://cloud.google.com/free-trial/index
    Free trial for 60 days… (new users only)

    View full-size slide