From 2b78b3a0e0208005f6619ab961688148870580dd Mon Sep 17 00:00:00 2001 From: salaboy Date: Thu, 27 Jun 2024 19:49:22 +0100 Subject: [PATCH] updating Kubernetes hello quickstart to support endpoint env vars (#1030) Signed-off-by: salaboy --- tutorials/hello-kubernetes/node/app.js | 12 ++++++------ tutorials/hello-kubernetes/python/app.py | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tutorials/hello-kubernetes/node/app.js b/tutorials/hello-kubernetes/node/app.js index 68fe0dc4e..996139602 100644 --- a/tutorials/hello-kubernetes/node/app.js +++ b/tutorials/hello-kubernetes/node/app.js @@ -19,11 +19,11 @@ const app = express(); app.use(bodyParser.json()); // These ports are injected automatically into the container. -const daprPort = process.env.DAPR_HTTP_PORT ?? "3500"; -const daprGRPCPort = process.env.DAPR_GRPC_PORT ?? "50001"; +const daprHttpEndpoint = process.env.DAPR_HTTP_ENDPOINT ?? "http://localhost:3500"; +const daprGRPCEndpoint = process.env.DAPR_GRPC_ENDPOINT ?? "http://localhost:50001"; const stateStoreName = process.env.STATE_STORE_NAME ?? "statestore"; -const stateUrl = `http://localhost:${daprPort}/v1.0/state/${stateStoreName}`; +const stateUrl = `${daprHttpEndpoint}/v1.0/state/${stateStoreName}`; const port = process.env.APP_PORT ?? "3000"; app.get('/order', async (_req, res) => { @@ -71,9 +71,9 @@ app.post('/neworder', async (req, res) => { }); app.get('/ports', (_req, res) => { - console.log("DAPR_HTTP_PORT: " + daprPort); - console.log("DAPR_GRPC_PORT: " + daprGRPCPort); - res.status(200).send({DAPR_HTTP_PORT: daprPort, DAPR_GRPC_PORT: daprGRPCPort }) + console.log("DAPR_HTTP_ENDPOINT: " + daprHttpEndpoint); + console.log("DAPR_GRPC_ENDPOINT: " + daprGRPCEndpoint); + res.status(200).send({DAPR_HTTP_ENDPOINT: daprHttpEndpoint, DAPR_GRPC_ENDPOINT: daprGRPCEndpoint }) }); app.listen(port, () => console.log(`Node App listening on port ${port}!`)); diff --git a/tutorials/hello-kubernetes/python/app.py b/tutorials/hello-kubernetes/python/app.py index c9264af30..cb7cbd469 100644 --- a/tutorials/hello-kubernetes/python/app.py +++ b/tutorials/hello-kubernetes/python/app.py @@ -15,8 +15,8 @@ import requests import time -dapr_port = os.getenv("DAPR_HTTP_PORT", 3500) -dapr_url = "http://localhost:{}/neworder".format(dapr_port) +dapr_http_endpoint = os.getenv("DAPR_HTTP_ENDPOINT", "http://localhost:3500") +dapr_url = "{}/neworder".format(dapr_http_endpoint) n = 0 while True: