Skip to content

Commit

Permalink
Review Comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffmendoza committed Feb 8, 2017
1 parent c8b9224 commit 8289379
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 27 deletions.
14 changes: 14 additions & 0 deletions endpoints/getting-started-grpc/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2017 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# https://github.com/GoogleCloudPlatform/openjdk-runtime
FROM gcr.io/google_appengine/openjdk8

Expand Down
37 changes: 21 additions & 16 deletions endpoints/getting-started-grpc/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
# Endpoints Getting Started with gRPC & Java Quickstart

It is assumed that you have a working gRPC and Java environment.
It is assumed that you have a
working
[gRPC](http://www.grpc.io/docs/),
[ProtoBuf](https://github.com/google/protobuf#protocol-compiler-installation) and
Java environment, a Google Cloud account
and [SDK](https://cloud.google.com/sdk/) configured.

1. Build the code:

```
```bash
./gradlew build
```

1. Test running the code, optional:

```
```bash
# In the background or another terminal run the server:
java -jar server/build/libs/server.jar
Expand All @@ -23,15 +28,15 @@ It is assumed that you have a working gRPC and Java environment.

1. Generate the `out.pb` from the proto file.

```
```bash
protoc --include_imports --include_source_info api/src/main/proto/helloworld.proto --descriptor_set_out out.pb
```

1. Edit, `api_config.yaml`. Replace `MY_PROJECT_ID` with your project id.

1. Deploy your service config to Service Management:

```
```bash
gcloud service-management deploy out.pb api_config.yaml
# The Config ID should be printed out, looks like: 2017-02-01r0, remember this
Expand All @@ -46,7 +51,7 @@ It is assumed that you have a working gRPC and Java environment.
1. Build a docker image for your gRPC server, store in your Registry
```
```bash
gcloud container builds submit --tag gcr.io/${GCLOUD_PROJECT}/java-grpc-hello:1.0 .
```
Expand All @@ -56,29 +61,29 @@ It is assumed that you have a working gRPC and Java environment.
1. Create your instance and ssh in.
```
```bash
gcloud compute instances create grpc-host --image-family gci-stable --image-project google-containers --tags=http-server
gcloud compute ssh grpc-host
```
1. Set some variables to make commands easier
```
```bash
GCLOUD_PROJECT=$(curl -s "http://metadata.google.internal/computeMetadata/v1/project/project-id" -H "Metadata-Flavor: Google")
SERVICE_NAME=hellogrpc.endpoints.${GCLOUD_PROJECT}.cloud.goog
SERVICE_CONFIG_ID=<Your Config ID>
```
1. Pull your credentials to access Container Registry, and run your gRPC server container
```
```bash
/usr/share/google/dockercfg_update.sh
docker run -d --name=grpc-hello gcr.io/${GCLOUD_PROJECT}/java-grpc-hello:1.0
```
1. Run the Endpoints proxy
```
```bash
docker run --detach --name=esp \
-p 80:9000 \
--link=grpc-hello:grpc-hello \
Expand All @@ -91,40 +96,40 @@ It is assumed that you have a working gRPC and Java environment.
1. Back on your local machine, get the external IP of your GCE instance.
```
```bash
gcloud compute instances list
```
1. Run the client
```
```bash
java -jar client/build/libs/client.jar --host <IP of GCE Instance>:80 --api_key <API Key from Console>
```
### GKE
1. Create a cluster
```
```bash
gcloud container clusters create my-cluster
```
1. Edit `container-engine.yaml`. Replace `SERVICE_NAME`, `SERVICE_CONFIG_ID`, and `GCLOUD_PROJECT` with your values.
1. Deploy to GKE
```
```bash
kubectl create -f ./container-engine.yaml
```
1. Get IP of load balancer, run until you see an External IP.
```
```bash
kubectl get svc grpc-hello
```
1. Run the client
```
```bash
java -jar client/build/libs/client.jar --host <IP of GKE LoadBalancer>:80 --api_key <API Key from Console>
```
2 changes: 1 addition & 1 deletion endpoints/getting-started-grpc/api/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017 Google Inc. All Rights Reserved.
// Copyright 2017 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// Copyright 2015, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
Expand Down
5 changes: 2 additions & 3 deletions endpoints/getting-started-grpc/api_config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2017 Google Inc. All Rights Reserved.
# Copyright 2017 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.


#
# An example API configuration.
#
Expand All @@ -27,7 +26,7 @@ config_version: 3
#
# Name of the service configuration.
#
name: hellogrpc.endpoints.MY_PROJECT_ID.cloud.goog
name: hellogrpc.endpoints.jeffs-test-deploy-1.cloud.goog

#
# API title to appear in the user interface (Google Cloud Console).
Expand Down
2 changes: 1 addition & 1 deletion endpoints/getting-started-grpc/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017 Google Inc. All Rights Reserved.
// Copyright 2017 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion endpoints/getting-started-grpc/client/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017 Google Inc. All Rights Reserved.
// Copyright 2017 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015, Google Inc. All rights reserved.
* Copyright 2015, Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
Expand Down
2 changes: 1 addition & 1 deletion endpoints/getting-started-grpc/container-engine.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2017 Google Inc. All Rights Reserved.
# Copyright 2017 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion endpoints/getting-started-grpc/server/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017 Google Inc. All Rights Reserved.
// Copyright 2017 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015, Google Inc. All rights reserved.
* Copyright 2015, Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
Expand Down

0 comments on commit 8289379

Please sign in to comment.