updating Kubernetes hello quickstart to support endpoint env vars (#1030)

Signed-off-by: salaboy <Salaboy@gmail.com>
This commit is contained in:
salaboy 2024-06-27 19:49:22 +01:00 committed by GitHub
parent 6c1392af01
commit 2b78b3a0e0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 8 deletions

View File

@ -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}!`));

View File

@ -15,8 +15,8 @@ import os
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: