mirror of
https://github.com/portainer/portainer.git
synced 2025-08-04 21:35:23 +02:00
feat(k8s/application): Support multi-container pods applications (#4208)
* feat(application): Support multi-container pods applications * feat(application): Support multi-container pods applications * fix(application): use only one pod in app details and fix logs and console links * fix(application): show all containers in containers datatable * fix(application): fix order by pod name * feat(k8s/application): minor UI update * feat(k8s/application): minor UI update * feat(k8s/application): minor UI update * feat(k8s/application): minor UI update * feat(k8s/application): minor UI update * fix(application): fix persisted folders in application details Co-authored-by: Anthony Lapenna <lapenna.anthony@gmail.com>
This commit is contained in:
parent
fe4a80c7bd
commit
00389a7da9
24 changed files with 358 additions and 141 deletions
|
@ -28,6 +28,43 @@ class KubernetesApplicationHelper {
|
|||
return _.filter(pods, { Labels: app.spec.selector.matchLabels });
|
||||
}
|
||||
|
||||
static associateContainerPersistedFoldersAndConfigurations(app, containers) {
|
||||
_.forEach(containers, (container) => {
|
||||
container.PersistedFolders = _.without(
|
||||
_.map(app.PersistedFolders, (pf) => {
|
||||
if (pf.MountPath && _.includes(_.map(container.VolumeMounts, 'mountPath'), pf.MountPath)) {
|
||||
return pf;
|
||||
}
|
||||
}),
|
||||
undefined
|
||||
);
|
||||
|
||||
container.ConfigurationVolumes = _.without(
|
||||
_.map(app.ConfigurationVolumes, (cv) => {
|
||||
if (cv.rootMountPath && _.includes(_.map(container.VolumeMounts, 'mountPath'), cv.rootMountPath)) {
|
||||
return cv;
|
||||
}
|
||||
}),
|
||||
undefined
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
static associateContainersAndApplication(app) {
|
||||
if (!app.Pods) {
|
||||
return [];
|
||||
}
|
||||
const containers = app.Pods[0].Containers;
|
||||
KubernetesApplicationHelper.associateContainerPersistedFoldersAndConfigurations(app, containers);
|
||||
return containers;
|
||||
}
|
||||
|
||||
static associateAllContainersAndApplication(app) {
|
||||
const containers = _.flatMap(_.map(app.Pods, 'Containers'));
|
||||
KubernetesApplicationHelper.associateContainerPersistedFoldersAndConfigurations(app, containers);
|
||||
return containers;
|
||||
}
|
||||
|
||||
static portMappingsFromApplications(applications) {
|
||||
const res = _.reduce(
|
||||
applications,
|
||||
|
|
|
@ -9,13 +9,13 @@ class KubernetesResourceReservationHelper {
|
|||
return _.reduce(
|
||||
containers,
|
||||
(acc, container) => {
|
||||
if (container.resources && container.resources.requests) {
|
||||
if (container.resources.requests.memory) {
|
||||
acc.Memory += filesizeParser(container.resources.requests.memory, { base: 10 });
|
||||
if (container.Requests) {
|
||||
if (container.Requests.memory) {
|
||||
acc.Memory += filesizeParser(container.Requests.memory, { base: 10 });
|
||||
}
|
||||
|
||||
if (container.resources.requests.cpu) {
|
||||
acc.CPU += KubernetesResourceReservationHelper.parseCPU(container.resources.requests.cpu);
|
||||
if (container.Requests.cpu) {
|
||||
acc.CPU += KubernetesResourceReservationHelper.parseCPU(container.Requests.cpu);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue