|
1 | 1 | # Google Cloud Endpoints
|
2 | 2 | This sample demonstrates how to use Google Cloud Endpoints using Java.
|
3 | 3 |
|
4 |
| -## Pre-deployment steps |
| 4 | +For a complete walkthrough showing how to run this sample in different environments, see the [Google Cloud Endpoints Quickstarts](https://cloud.google.com/endpoints/docs/quickstarts). |
5 | 5 |
|
6 |
| -### Edit and deploy the OpenAPI specification |
| 6 | +## Deploying to Production |
7 | 7 |
|
8 |
| -1. Open the [src/main/appengine/swagger.yaml](src/main/appengine/swagger.yaml) file in your favorite editor, and replace the YOUR-PROJECT-ID `host` line with your actual Google Cloud Platform project id. |
| 8 | +See the [Google Cloud Endpoints Quickstarts](https://cloud.google.com/endpoints/docs/quickstarts). |
9 | 9 |
|
10 |
| -2. Deploy the service configuration. For information on how to do this, see the Configuring Endpoints and Deploying the Sample API sections [here](https://cloud.google.com/endpoints/docs/quickstart-container-engine). |
11 |
| - |
12 |
| -## Deploying to Google App Engine Flexible Environment |
13 |
| - |
14 |
| -### Running locally |
15 |
| - $ mvn jetty:run |
16 |
| - |
17 |
| -### Deploying |
18 |
| - $ mvn gcloud:deploy |
19 |
| - |
20 |
| -### Calling your API |
| 10 | +## Calling your API |
21 | 11 |
|
22 | 12 | Please refer to the Google Cloud Endpoints [documentation](https://cloud.google.com/endpoints/docs/app-engine/) for App Engine Flexible Environment to learn about creating an API Key and calling your API.
|
23 |
| - |
24 |
| -## Deploying to Google Container Engine |
25 |
| - |
26 |
| -### Deploy the sample API to the GKE cluster |
27 |
| - |
28 |
| -To deploy to a cluster: |
29 |
| - |
30 |
| -For instructions on how to create a GKE cluster, please refer to the GKE [documentation](https://cloud.google.com/container-engine/docs/quickstart). |
31 |
| - |
32 |
| -1. Edit the Kubernetes configuration file called gke.yaml in this directory, replacing SERVICE_NAME and SERVICE_VERSION shown in the snippet below with the values returned when you deployed the API: |
33 |
| - |
34 |
| - ``` |
35 |
| - containers: |
36 |
| - - name: esp |
37 |
| - image: b.gcr.io/endpoints/endpoints-runtime:0.3 |
38 |
| - args: [ |
39 |
| - "-p", "8080", # the port ESP listens on |
40 |
| - "-a", "127.0.0.1:8081", # the backend address |
41 |
| - "-s", "SERVICE_NAME", |
42 |
| - "-v", "SERVICE_VERSION", |
43 |
| - ] |
44 |
| - ``` |
45 |
| -
|
46 |
| -2. Start the service using the kubectl create command: |
47 |
| -
|
48 |
| - ``` |
49 |
| - kubectl create -f gke.yaml |
50 |
| - ``` |
51 |
| -
|
52 |
| -3. Get the service's external IP address (it can take a few minutes after you start your service in the container before the external IP address is ready): |
53 |
| -
|
54 |
| - ``` |
55 |
| - kubectl get service |
56 |
| - ``` |
57 |
| -
|
58 |
| -4. [Create an API key](https://console.cloud.google.com/apis/credentials) in the API credentials page. |
59 |
| - * Click Create credentials, then select API key > Server key, then click Create. |
60 |
| - * Copy the key, then paste it into the following export statement: |
61 |
| -
|
62 |
| - ``` |
63 |
| - export ENDPOINTS_KEY=AIza... |
64 |
| - ``` |
65 |
| -
|
66 |
| -5. Test the app by making a call to the EXTERNAL-IP returned in the previous step, at port 8080. For example, this curl will test the app: |
67 |
| -
|
68 |
| - ``` |
69 |
| - curl -d '{"message":"hello world"}' -H "content-type:application/json" http://[EXTERNAL-IP]/echo?key=${ENDPOINTS_KEY} |
70 |
| - ``` |
0 commit comments