mirror of
https://github.com/portainer/portainer.git
synced 2025-07-20 05:49:40 +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
|
@ -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