Use env in service manifests for PORT (#212)
* fix shipping service ports * fix product catalog servicde ports * fix paymentservice ports * fix currenservice ports * fix checkoutservice ports * fix emailservice ports * fix frontend app ports * fix recommendationservice ports * fix indentation in service yaml files
This commit is contained in:
parent
876d4f966f
commit
55f5061532
12 changed files with 33 additions and 9 deletions
|
@ -37,6 +37,8 @@ spec:
|
||||||
exec:
|
exec:
|
||||||
command: ["/bin/grpc_health_probe", "-addr=:5050"]
|
command: ["/bin/grpc_health_probe", "-addr=:5050"]
|
||||||
env:
|
env:
|
||||||
|
- name: PORT
|
||||||
|
value: "5050"
|
||||||
- name: PRODUCT_CATALOG_SERVICE_ADDR
|
- name: PRODUCT_CATALOG_SERVICE_ADDR
|
||||||
value: "productcatalogservice:3550"
|
value: "productcatalogservice:3550"
|
||||||
- name: SHIPPING_SERVICE_ADDR
|
- name: SHIPPING_SERVICE_ADDR
|
||||||
|
|
|
@ -32,6 +32,9 @@ spec:
|
||||||
ports:
|
ports:
|
||||||
- name: grpc
|
- name: grpc
|
||||||
containerPort: 7000
|
containerPort: 7000
|
||||||
|
env:
|
||||||
|
- name: PORT
|
||||||
|
value: "7000"
|
||||||
readinessProbe:
|
readinessProbe:
|
||||||
exec:
|
exec:
|
||||||
command: ["/bin/grpc_health_probe", "-addr=:7000"]
|
command: ["/bin/grpc_health_probe", "-addr=:7000"]
|
||||||
|
|
|
@ -31,6 +31,9 @@ spec:
|
||||||
image: emailservice
|
image: emailservice
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 8080
|
- containerPort: 8080
|
||||||
|
env:
|
||||||
|
- name: PORT
|
||||||
|
value: "8080"
|
||||||
readinessProbe:
|
readinessProbe:
|
||||||
periodSeconds: 5
|
periodSeconds: 5
|
||||||
exec:
|
exec:
|
||||||
|
|
|
@ -47,6 +47,8 @@ spec:
|
||||||
- name: "Cookie"
|
- name: "Cookie"
|
||||||
value: "shop_session-id=x-liveness-probe"
|
value: "shop_session-id=x-liveness-probe"
|
||||||
env:
|
env:
|
||||||
|
- name: PORT
|
||||||
|
value: "8080"
|
||||||
- name: PRODUCT_CATALOG_SERVICE_ADDR
|
- name: PRODUCT_CATALOG_SERVICE_ADDR
|
||||||
value: "productcatalogservice:3550"
|
value: "productcatalogservice:3550"
|
||||||
- name: CURRENCY_SERVICE_ADDR
|
- name: CURRENCY_SERVICE_ADDR
|
||||||
|
|
|
@ -31,6 +31,9 @@ spec:
|
||||||
image: paymentservice
|
image: paymentservice
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 50051
|
- containerPort: 50051
|
||||||
|
env:
|
||||||
|
- name: PORT
|
||||||
|
value: "50051"
|
||||||
readinessProbe:
|
readinessProbe:
|
||||||
exec:
|
exec:
|
||||||
command: ["/bin/grpc_health_probe", "-addr=:50051"]
|
command: ["/bin/grpc_health_probe", "-addr=:50051"]
|
||||||
|
|
|
@ -31,6 +31,9 @@ spec:
|
||||||
image: productcatalogservice
|
image: productcatalogservice
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 3550
|
- containerPort: 3550
|
||||||
|
env:
|
||||||
|
- name: PORT
|
||||||
|
value: "3550"
|
||||||
readinessProbe:
|
readinessProbe:
|
||||||
exec:
|
exec:
|
||||||
command: ["/bin/grpc_health_probe", "-addr=:3550"]
|
command: ["/bin/grpc_health_probe", "-addr=:3550"]
|
||||||
|
|
|
@ -40,6 +40,8 @@ spec:
|
||||||
exec:
|
exec:
|
||||||
command: ["/bin/grpc_health_probe", "-addr=:8080"]
|
command: ["/bin/grpc_health_probe", "-addr=:8080"]
|
||||||
env:
|
env:
|
||||||
|
- name: PORT
|
||||||
|
value: "8080"
|
||||||
- name: PRODUCT_CATALOG_SERVICE_ADDR
|
- name: PRODUCT_CATALOG_SERVICE_ADDR
|
||||||
value: "productcatalogservice:3550"
|
value: "productcatalogservice:3550"
|
||||||
- name: ENABLE_PROFILER
|
- name: ENABLE_PROFILER
|
||||||
|
|
|
@ -30,6 +30,9 @@ spec:
|
||||||
image: shippingservice
|
image: shippingservice
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 50051
|
- containerPort: 50051
|
||||||
|
env:
|
||||||
|
- name: PORT
|
||||||
|
value: "50051"
|
||||||
readinessProbe:
|
readinessProbe:
|
||||||
periodSeconds: 5
|
periodSeconds: 5
|
||||||
exec:
|
exec:
|
||||||
|
|
|
@ -36,7 +36,7 @@ const protoLoader = require('@grpc/proto-loader');
|
||||||
const MAIN_PROTO_PATH = path.join(__dirname, './proto/demo.proto');
|
const MAIN_PROTO_PATH = path.join(__dirname, './proto/demo.proto');
|
||||||
const HEALTH_PROTO_PATH = path.join(__dirname, './proto/grpc/health/v1/health.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 shopProto = _loadProto(MAIN_PROTO_PATH).hipstershop;
|
||||||
const healthProto = _loadProto(HEALTH_PROTO_PATH).grpc.health.v1;
|
const healthProto = _loadProto(HEALTH_PROTO_PATH).grpc.health.v1;
|
||||||
|
|
|
@ -27,7 +27,7 @@ const logger = pino({
|
||||||
});
|
});
|
||||||
|
|
||||||
class HipsterShopServer {
|
class HipsterShopServer {
|
||||||
constructor (protoRoot, port = HipsterShopServer.DEFAULT_PORT) {
|
constructor (protoRoot, port = HipsterShopServer.PORT) {
|
||||||
this.port = port;
|
this.port = port;
|
||||||
|
|
||||||
this.packages = {
|
this.packages = {
|
||||||
|
@ -99,6 +99,6 @@ class HipsterShopServer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HipsterShopServer.DEFAULT_PORT = 50051;
|
HipsterShopServer.PORT = process.env.PORT;
|
||||||
|
|
||||||
module.exports = HipsterShopServer;
|
module.exports = HipsterShopServer;
|
||||||
|
|
|
@ -50,7 +50,7 @@ var (
|
||||||
log *logrus.Logger
|
log *logrus.Logger
|
||||||
extraLatency time.Duration
|
extraLatency time.Duration
|
||||||
|
|
||||||
port = flag.Int("port", 3550, "port to listen at")
|
port = "3550"
|
||||||
|
|
||||||
reloadCatalog bool
|
reloadCatalog bool
|
||||||
)
|
)
|
||||||
|
@ -106,13 +106,16 @@ func main() {
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
log.Infof("starting grpc server at :%d", *port)
|
if os.Getenv("PORT") != "" {
|
||||||
run(*port)
|
port = os.Getenv("PORT")
|
||||||
|
}
|
||||||
|
log.Infof("starting grpc server at :%s", port)
|
||||||
|
run(port)
|
||||||
select {}
|
select {}
|
||||||
}
|
}
|
||||||
|
|
||||||
func run(port int) string {
|
func run(port string) string {
|
||||||
l, err := net.Listen("tcp", fmt.Sprintf(":%d", port))
|
l, err := net.Listen("tcp", fmt.Sprintf(":%s", port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ func main() {
|
||||||
go initProfiling("shippingservice", "1.0.0")
|
go initProfiling("shippingservice", "1.0.0")
|
||||||
|
|
||||||
port := defaultPort
|
port := defaultPort
|
||||||
if value, ok := os.LookupEnv("APP_PORT"); ok {
|
if value, ok := os.LookupEnv("PORT"); ok {
|
||||||
port = value
|
port = value
|
||||||
}
|
}
|
||||||
port = fmt.Sprintf(":%s", port)
|
port = fmt.Sprintf(":%s", port)
|
||||||
|
|
Loading…
Add table
Reference in a new issue