mirror of
https://github.com/portainer/portainer.git
synced 2025-08-02 20:35:25 +02:00
feat(node): Show which IP address / port the cluster API is listening on (#4134)
* feat(cluster): add kubernetes endpoint resource * feat(cluster): add kubernetes endpoint service * feat(node): Show which IP address / port the cluster API is listening on * fix(cluster): support multi-master clusters * fix(cluster): support multi-master clusters * feat(k8s/cluster): minor UI update * refactor(k8s/cluster): rename variable * refactor(k8s/endpoints): refactor KubernetesEndpointsFactory Co-authored-by: Anthony Lapenna <lapenna.anthony@gmail.com>
This commit is contained in:
parent
6756b04b67
commit
148ccd1bc4
9 changed files with 110 additions and 8 deletions
|
@ -51,7 +51,7 @@
|
|||
<!-- !cluster-status -->
|
||||
|
||||
<!-- leader-status -->
|
||||
<div ng-if="ctrl.endpoints.length > 0">
|
||||
<div ng-if="ctrl.systemEndpoints.length > 0">
|
||||
<div class="col-sm-12 form-section-title">
|
||||
Leader status
|
||||
</div>
|
||||
|
@ -62,7 +62,7 @@
|
|||
<td style="border-top: none; width: 25%;">Component</td>
|
||||
<td style="border-top: none; width: 25%;">Leader node</td>
|
||||
</tr>
|
||||
<tr ng-repeat="ep in ctrl.endpoints">
|
||||
<tr ng-repeat="ep in ctrl.systemEndpoints">
|
||||
<td style="width: 25%;">
|
||||
{{ ep.Name }}
|
||||
</td>
|
||||
|
|
|
@ -51,8 +51,17 @@ class KubernetesClusterController {
|
|||
|
||||
async getEndpointsAsync() {
|
||||
try {
|
||||
const endpoints = await this.KubernetesEndpointService.get('kube-system');
|
||||
this.endpoints = _.filter(endpoints, (ep) => ep.HolderIdentity);
|
||||
const endpoints = await this.KubernetesEndpointService.get();
|
||||
const systemEndpoints = _.filter(endpoints, { Namespace: 'kube-system' });
|
||||
this.systemEndpoints = _.filter(systemEndpoints, (ep) => ep.HolderIdentity);
|
||||
|
||||
const kubernetesEndpoint = _.find(endpoints, { Name: 'kubernetes' });
|
||||
if (kubernetesEndpoint && kubernetesEndpoint.Subsets) {
|
||||
const ips = _.flatten(_.map(kubernetesEndpoint.Subsets, 'Ips'));
|
||||
_.forEach(this.nodes, (node) => {
|
||||
node.Api = _.includes(ips, node.IPAddress);
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
this.Notifications.error('Failure', err, 'Unable to retrieve endpoints');
|
||||
}
|
||||
|
|
|
@ -18,7 +18,16 @@
|
|||
<tbody ng-if="ctrl.node">
|
||||
<tr>
|
||||
<td>Hostname</td>
|
||||
<td>{{ ctrl.node.Name }}</td>
|
||||
<td>
|
||||
{{ ctrl.node.Name }}
|
||||
<span class="label label-primary image-tag" style="margin-left: 5px;" ng-if="ctrl.node.Api">api</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr ng-if="ctrl.endpoint.Subsets">
|
||||
<td>
|
||||
Kubernetes API
|
||||
</td>
|
||||
<td>{{ ctrl.node.IPAddress }}:{{ ctrl.node.Port }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Role</td>
|
||||
|
|
|
@ -6,7 +6,17 @@ import KubernetesEventHelper from 'Kubernetes/helpers/eventHelper';
|
|||
|
||||
class KubernetesNodeController {
|
||||
/* @ngInject */
|
||||
constructor($async, $state, Notifications, LocalStorage, KubernetesNodeService, KubernetesEventService, KubernetesPodService, KubernetesApplicationService) {
|
||||
constructor(
|
||||
$async,
|
||||
$state,
|
||||
Notifications,
|
||||
LocalStorage,
|
||||
KubernetesNodeService,
|
||||
KubernetesEventService,
|
||||
KubernetesPodService,
|
||||
KubernetesApplicationService,
|
||||
KubernetesEndpointService
|
||||
) {
|
||||
this.$async = $async;
|
||||
this.$state = $state;
|
||||
this.Notifications = Notifications;
|
||||
|
@ -15,18 +25,44 @@ class KubernetesNodeController {
|
|||
this.KubernetesEventService = KubernetesEventService;
|
||||
this.KubernetesPodService = KubernetesPodService;
|
||||
this.KubernetesApplicationService = KubernetesApplicationService;
|
||||
this.KubernetesEndpointService = KubernetesEndpointService;
|
||||
|
||||
this.onInit = this.onInit.bind(this);
|
||||
this.getNodeAsync = this.getNodeAsync.bind(this);
|
||||
this.getEvents = this.getEvents.bind(this);
|
||||
this.getEventsAsync = this.getEventsAsync.bind(this);
|
||||
this.getApplicationsAsync = this.getApplicationsAsync.bind(this);
|
||||
this.getEndpointsAsync = this.getEndpointsAsync.bind(this);
|
||||
}
|
||||
|
||||
selectTab(index) {
|
||||
this.LocalStorage.storeActiveTab('node', index);
|
||||
}
|
||||
|
||||
async getEndpointsAsync() {
|
||||
try {
|
||||
const endpoints = await this.KubernetesEndpointService.get();
|
||||
this.endpoint = _.find(endpoints, { Name: 'kubernetes' });
|
||||
if (this.endpoint && this.endpoint.Subsets) {
|
||||
_.forEach(this.endpoint.Subsets, (subset) => {
|
||||
return _.forEach(subset.Ips, (ip) => {
|
||||
if (ip === this.node.IPAddress) {
|
||||
this.node.Api = true;
|
||||
this.node.Port = subset.Port;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
this.Notifications.error('Failure', err, 'Unable to retrieve endpoints');
|
||||
}
|
||||
}
|
||||
|
||||
getEndpoints() {
|
||||
return this.$async(this.getEndpointsAsync);
|
||||
}
|
||||
|
||||
async getNodeAsync() {
|
||||
try {
|
||||
this.state.dataLoading = true;
|
||||
|
@ -118,6 +154,7 @@ class KubernetesNodeController {
|
|||
await this.getNode();
|
||||
await this.getEvents();
|
||||
await this.getApplications();
|
||||
await this.getEndpoints();
|
||||
|
||||
this.state.viewReady = true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue