Skip to content

Commit

Permalink
[Tour Of Beam] Playground Router GRPC API host (apache#24542)
Browse files Browse the repository at this point in the history
* aio

* fix

* README

* adjust

* -redis

* reset values

* -redis
  • Loading branch information
eantyshev authored Dec 8, 2022
1 parent 80980b8 commit a40e79b
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 2 deletions.
18 changes: 16 additions & 2 deletions learning/tour-of-beam/backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,24 @@ Prerequisites:
* Cloud Functions API
* Firebase Admin API
* Secret Manager API
- existing setup of Playground backend in a project
* (output) GKE_CLUSTER_NAME (`playground` by default)
* (output) GKE_ZONE, like `us-east1-b`
- set environment variables:
* PROJECT_ID: GCP id
* REGION: the region, "us-central1" fe
- existing setup of Playground backend in a project
* PLAYGROUND_ROUTER_HOST: router serving Playground Router GRPC API

__To discover Router host:__
```
# setup kubectl credentials
gcloud container clusters get-credentials $GKE_CLUSTER_NAME --zone $GKE_ZONE --project $PROJECT_ID
# get external host:port of a backend-router-grpc service
PLAYGROUND_ROUTER_HOST=$(kubectl get svc -l "app=backend-router-grpc" \
-o jsonpath='{.items[0].status.loadBalancer.ingress[0].ip}:{.items[0].spec.ports[0].port}'\
)
```

1. Deploy Datastore indexes (but don't delete existing Playground indexes!)
```
Expand All @@ -103,7 +117,7 @@ for endpoint in getSdkList getContentTree getUnitContent getUserProgress postUni
gcloud functions deploy $endpoint --entry-point $endpoint \
--region $REGION --runtime go116 --allow-unauthenticated \
--trigger-http \
--set-env-vars="DATASTORE_PROJECT_ID=$PROJECT_ID,GOOGLE_PROJECT_ID=$PROJECT_ID"
--set-env-vars="DATASTORE_PROJECT_ID=$PROJECT_ID,GOOGLE_PROJECT_ID=$PROJECT_ID,PLAYGROUND_ROUTER_HOST=$PLAYGROUND_ROUTER_HOST"
done
```
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You 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.

apiVersion: apps/v1
kind: Deployment
metadata:
name: playground-router-grpc
labels:
app: backend-router-grpc
type: backend
spec:
template:
metadata:
name: playground
labels:
app: backend-router-grpc
type: backend
spec:
containers:
- name: playground-backend-router-grpc
image: "{{ .Values.registry}}/{{ .Values.image.router_image }}:{{ .Values.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
- name: GOOGLE_CLOUD_PROJECT
value: {{ .Values.project_id }}
- name: CACHE_TYPE
value: "remote"
- name: CACHE_ADDRESS
value: {{ .Values.redis_ip }}
- name: PROTOCOL_TYPE
value: TCP
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: backend-router-grpc
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You 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.

apiVersion: v1
kind: Service
metadata:
labels:
app: backend-router-grpc
type: backend
name: playground-router-grpc-service
spec:
type: LoadBalancer
selector:
app: backend-router-grpc
ports:
- name: grpc
port: 8080
protocol: TCP
targetPort: 8080

0 comments on commit a40e79b

Please sign in to comment.