1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Issue-772: Add LoadBalancer information to the Ingress view

Add a new LoadBalancer column in the Ingress view so that users can see the hostname or IP of the Ingress Controller to be used.

Signed-off-by: Steve Richards <srichards@mirantis.com>
This commit is contained in:
Steve Richards 2020-10-09 10:52:29 +01:00
parent abe6a4e0b1
commit 6c9bf2f506
2 changed files with 17 additions and 0 deletions

View File

@ -2,6 +2,7 @@ import { KubeObject } from "../kube-object";
import { autobind } from "../../utils";
import { IMetrics, metricsApi } from "./metrics.api";
import { KubeApi } from "../kube-api";
import { hostname } from "os";
export class IngressApi extends KubeApi<Ingress> {
getMetrics(ingress: string, namespace: string): Promise<IIngressMetrics> {
@ -107,6 +108,20 @@ export class Ingress extends KubeObject {
}
return ports.join(", ")
}
getLoadBalancers() {
const ingressAddresses: string[] = [];
const { status: { loadBalancer } } = this;
if (!loadBalancer) return [];
loadBalancer.ingress.forEach(address => {
const entry = address.hostname ? address.hostname : address.ip;
ingressAddresses.push(entry);
})
return ingressAddresses;
}
}
export const ingressApi = new IngressApi({

View File

@ -39,12 +39,14 @@ export class Ingresses extends React.Component<Props> {
renderTableHeader={[
{ title: <Trans>Name</Trans>, className: "name", sortBy: sortBy.name },
{ title: <Trans>Namespace</Trans>, className: "namespace", sortBy: sortBy.namespace },
{ title: <Trans>LoadBalancers</Trans>, className: "loadbalancers" },
{ title: <Trans>Rules</Trans>, className: "rules" },
{ title: <Trans>Age</Trans>, className: "age", sortBy: sortBy.age },
]}
renderTableContents={(ingress: Ingress) => [
ingress.getName(),
ingress.getNs(),
ingress.getLoadBalancers().map(lb => <p key={lb}>{lb}</p>),
ingress.getRoutes().map(route => <p key={route}>{route}</p>),
ingress.getAge(),
]}