Skip to content

Commit e357ea5

Browse files
committed
ip-addr: Displays name and namespace of each load balancer
Why: If there is more than one load balancer in the cluster, the user needs to select the appropriate one.
1 parent a103d90 commit e357ea5

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

community-edition/get_ip/index.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@ if (output.items.length === 0) {
1313
process.exit(1);
1414
}
1515
for (const item of output.items) {
16-
const ipAddr = item.status.loadBalancer?.ingress?.[0]?.ip;
17-
if (ipAddr) {
18-
console.log("load balancer external IP address:", ipAddr);
16+
const name = item.metadata.name;
17+
const namespace = item.metadata.namespace;
18+
const status = item.status;
19+
const addr = status?.loadBalancer?.ingress?.[0]?.ip || status?.loadBalancer?.ingress?.[0]?.hostname;
20+
if (addr) {
21+
console.log(`load balancer “${name}” in namespace “${namespace}” external address: ${addr}`);
1922
} else {
20-
console.log("load balancer not running yet:", output.status.loadBalancer);
23+
console.log(`load balancer ${name}” in namespace “${namespace}not running yet:`, status);
2124
}
2225
}

0 commit comments

Comments
 (0)