diff --git a/gateway-vertx/src/main/java/com/redhat/cloudnative/gateway/GatewayVerticle.java b/gateway-vertx/src/main/java/com/redhat/cloudnative/gateway/GatewayVerticle.java index 147009f..126dc62 100644 --- a/gateway-vertx/src/main/java/com/redhat/cloudnative/gateway/GatewayVerticle.java +++ b/gateway-vertx/src/main/java/com/redhat/cloudnative/gateway/GatewayVerticle.java @@ -71,11 +71,21 @@ public void start() { .setDefaultPort(Integer.getInteger("inventory.api.port", 9001)))); // Cart lookup - Single cartDiscoveryRequest = HttpEndpoint.rxGetWebClient(discovery, - rec -> rec.getName().equals("cart")) - .onErrorReturn(t -> WebClient.create(vertx, new WebClientOptions() - .setDefaultHost(System.getProperty("cart.api.host", "localhost")) - .setDefaultPort(Integer.getInteger("cart.api.port", 9002)))); + Single cartDiscoveryRequest; + String cartEndpoint = System.getenv("CART_ENDPOINT_HOST"); + + if (cartEndpoint != null) { + cartDiscoveryRequest = Single.just(WebClient.create(vertx, + new WebClientOptions() + .setDefaultHost(cartEndpoint) + .setDefaultPort(80))); + } else { + cartDiscoveryRequest = HttpEndpoint.rxGetWebClient(discovery, + rec -> rec.getName().equals("cart")) + .onErrorReturn(t -> WebClient.create(vertx, new WebClientOptions() + .setDefaultHost(System.getProperty("cart.api.host", "localhost")) + .setDefaultPort(Integer.getInteger("cart.api.port", 9002)))); + } // Zip all 3 requests Single.zip(catalogDiscoveryRequest, inventoryDiscoveryRequest, cartDiscoveryRequest, (c, i, ct) -> { diff --git a/openshift/coolstore-deployment-template.yaml b/openshift/coolstore-deployment-template.yaml index 74f97b9..905a7b4 100644 --- a/openshift/coolstore-deployment-template.yaml +++ b/openshift/coolstore-deployment-template.yaml @@ -45,8 +45,8 @@ objects: valueFrom: fieldRef: fieldPath: metadata.namespace - - name: COOLSTORE_GW_ENDPOINT - value: http://gw-${HOSTNAME_SUFFIX} + - name: COOLSTORE_GW_SERVICE + value: gw - name: HOSTNAME_HTTP value: web-ui:8080 image: web-ui @@ -122,7 +122,6 @@ objects: application: coolstore component: web-ui spec: - host: web-ui-${HOSTNAME_SUFFIX} to: kind: Service name: web-ui @@ -157,10 +156,6 @@ objects: fieldPath: metadata.namespace - name: CART_ENDPOINT value: cart-${HOSTNAME_SUFFIX} - - name: INVENTORY_ENDPOINT - value: inventory-${HOSTNAME_SUFFIX} - - name: CATALOG_ENDPOINT - value: catalog-${HOSTNAME_SUFFIX} image: library/coolstore-gw:${APP_VERSION} livenessProbe: httpGet: @@ -202,7 +197,7 @@ objects: application: coolstore component: coolstore-gw hystrix.enabled: "true" - name: coolstore-gw + name: gw spec: ports: - port: 8080 @@ -213,15 +208,14 @@ objects: - apiVersion: v1 kind: Route metadata: - name: coolstore-gw + name: gw labels: application: coolstore component: coolstore-gw spec: - host: gw-${HOSTNAME_SUFFIX} to: kind: Service - name: coolstore-gw + name: gw # Catalog Service - apiVersion: v1 kind: DeploymentConfig @@ -337,7 +331,6 @@ objects: component: catalog name: catalog spec: - host: catalog-${HOSTNAME_SUFFIX} to: kind: Service name: catalog @@ -576,7 +569,6 @@ objects: component: cart name: cart spec: - host: cart-${HOSTNAME_SUFFIX} to: kind: Service name: cart @@ -716,7 +708,6 @@ objects: component: inventory name: inventory spec: - host: inventory-${HOSTNAME_SUFFIX} to: kind: Service name: inventory