Skip to content

Commit 8289379

Browse files
committed
Review Comments.
1 parent c8b9224 commit 8289379

File tree

11 files changed

+44
-27
lines changed

11 files changed

+44
-27
lines changed

endpoints/getting-started-grpc/Dockerfile

+14
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# Copyright 2017 Google Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
115
# https://github.com/GoogleCloudPlatform/openjdk-runtime
216
FROM gcr.io/google_appengine/openjdk8
317

endpoints/getting-started-grpc/README.md

+21-16
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
# Endpoints Getting Started with gRPC & Java Quickstart
22

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

510
1. Build the code:
611

7-
```
12+
```bash
813
./gradlew build
914
```
1015

1116
1. Test running the code, optional:
1217

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

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

26-
```
31+
```bash
2732
protoc --include_imports --include_source_info api/src/main/proto/helloworld.proto --descriptor_set_out out.pb
2833
```
2934

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

3237
1. Deploy your service config to Service Management:
3338

34-
```
39+
```bash
3540
gcloud service-management deploy out.pb api_config.yaml
3641
# The Config ID should be printed out, looks like: 2017-02-01r0, remember this
3742
@@ -46,7 +51,7 @@ It is assumed that you have a working gRPC and Java environment.
4651
4752
1. Build a docker image for your gRPC server, store in your Registry
4853
49-
```
54+
```bash
5055
gcloud container builds submit --tag gcr.io/${GCLOUD_PROJECT}/java-grpc-hello:1.0 .
5156
```
5257
@@ -56,29 +61,29 @@ It is assumed that you have a working gRPC and Java environment.
5661
5762
1. Create your instance and ssh in.
5863
59-
```
64+
```bash
6065
gcloud compute instances create grpc-host --image-family gci-stable --image-project google-containers --tags=http-server
6166
gcloud compute ssh grpc-host
6267
```
6368
6469
1. Set some variables to make commands easier
6570
66-
```
71+
```bash
6772
GCLOUD_PROJECT=$(curl -s "http://metadata.google.internal/computeMetadata/v1/project/project-id" -H "Metadata-Flavor: Google")
6873
SERVICE_NAME=hellogrpc.endpoints.${GCLOUD_PROJECT}.cloud.goog
6974
SERVICE_CONFIG_ID=<Your Config ID>
7075
```
7176
7277
1. Pull your credentials to access Container Registry, and run your gRPC server container
7378
74-
```
79+
```bash
7580
/usr/share/google/dockercfg_update.sh
7681
docker run -d --name=grpc-hello gcr.io/${GCLOUD_PROJECT}/java-grpc-hello:1.0
7782
```
7883
7984
1. Run the Endpoints proxy
8085
81-
```
86+
```bash
8287
docker run --detach --name=esp \
8388
-p 80:9000 \
8489
--link=grpc-hello:grpc-hello \
@@ -91,40 +96,40 @@ It is assumed that you have a working gRPC and Java environment.
9196
9297
1. Back on your local machine, get the external IP of your GCE instance.
9398
94-
```
99+
```bash
95100
gcloud compute instances list
96101
```
97102
98103
1. Run the client
99104
100-
```
105+
```bash
101106
java -jar client/build/libs/client.jar --host <IP of GCE Instance>:80 --api_key <API Key from Console>
102107
```
103108
104109
### GKE
105110
106111
1. Create a cluster
107112
108-
```
113+
```bash
109114
gcloud container clusters create my-cluster
110115
```
111116
112117
1. Edit `container-engine.yaml`. Replace `SERVICE_NAME`, `SERVICE_CONFIG_ID`, and `GCLOUD_PROJECT` with your values.
113118
114119
1. Deploy to GKE
115120
116-
```
121+
```bash
117122
kubectl create -f ./container-engine.yaml
118123
```
119124
120125
1. Get IP of load balancer, run until you see an External IP.
121126
122-
```
127+
```bash
123128
kubectl get svc grpc-hello
124129
```
125130
126131
1. Run the client
127132
128-
```
133+
```bash
129134
java -jar client/build/libs/client.jar --host <IP of GKE LoadBalancer>:80 --api_key <API Key from Console>
130135
```

endpoints/getting-started-grpc/api/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2017 Google Inc. All Rights Reserved.
1+
// Copyright 2017 Google Inc.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

endpoints/getting-started-grpc/api/src/main/proto/helloworld.proto

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// Copyright 2015, Google Inc.
2-
// All rights reserved.
32
//
43
// Redistribution and use in source and binary forms, with or without
54
// modification, are permitted provided that the following conditions are

endpoints/getting-started-grpc/api_config.yaml

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2017 Google Inc. All Rights Reserved.
1+
# Copyright 2017 Google Inc.
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -12,7 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
1615
#
1716
# An example API configuration.
1817
#
@@ -27,7 +26,7 @@ config_version: 3
2726
#
2827
# Name of the service configuration.
2928
#
30-
name: hellogrpc.endpoints.MY_PROJECT_ID.cloud.goog
29+
name: hellogrpc.endpoints.jeffs-test-deploy-1.cloud.goog
3130

3231
#
3332
# API title to appear in the user interface (Google Cloud Console).

endpoints/getting-started-grpc/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2017 Google Inc. All Rights Reserved.
1+
// Copyright 2017 Google Inc.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

endpoints/getting-started-grpc/client/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2017 Google Inc. All Rights Reserved.
1+
// Copyright 2017 Google Inc.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

endpoints/getting-started-grpc/client/src/main/java/com/google/endpoints/examples/hello/HelloWorldClient.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015, Google Inc. All rights reserved.
2+
* Copyright 2015, Google Inc.
33
*
44
* Redistribution and use in source and binary forms, with or without
55
* modification, are permitted provided that the following conditions are

endpoints/getting-started-grpc/container-engine.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2017 Google Inc. All Rights Reserved.
1+
# Copyright 2017 Google Inc.
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.

endpoints/getting-started-grpc/server/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2017 Google Inc. All Rights Reserved.
1+
// Copyright 2017 Google Inc.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

endpoints/getting-started-grpc/server/src/main/java/com/google/endpoints/examples/hello/HelloWorldServer.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015, Google Inc. All rights reserved.
2+
* Copyright 2015, Google Inc.
33
*
44
* Redistribution and use in source and binary forms, with or without
55
* modification, are permitted provided that the following conditions are

0 commit comments

Comments
 (0)