mirror of
https://github.com/portainer/portainer.git
synced 2025-07-23 15:29:42 +02:00
* feat(node): Add the ability to apply taints and labels to nodes * feat(k8s/node): minor UI update * feat(k8s/node): UI update and disable system labels * feat(k8s/node): minor UI update * fix(node): fix add first taint * refacto(node): add KubernetesNodeHelper * feat(node): add used label to labels * feat(node): add node update modals * fix(node): modal when used label changes * feat(k8s/node): minor UI update Co-authored-by: Anthony Lapenna <lapenna.anthony@gmail.com>
23 lines
774 B
JavaScript
23 lines
774 B
JavaScript
import _ from 'lodash-es';
|
|
|
|
export class KubernetesNodeHelper {
|
|
static isSystemLabel(label) {
|
|
return !label.IsNew && (_.startsWith(label.Key, 'beta.kubernetes.io') || _.startsWith(label.Key, 'kubernetes.io') || label.Key === 'node-role.kubernetes.io/master');
|
|
}
|
|
|
|
static reorderLabels(labels) {
|
|
return _.sortBy(labels, (label) => {
|
|
return !KubernetesNodeHelper.isSystemLabel(label);
|
|
});
|
|
}
|
|
|
|
static computeUsedLabels(applications, labels) {
|
|
const pods = _.flatten(_.map(applications, 'Pods'));
|
|
const nodeSelectors = _.uniq(_.flatten(_.map(pods, 'NodeSelector')));
|
|
|
|
return _.map(labels, (label) => {
|
|
label.IsUsed = _.find(nodeSelectors, (ns) => ns && ns[label.Key] === label.Value) ? true : false;
|
|
return label;
|
|
});
|
|
}
|
|
}
|