Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add LoadBalancer information to the Ingress view #1064

Merged
merged 2 commits into from
Oct 16, 2020

Conversation

stevejr
Copy link
Collaborator

@stevejr stevejr commented Oct 9, 2020

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.

Fixes #772

Signed-off-by: Steve Richards srichards@mirantis.com

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>
@stevejr stevejr linked an issue Oct 9, 2020 that may be closed by this pull request
@stevejr stevejr self-assigned this Oct 9, 2020
@nevalla nevalla changed the title Issue-772: Add LoadBalancer information to the Ingress view Add LoadBalancer information to the Ingress view Oct 9, 2020
@nevalla nevalla added the enhancement New feature or request label Oct 9, 2020
@nevalla nevalla added this to the 3.7.0 milestone Oct 9, 2020
@@ -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";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this used anywhere?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Have removed in the next commit


if (!loadBalancer) return [];

loadBalancer.ingress.forEach(address => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This crashes when there are no external addresses

Suggested change
loadBalancer.ingress.forEach(address => {
loadBalancer.ingress?.forEach(address => {

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good spot @jim-docker. I guess the only time this can happen though is if an ingress object exists without an ingress controller being present? Still something we should handle

Comment on lines 113 to 123
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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest making this a map as it is much cleaner

Suggested change
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;
const { status: { loadBalancer = {} } } = this;
return (loadBalancer.ingress ?? []).map(address => (
address.hostname || address.ip
))

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is much cleaner @Nokel81 - I'm still learning so having these examples is awesome to help me improve. One question, as loadBalancer could end up being an empty array are we good with the ingress and address property throwing up a warning in IDE validation? For example, in VS Code I get the following:

any
Property 'ingress' does not exist on type '{}'

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The above actually causes a CI/CD failure in integration tests so will see if I can resolve

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amended as follows:

const { status: { loadBalancer = {ingress: []} } } = this;

This gives the loadBalancer an empty ingress object by default.

This ok?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that would be better

Signed-off-by: Steve Richards <srichards@mirantis.com>
@jakolehm jakolehm merged commit c0b8d47 into lensapp:master Oct 16, 2020
@nevalla nevalla modified the milestones: 3.7.0, 4.0.0 Oct 26, 2020
@jakolehm jakolehm mentioned this pull request Oct 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Status details for Ingress
5 participants