Skip to content

Commit

Permalink
updating Kubernetes hello quickstart to support endpoint env vars (#1030
Browse files Browse the repository at this point in the history
)

Signed-off-by: salaboy <Salaboy@gmail.com>
  • Loading branch information
salaboy authored Jun 27, 2024
1 parent 6c1392a commit 2b78b3a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions tutorials/hello-kubernetes/node/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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}!`));
4 changes: 2 additions & 2 deletions tutorials/hello-kubernetes/python/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 2b78b3a

Please sign in to comment.