From 2283bd2921252096b2dae692b1ced6fd7f874f42 Mon Sep 17 00:00:00 2001 From: mukundha Date: Wed, 17 Oct 2018 09:32:02 +0100 Subject: [PATCH 1/2] Fix for the issue: https://github.com/GoogleCloudPlatform/microservices-demo/issues/80 Updated server.js to use Env variable, instead of hardcoded currency URL Hosting a currency service, that is serving via http updated the manifests to include the env and egress whitelisting --- istio-manifests/whitelist-egress-currencyprovider.yaml | 1 + kubernetes-manifests/currencyservice.yaml | 6 +++++- src/currencyservice/client.js | 2 +- src/currencyservice/server.js | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/istio-manifests/whitelist-egress-currencyprovider.yaml b/istio-manifests/whitelist-egress-currencyprovider.yaml index 8523fc0..0d3d31b 100644 --- a/istio-manifests/whitelist-egress-currencyprovider.yaml +++ b/istio-manifests/whitelist-egress-currencyprovider.yaml @@ -19,6 +19,7 @@ metadata: spec: hosts: - www.ecb.europa.eu + - amer-demo4-test.apigee.net ports: - number: 80 name: http diff --git a/kubernetes-manifests/currencyservice.yaml b/kubernetes-manifests/currencyservice.yaml index b344b1a..bcb012b 100644 --- a/kubernetes-manifests/currencyservice.yaml +++ b/kubernetes-manifests/currencyservice.yaml @@ -25,7 +25,8 @@ spec: terminationGracePeriodSeconds: 5 containers: - name: server - image: gcr.io/microservices-demo-app/currencyservice + #image: gcr.io/microservices-demo-app/currencyservice + image: us.gcr.io/hipster-apim-demo/currencyservice ports: - name: grpc containerPort: 7000 @@ -42,6 +43,9 @@ spec: limits: cpu: 200m memory: 128Mi + env: + - name: DATA_URL + value: "http://amer-demo4-test.apigee.net/currency-service" --- apiVersion: v1 kind: Service diff --git a/src/currencyservice/client.js b/src/currencyservice/client.js index f381dc8..3dbf7c4 100644 --- a/src/currencyservice/client.js +++ b/src/currencyservice/client.js @@ -61,6 +61,6 @@ client.convert(request, (err, response) => { if (err) { logger.error(`Error in convert: ${err}`); } else { - logger.log(`Convert: ${_moneyToString(request.from)} to ${_moneyToString(response)}`); + logger.info(`Convert: ${_moneyToString(request.from)} to ${_moneyToString(response)}`); } }); diff --git a/src/currencyservice/server.js b/src/currencyservice/server.js index 633078c..a101788 100644 --- a/src/currencyservice/server.js +++ b/src/currencyservice/server.js @@ -39,7 +39,7 @@ 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 DATA_URL = 'http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml'; +const DATA_URL = process.env.DATA_URL //'http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml'; const shopProto = _loadProto(MAIN_PROTO_PATH).hipstershop; const healthProto = _loadProto(HEALTH_PROTO_PATH).grpc.health.v1; From fdb614e2add77eaa04da077834b13442e01affa2 Mon Sep 17 00:00:00 2001 From: mukundha Date: Wed, 17 Oct 2018 09:35:09 +0100 Subject: [PATCH 2/2] remove test image --- kubernetes-manifests/currencyservice.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kubernetes-manifests/currencyservice.yaml b/kubernetes-manifests/currencyservice.yaml index bcb012b..5309bda 100644 --- a/kubernetes-manifests/currencyservice.yaml +++ b/kubernetes-manifests/currencyservice.yaml @@ -25,8 +25,7 @@ spec: terminationGracePeriodSeconds: 5 containers: - name: server - #image: gcr.io/microservices-demo-app/currencyservice - image: us.gcr.io/hipster-apim-demo/currencyservice + image: gcr.io/microservices-demo-app/currencyservice ports: - name: grpc containerPort: 7000