Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making yaml files templates, updating readme and makefile. #18

Merged
merged 1 commit into from
Jan 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions optional-container-engine/Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
GCLOUD_PROJECT:=$(shell gcloud config list project --format="value(core.project)")

.PHONY: all
all: deploy

.PHONY: create-cluster
create-cluster:
gcloud container clusters create bookshelf \
--scope "https://www.googleapis.com/auth/userinfo.email","cloud-platform"
gcloud container clusters get-credentials bookshelf

.PHONY: create-bucket
create-bucket:
Expand Down
30 changes: 25 additions & 5 deletions optional-container-engine/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,32 +28,48 @@ Create a cluster for the bookshelf application:

The scopes specified in the `--scope` argument allows nodes in the cluster to access Google Cloud Platform APIs, such as the Cloud Datastore API.

Alternatively, you can use make:

make create-cluster

## Create a Cloud Storage bucket

The bookshelf application uses [Google Cloud Storage](https://cloud.google.com/storage) to store image files. Create a bucket for your project:

gsutil mb gs://<your-project-id>
gsutil defacl set public-read gs://<your-project-id>

Alternatively, you can use make:

make create-bucket

## Update config.py

Modify config.py and enter your Cloud Project ID into the `PROJECT_ID` and `CLOUD_STORAGE_BUCKET` field. The remaining configuration values are only needed if you wish to use a different database or if you wish to enable log-in via oauth2, which requires a domain name.

## Build the bookshelf container

Before the application can be deployed to Container Engine, you will need build and push the image to [Google Container Registry](https://cloud.google.com/container-registry/).
Before the application can be deployed to Container Engine, you will need build and push the image to [Google Container Registry](https://cloud.google.com/container-registry/).

docker build -t gcr.io/your-project-id/bookshelf .
gcloud docker push gcr.io/your-project-id/bookshelf

## Deploy to Bookshelf frontend
Alternativel,y you can use make:

make push

## Deploy the bookshelf frontend

The bookshelf app has two distinct "tiers". The frontend serves a web interface to create and manage books, while the worker handles fetching book information from the Google Books API.

`bookshelf-frontend.yaml` contains the Kubernetes resource definitions to deploy the frontend. **Update this file with your Project ID**, then use `kubectl` to create these resources on the cluster:
Update `bookshelf-frontend.yaml` with your Project ID or use `make template`. This file contains the Kubernetes resource definitions to deploy the frontend. You can use `kubectl` to create these resources on the cluster:

kubectl create -f bookshelf-frontend.yaml

Alternatively, you can use make:

make deploy-frontend

Once the resources are created, there should be 3 `bookshelf-frontend` pods on the cluster. To see the pods and ensure that they are running:

kubectl get pods
Expand All @@ -68,10 +84,14 @@ Once the pods are ready, you can get the public IP address of the load balancer:

You can then browse to the public IP address in your browser to see the bookshelf application.

# Deploy worker
## Deploy worker

`bookshelf-worker.yaml` contains the Kubernetes resource definitions to deploy the worker. The worker doesn't need to serve web traffic or expose any ports, so it has significantly less configuration than the frontend. **Update `bookshelf-worker.yaml` file with your Project ID**, then use `kubectl` to create these resources on the cluster:
Update `bookshelf-worker.yaml` with your Project ID or use `make template`. This file contains the Kubernetes resource definitions to deploy the worker. The worker doesn't need to serve web traffic or expose any ports, so it has significantly less configuration than the frontend. You can use `kubectl` to create these resources on the cluster:

kubectl create -f bookshelf-worker.yaml

Alternatively, you can use make:

make deploy-backend

Once again, use `kubectl get pods` to check the status of the worker pods. Once the worker pods are up and running, you should be able to create books on the frontend and the workers will handle updating book information in the background.