Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Yoshi Yamaguchi 2019-06-13 11:52:40 +08:00
commit e967007c5a
19 changed files with 85 additions and 41 deletions

View file

@ -272,6 +272,7 @@ resources.
- [Day 3 Keynote](https://youtu.be/JQPOPV_VH5w?t=815) showing Stackdriver
APM (Tracing, Code Search, Profiler, Google Cloud Build)
- [Introduction to Service Management with Istio](https://www.youtube.com/watch?v=wCJrdKdD6UM&feature=youtu.be&t=586)
- [KubeCon EU 2019 - Reinventing Networking: A Deep Dive into Istio's Multicluster Gateways - Steve Dake, Independent](https://youtu.be/-t2BfT59zJA?t=982)
---

View file

@ -37,6 +37,8 @@ spec:
exec:
command: ["/bin/grpc_health_probe", "-addr=:5050"]
env:
- name: PORT
value: "5050"
- name: PRODUCT_CATALOG_SERVICE_ADDR
value: "productcatalogservice:3550"
- name: SHIPPING_SERVICE_ADDR

View file

@ -32,6 +32,9 @@ spec:
ports:
- name: grpc
containerPort: 7000
env:
- name: PORT
value: "7000"
readinessProbe:
exec:
command: ["/bin/grpc_health_probe", "-addr=:7000"]

View file

@ -31,6 +31,9 @@ spec:
image: emailservice
ports:
- containerPort: 8080
env:
- name: PORT
value: "8080"
readinessProbe:
periodSeconds: 5
exec:

View file

@ -47,6 +47,8 @@ spec:
- name: "Cookie"
value: "shop_session-id=x-liveness-probe"
env:
- name: PORT
value: "8080"
- name: PRODUCT_CATALOG_SERVICE_ADDR
value: "productcatalogservice:3550"
- name: CURRENCY_SERVICE_ADDR

View file

@ -31,6 +31,9 @@ spec:
image: paymentservice
ports:
- containerPort: 50051
env:
- name: PORT
value: "50051"
readinessProbe:
exec:
command: ["/bin/grpc_health_probe", "-addr=:50051"]

View file

@ -31,6 +31,9 @@ spec:
image: productcatalogservice
ports:
- containerPort: 3550
env:
- name: PORT
value: "3550"
readinessProbe:
exec:
command: ["/bin/grpc_health_probe", "-addr=:3550"]

View file

@ -40,6 +40,8 @@ spec:
exec:
command: ["/bin/grpc_health_probe", "-addr=:8080"]
env:
- name: PORT
value: "8080"
- name: PRODUCT_CATALOG_SERVICE_ADDR
value: "productcatalogservice:3550"
- name: ENABLE_PROFILER

View file

@ -30,6 +30,9 @@ spec:
image: shippingservice
ports:
- containerPort: 50051
env:
- name: PORT
value: "50051"
readinessProbe:
periodSeconds: 5
exec:

View file

@ -48,21 +48,6 @@ spec:
number: 80
---
apiVersion: networking.istio.io/v1alpha3
kind: ServiceEntry
metadata:
name: currency-provider-external
spec:
hosts:
- www.ecb.europa.eu
ports:
- number: 80
name: http
protocol: HTTP
- number: 443
name: https
protocol: HTTPS
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: frontend

View file

@ -32,9 +32,12 @@ spec:
terminationGracePeriodSeconds: 5
containers:
- name: server
image: gcr.io/google-samples/microservices-demo/emailservice:v0.1.0
image: gcr.io/google-samples/microservices-demo/emailservice:v0.1.1
ports:
- containerPort: 8080
env:
- name: PORT
value: "8080"
readinessProbe:
periodSeconds: 5
exec:
@ -43,6 +46,9 @@ spec:
periodSeconds: 5
exec:
command: ["/bin/grpc_health_probe", "-addr=:8080"]
env:
- name: ENABLE_PROFILER
value: "0"
resources:
requests:
cpu: 100m
@ -79,7 +85,7 @@ spec:
spec:
containers:
- name: server
image: gcr.io/google-samples/microservices-demo/checkoutservice:v0.1.0
image: gcr.io/google-samples/microservices-demo/checkoutservice:v0.1.1
ports:
- containerPort: 5050
readinessProbe:
@ -89,6 +95,8 @@ spec:
exec:
command: ["/bin/grpc_health_probe", "-addr=:5050"]
env:
- name: PORT
value: "5050"
- name: PRODUCT_CATALOG_SERVICE_ADDR
value: "productcatalogservice:3550"
- name: SHIPPING_SERVICE_ADDR
@ -140,7 +148,7 @@ spec:
terminationGracePeriodSeconds: 5
containers:
- name: server
image: gcr.io/google-samples/microservices-demo/recommendationservice:v0.1.0
image: gcr.io/google-samples/microservices-demo/recommendationservice:v0.1.1
ports:
- containerPort: 8080
readinessProbe:
@ -152,8 +160,12 @@ spec:
exec:
command: ["/bin/grpc_health_probe", "-addr=:8080"]
env:
- name: PORT
value: "8080"
- name: PRODUCT_CATALOG_SERVICE_ADDR
value: "productcatalogservice:3550"
- name: ENABLE_PROFILER
value: "0"
resources:
requests:
cpu: 100m
@ -190,7 +202,7 @@ spec:
spec:
containers:
- name: server
image: gcr.io/google-samples/microservices-demo/frontend:v0.1.0
image: gcr.io/google-samples/microservices-demo/frontend:v0.1.1
ports:
- containerPort: 8080
readinessProbe:
@ -210,6 +222,8 @@ spec:
- name: "Cookie"
value: "shop_session-id=x-liveness-probe"
env:
- name: PORT
value: "8080"
- name: PRODUCT_CATALOG_SERVICE_ADDR
value: "productcatalogservice:3550"
- name: CURRENCY_SERVICE_ADDR
@ -276,9 +290,12 @@ spec:
terminationGracePeriodSeconds: 5
containers:
- name: server
image: gcr.io/google-samples/microservices-demo/paymentservice:v0.1.0
image: gcr.io/google-samples/microservices-demo/paymentservice:v0.1.1
ports:
- containerPort: 50051
env:
- name: PORT
value: "50051"
readinessProbe:
exec:
command: ["/bin/grpc_health_probe", "-addr=:50051"]
@ -322,9 +339,12 @@ spec:
terminationGracePeriodSeconds: 5
containers:
- name: server
image: gcr.io/google-samples/microservices-demo/productcatalogservice:v0.1.0
image: gcr.io/google-samples/microservices-demo/productcatalogservice:v0.1.1
ports:
- containerPort: 3550
env:
- name: PORT
value: "3550"
readinessProbe:
exec:
command: ["/bin/grpc_health_probe", "-addr=:3550"]
@ -371,7 +391,7 @@ spec:
terminationGracePeriodSeconds: 5
containers:
- name: server
image: gcr.io/google-samples/microservices-demo/cartservice:v0.1.0
image: gcr.io/google-samples/microservices-demo/cartservice:v0.1.1
ports:
- containerPort: 7070
env:
@ -440,7 +460,7 @@ spec:
value: "frontend:80"
containers:
- name: main
image: gcr.io/google-samples/microservices-demo/loadgenerator:v0.1.0
image: gcr.io/google-samples/microservices-demo/loadgenerator:v0.1.1
env:
- name: FRONTEND_ADDR
value: "frontend:80"
@ -470,10 +490,13 @@ spec:
terminationGracePeriodSeconds: 5
containers:
- name: server
image: gcr.io/google-samples/microservices-demo/currencyservice:v0.1.0
image: gcr.io/google-samples/microservices-demo/currencyservice:v0.1.1
ports:
- name: grpc
containerPort: 7000
env:
- name: PORT
value: "7000"
readinessProbe:
exec:
command: ["/bin/grpc_health_probe", "-addr=:7000"]
@ -516,9 +539,12 @@ spec:
spec:
containers:
- name: server
image: gcr.io/google-samples/microservices-demo/shippingservice:v0.1.0
image: gcr.io/google-samples/microservices-demo/shippingservice:v0.1.1
ports:
- containerPort: 50051
env:
- name: PORT
value: "50051"
readinessProbe:
periodSeconds: 5
exec:
@ -619,7 +645,7 @@ spec:
terminationGracePeriodSeconds: 5
containers:
- name: server
image: gcr.io/google-samples/microservices-demo/adservice:v0.1.0
image: gcr.io/google-samples/microservices-demo/adservice:v0.1.1
ports:
- containerPort: 9555
env:

View file

@ -11,9 +11,16 @@ COPY . .
RUN chmod +x gradlew
RUN ./gradlew installDist
FROM openjdk:8-alpine
FROM openjdk:8-slim
RUN apk add --no-cache libc6-compat
# Download Stackdriver Profiler Java agent
RUN apt-get -y update && apt-get install -qqy \
wget \
&& rm -rf /var/lib/apt/lists/*
RUN mkdir -p /opt/cprof && \
wget -q -O- https://storage.googleapis.com/cloud-profiler/java/latest/profiler_java_agent.tar.gz \
| tar xzv -C /opt/cprof && \
rm -rf profiler_java_agent.tar.gz
RUN GRPC_HEALTH_PROBE_VERSION=v0.2.1 && \
wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64 && \

View file

@ -118,7 +118,8 @@ task adService(type: CreateStartScripts) {
outputDir = new File(project.buildDir, 'tmp')
classpath = jar.outputs.files + project.configurations.runtime
defaultJvmOpts =
["-Dlog4j2.contextDataInjector=io.opencensus.contrib.logcorrelation.log4j2.OpenCensusTraceContextDataInjector"]
["-Dlog4j2.contextDataInjector=io.opencensus.contrib.logcorrelation.log4j2.OpenCensusTraceContextDataInjector",
"-agentpath:/opt/cprof/profiler_java_agent.so=-cprof_service=adservice,-cprof_service_version=1.0.0"]
}
task adServiceClient(type: CreateStartScripts) {
@ -127,7 +128,8 @@ task adServiceClient(type: CreateStartScripts) {
outputDir = new File(project.buildDir, 'tmp')
classpath = jar.outputs.files + project.configurations.runtime
defaultJvmOpts =
["-Dlog4j2.contextDataInjector=io.opencensus.contrib.logcorrelation.log4j2.OpenCensusTraceContextDataInjector"]
["-Dlog4j2.contextDataInjector=io.opencensus.contrib.logcorrelation.log4j2.OpenCensusTraceContextDataInjector",
"-agentpath:/opt/cprof/profiler_java_agent.so=-cprof_service=adserviceclient,-cprof_service_version=1.0.0"]
}
applicationDistribution.into('bin') {

View file

@ -46,7 +46,7 @@ const request = {
};
function _moneyToString (m) {
return `${m.units}.${leftPad(m.nanos, 9, '0')} ${m.currency_code}`;
return `${m.units}.${m.nanos.toString().padStart(9,'0')} ${m.currency_code}`;
}
client.getSupportedCurrencies({}, (err, response) => {

View file

@ -16,7 +16,6 @@
"async": "^1.5.2",
"google-protobuf": "^3.0.0",
"grpc": "^1.0.0",
"left-pad": "^1.3.0",
"pino": "^5.6.2",
"request": "^2.87.0",
"xml2js": "^0.4.19"

View file

@ -36,7 +36,7 @@ const protoLoader = require('@grpc/proto-loader');
const MAIN_PROTO_PATH = path.join(__dirname, './proto/demo.proto');
const HEALTH_PROTO_PATH = path.join(__dirname, './proto/grpc/health/v1/health.proto');
const PORT = 7000;
const PORT = process.env.PORT;
const shopProto = _loadProto(MAIN_PROTO_PATH).hipstershop;
const healthProto = _loadProto(HEALTH_PROTO_PATH).grpc.health.v1;

View file

@ -27,7 +27,7 @@ const logger = pino({
});
class HipsterShopServer {
constructor (protoRoot, port = HipsterShopServer.DEFAULT_PORT) {
constructor (protoRoot, port = HipsterShopServer.PORT) {
this.port = port;
this.packages = {
@ -99,6 +99,6 @@ class HipsterShopServer {
}
}
HipsterShopServer.DEFAULT_PORT = 50051;
HipsterShopServer.PORT = process.env.PORT;
module.exports = HipsterShopServer;

View file

@ -50,7 +50,7 @@ var (
log *logrus.Logger
extraLatency time.Duration
port = flag.Int("port", 3550, "port to listen at")
port = "3550"
reloadCatalog bool
)
@ -106,13 +106,16 @@ func main() {
}
}()
log.Infof("starting grpc server at :%d", *port)
run(*port)
if os.Getenv("PORT") != "" {
port = os.Getenv("PORT")
}
log.Infof("starting grpc server at :%s", port)
run(port)
select {}
}
func run(port int) string {
l, err := net.Listen("tcp", fmt.Sprintf(":%d", port))
func run(port string) string {
l, err := net.Listen("tcp", fmt.Sprintf(":%s", port))
if err != nil {
log.Fatal(err)
}

View file

@ -60,7 +60,7 @@ func main() {
go initProfiling("shippingservice", "1.0.0")
port := defaultPort
if value, ok := os.LookupEnv("APP_PORT"); ok {
if value, ok := os.LookupEnv("PORT"); ok {
port = value
}
port = fmt.Sprintf(":%s", port)