Coder Social home page Coder Social logo

amygdala / container-vm-guestbook-redis-python Goto Github PK

View Code? Open in Web Editor NEW

This project forked from googlecloudplatform/container-vm-guestbook-redis-python

0.0 3.0 0.0 92 KB

A simple guestbook example for Container VMs on GCE. Uses Redis and Python/Flask.

License: Apache License 2.0

Python 25.84% HTML 26.42% Shell 47.74%

container-vm-guestbook-redis-python's Introduction

Container VM Guestbook

This is a sample on how to use container VMs for a simple guestbook. You can read more about containers on GCE here.

There are 2 containers that get deployed into one VM:

  • A Redis database. This uses the dockerfile/redis container image.
  • A simple python application (based on Flask) that implements the guestbook. The source is included at the root of this repo and is pushed to google/guestbook-python-redis on the Docker Index.

Launching

To launch simply have gcloud compute configured (see the Cloud SDK) with a GCE enabled project and your credentials. There is no need to have Docker installed on your workstation/development machine.

Either run the start-containers.sh shell script or run the following commands:

VM_NAME=container-vm-guestbook
gcloud compute firewalls create ${VM_NAME}-www --allow tcp:80 --target-tags ${VM_NAME}

gcloud compute instances create ${VM_NAME} \
  --tags ${VM_NAME} \
  --zone us-central1-a  --machine-type n1-standard-1 \
  --image https://www.googleapis.com/compute/v1/projects/google-containers/global/images/container-vm \
  --metadata-from-file google-container-manifest=manifest.yaml

This will create a new VM called containervm-guestbook running the 2 containers described above. We also open up the firewall to just this VM so that you can reach the web server running on it. The containers that are running in the VM are specified in manifest.yaml. It may take a while to get up and running as the container image must be downloaded from the docker registry.

Just hit the public IP of the VM with your web browser to access the guest book.

Restarting the containers

If you want to change the manifest and reload it, the easiest thing to do is to upload a new manifest and restart the VM hosting the containers.

You can run the restart-containers.sh script or run the following commands:

gcloud compute instances add-metadata --zone us-central1-a ${VM_NAME} \
  --metadata-from-file google-container-manifest=manifest.yaml

gcloud compute instances reset --zone us-central1-a ${VM_NAME}

Cleaning up

To clean up the VM, simply run stop-containers.sh. This will delete the VM and its root disk. Any data on the VM will be lost!

Or run the following commands:

gcloud compute firewalls delete --quiet ${VM_NAME}-www

gcloud compute instances delete --quiet --zone=us-central1-a ${VM_NAME}

Modifying the application

  1. Have Docker installed on a development workstation. You can use a GCE instance for this. See instructions here.

  2. Build your application with (this project should match where you plan to create the VM):

    docker build -t gcr.io/<your-project-id>/guestbook-python-redis .
    
  3. Push your application to the Google Container Registry with:

    gcloud preview docker push gcr.io/<your-project-id>/guestbook-python-redis
    
  4. Modify manifest.yaml to refer to use gcr.io/<your-project-id>/guestbook-python-redis in place of google/guestbook-python-redis.

  5. Start up a new VM with start-containers.sh or reload you rexisting one with restart-containers.sh.

container-vm-guestbook-redis-python's People

Contributors

amygdala avatar brendandburns avatar fredr avatar jbeda avatar mattmoor avatar mikejeffrey avatar vtereshko avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.