Skip to content

Commit

Permalink
fix: Show hostname in loadBalancerIngress
Browse files Browse the repository at this point in the history
  • Loading branch information
leoliu committed Jun 30, 2020
1 parent d01fe96 commit 6c85fa2
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/locales/zh/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default {
Ports: '端口',
selector: '选择器',
Selector: '选择器',
'External IP': '外部 IP',
'External Address': '外部地址',
'LoadBalancer IP': '负载均衡 IP',
'Create Service': '创建服务',
'Delete Service': '删除服务',
Expand Down
9 changes: 8 additions & 1 deletion src/pages/clusters/containers/Workload/Routes/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,16 @@ export default class Routers extends React.Component {
},
{
title: t('Gateway Address'),
dataIndex: 'loadBalancerIngress[0].ip',
dataIndex: 'loadBalancerIngress',
isHideable: true,
width: '22%',
render: loadBalancerIngress => (
<div>
{loadBalancerIngress.map((item, index) => (
<p key={index}>{item.ip || item.hostname}</p>
))}
</div>
),
},
{
title: t('Project'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ class InternetAccess extends React.Component {
) : (
<Text
title={this.getExternalIP(gateway)}
description={t('External IP')}
description={t('External Address')}
/>
)}
<Text
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export default class Components extends Component {
) : (
<Text
title={this.getExternalIP(gateway)}
description={t('External IP')}
description={t('External Address')}
/>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export default class Item extends React.Component {
) : (
<Text
title={this.getExternalIP(gateway)}
description={t('External IP')}
description={t('External Address')}
/>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ class InternetAccess extends React.Component {
) : (
<div className={styles.item}>
<div>{this.getExternalIP(gateway)}</div>
<p>{t('External IP')}</p>
<p>{t('External Address')}</p>
</div>
)}
{globals.app.hasClusterModule(cluster, 'servicemesh') && (
Expand Down
1 change: 1 addition & 0 deletions src/pages/projects/containers/Routes/Detail/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ export default class RouteDetail extends React.Component {
let ips = []
loadBalancerIngress.forEach(item => {
item.ip && ips.push(item.ip)
item.hostname && ips.push(item.hostname)
})
ips = ips.map((ip, index) => <p key={index}>{ip}</p>)

Expand Down
9 changes: 8 additions & 1 deletion src/pages/projects/containers/Routes/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,16 @@ export default class Routers extends React.Component {
},
{
title: t('Gateway Address'),
dataIndex: 'loadBalancerIngress[0].ip',
dataIndex: 'loadBalancerIngress',
isHideable: true,
width: '22%',
render: loadBalancerIngress => (
<div>
{loadBalancerIngress.map((item, index) => (
<p key={index}>{item.ip || item.hostname}</p>
))}
</div>
),
},
{
title: t('Application'),
Expand Down
2 changes: 1 addition & 1 deletion src/pages/projects/containers/Services/Detail/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export default class ServiceDetail extends React.Component {
value: detail.clusterIP,
},
{
name: t('External IP'),
name: t('External Address'),
value: externalIP,
},
{
Expand Down
8 changes: 6 additions & 2 deletions src/utils/object.mapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,9 @@ const ServiceMapper = item => {
sessionAffinity: get(item, 'spec.sessionAffinity'),
externalIPs: get(item, 'spec.externalIPs', []),
externalName: get(item, 'spec.externalName'),
loadBalancerIngress: get(item, 'status.loadBalancer.ingress[0].ip'),
loadBalancerIngress:
get(item, 'status.loadBalancer.ingress[0].ip') ||
get(item, 'status.loadBalancer.ingress[0].hostname'),
app:
get(item, 'metadata.labels.release') ||
get(item, 'metadata.labels["app.kubernetes.io/name"]'),
Expand Down Expand Up @@ -628,7 +630,9 @@ const GatewayMapper = item => ({
type: get(item, 'spec.type'),
externalIPs: get(item, 'spec.externalIPs', []),
ports: get(item, 'spec.ports', []),
loadBalancerIngress: get(item, 'status.loadBalancer.ingress[0].ip'),
loadBalancerIngress:
get(item, 'status.loadBalancer.ingress[0].ip') ||
get(item, 'status.loadBalancer.ingress[0].hostname'),
serviceMeshEnable:
get(item, 'metadata.annotations["servicemesh.kubesphere.io/enabled"]') ===
'true',
Expand Down

0 comments on commit 6c85fa2

Please sign in to comment.