From 8289379ba75d546caa2d6427419e578e335bb43b Mon Sep 17 00:00:00 2001 From: Jeff Mendoza Date: Wed, 8 Feb 2017 09:44:00 -0800 Subject: [PATCH] Review Comments. --- endpoints/getting-started-grpc/Dockerfile | 14 +++++++ endpoints/getting-started-grpc/README.md | 37 +++++++++++-------- .../getting-started-grpc/api/build.gradle | 2 +- .../api/src/main/proto/helloworld.proto | 1 - .../getting-started-grpc/api_config.yaml | 5 +-- endpoints/getting-started-grpc/build.gradle | 2 +- .../getting-started-grpc/client/build.gradle | 2 +- .../examples/hello/HelloWorldClient.java | 2 +- .../container-engine.yaml | 2 +- .../getting-started-grpc/server/build.gradle | 2 +- .../examples/hello/HelloWorldServer.java | 2 +- 11 files changed, 44 insertions(+), 27 deletions(-) diff --git a/endpoints/getting-started-grpc/Dockerfile b/endpoints/getting-started-grpc/Dockerfile index 9bb59984f06..3ed2caea49a 100644 --- a/endpoints/getting-started-grpc/Dockerfile +++ b/endpoints/getting-started-grpc/Dockerfile @@ -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 diff --git a/endpoints/getting-started-grpc/README.md b/endpoints/getting-started-grpc/README.md index 2f5ceffa851..97cd055de01 100644 --- a/endpoints/getting-started-grpc/README.md +++ b/endpoints/getting-started-grpc/README.md @@ -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 @@ -23,7 +28,7 @@ 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 ``` @@ -31,7 +36,7 @@ It is assumed that you have a working gRPC and Java environment. 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 @@ -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 . ``` @@ -56,14 +61,14 @@ 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= @@ -71,14 +76,14 @@ It is assumed that you have a working gRPC and Java environment. 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 \ @@ -91,13 +96,13 @@ 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 :80 --api_key ``` @@ -105,7 +110,7 @@ It is assumed that you have a working gRPC and Java environment. 1. Create a cluster - ``` + ```bash gcloud container clusters create my-cluster ``` @@ -113,18 +118,18 @@ It is assumed that you have a working gRPC and Java environment. 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 :80 --api_key ``` diff --git a/endpoints/getting-started-grpc/api/build.gradle b/endpoints/getting-started-grpc/api/build.gradle index 3b20eef3efc..7cc6a424e2a 100644 --- a/endpoints/getting-started-grpc/api/build.gradle +++ b/endpoints/getting-started-grpc/api/build.gradle @@ -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. diff --git a/endpoints/getting-started-grpc/api/src/main/proto/helloworld.proto b/endpoints/getting-started-grpc/api/src/main/proto/helloworld.proto index c3c3747e409..8f358ce6e26 100644 --- a/endpoints/getting-started-grpc/api/src/main/proto/helloworld.proto +++ b/endpoints/getting-started-grpc/api/src/main/proto/helloworld.proto @@ -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 diff --git a/endpoints/getting-started-grpc/api_config.yaml b/endpoints/getting-started-grpc/api_config.yaml index 02e665739ee..7d4fcf763e4 100644 --- a/endpoints/getting-started-grpc/api_config.yaml +++ b/endpoints/getting-started-grpc/api_config.yaml @@ -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. @@ -12,7 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. - # # An example API configuration. # @@ -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). diff --git a/endpoints/getting-started-grpc/build.gradle b/endpoints/getting-started-grpc/build.gradle index 671ed792282..6cf40137b01 100644 --- a/endpoints/getting-started-grpc/build.gradle +++ b/endpoints/getting-started-grpc/build.gradle @@ -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. diff --git a/endpoints/getting-started-grpc/client/build.gradle b/endpoints/getting-started-grpc/client/build.gradle index ef71e97939d..4794341f399 100644 --- a/endpoints/getting-started-grpc/client/build.gradle +++ b/endpoints/getting-started-grpc/client/build.gradle @@ -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. diff --git a/endpoints/getting-started-grpc/client/src/main/java/com/google/endpoints/examples/hello/HelloWorldClient.java b/endpoints/getting-started-grpc/client/src/main/java/com/google/endpoints/examples/hello/HelloWorldClient.java index ec0128bf6de..8c5f2d22f23 100644 --- a/endpoints/getting-started-grpc/client/src/main/java/com/google/endpoints/examples/hello/HelloWorldClient.java +++ b/endpoints/getting-started-grpc/client/src/main/java/com/google/endpoints/examples/hello/HelloWorldClient.java @@ -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 diff --git a/endpoints/getting-started-grpc/container-engine.yaml b/endpoints/getting-started-grpc/container-engine.yaml index eefa026502d..ae6563adcf6 100644 --- a/endpoints/getting-started-grpc/container-engine.yaml +++ b/endpoints/getting-started-grpc/container-engine.yaml @@ -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. diff --git a/endpoints/getting-started-grpc/server/build.gradle b/endpoints/getting-started-grpc/server/build.gradle index d9f72c0ad36..c5816792c8d 100644 --- a/endpoints/getting-started-grpc/server/build.gradle +++ b/endpoints/getting-started-grpc/server/build.gradle @@ -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. diff --git a/endpoints/getting-started-grpc/server/src/main/java/com/google/endpoints/examples/hello/HelloWorldServer.java b/endpoints/getting-started-grpc/server/src/main/java/com/google/endpoints/examples/hello/HelloWorldServer.java index 28889a54004..c8f5f6fd99f 100644 --- a/endpoints/getting-started-grpc/server/src/main/java/com/google/endpoints/examples/hello/HelloWorldServer.java +++ b/endpoints/getting-started-grpc/server/src/main/java/com/google/endpoints/examples/hello/HelloWorldServer.java @@ -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