Skip to content

Commit

Permalink
script 'get-ip' is now synchronous
Browse files Browse the repository at this point in the history
  • Loading branch information
DougReeder committed Oct 25, 2024
1 parent 43bc1a5 commit 8d0654a
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions community-edition/get_ip/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
const utils = require("../utils");
const { exec } = require('node:child_process');
const { spawnSync } = require("node:child_process");

const config = utils.readConfig();
const cmdline = `kubectl -n ${config.Namespace} get svc lb -o json`;
exec(cmdline, (error, stdout, stderr) => {
if (error) {
console.error(`exec error: ${error}`);
return;
}
const output = JSON.parse(stdout);
console.log("load balancer external IP address:", output.status.loadBalancer.ingress[0].ip);
});
const { stdout } = spawnSync(
"kubectl",
["-n", config.Namespace, "get", "svc", "lb", "-o", "json"],
{ stdio: ["pipe", "pipe", "inherit"] }
);
const output = JSON.parse(stdout);
console.log(
"load balancer external IP address:",
output.status.loadBalancer.ingress[0].ip
);

0 comments on commit 8d0654a

Please sign in to comment.