mirror of
https://github.com/portainer/portainer.git
synced 2025-07-25 08:19:40 +02:00
feat(k8s/application): add/edit placement preferences/constraints (#4210)
* feat(k8s/application): create application with placement preferences/constraints * feat(k8s/application): edit application placement preferences/constraints
This commit is contained in:
parent
32bac9ffcc
commit
52bdcf2e2b
22 changed files with 451 additions and 190 deletions
|
@ -31,7 +31,7 @@ function computeContainerStatus(statuses, name) {
|
|||
function computeAffinity(affinity) {
|
||||
const res = new KubernetesPodAffinity();
|
||||
if (affinity) {
|
||||
res.NodeAffinity = affinity.nodeAffinity || {};
|
||||
res.nodeAffinity = affinity.nodeAffinity || {};
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -10,56 +10,13 @@ export const KubernetesPodNodeAffinityNodeSelectorRequirementOperators = Object.
|
|||
/**
|
||||
* KubernetesPodAffinity Model
|
||||
*/
|
||||
const _KubernetesPodAffinity = Object.freeze({
|
||||
NodeAffinity: {},
|
||||
// PodAffinity: {},
|
||||
// PodAntiAffinity: {},
|
||||
});
|
||||
|
||||
export class KubernetesPodAffinity {
|
||||
constructor() {
|
||||
Object.assign(this, JSON.parse(JSON.stringify(_KubernetesPodAffinity)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* KubernetesPodNodeAffinity Model
|
||||
*/
|
||||
const _KubernetesPodNodeAffinity = Object.freeze({
|
||||
PreferredDuringSchedulingIgnoredDuringExecution: [],
|
||||
RequiredDuringSchedulingIgnoredDuringExecution: {},
|
||||
});
|
||||
|
||||
export class KubernetesPodNodeAffinity {
|
||||
constructor() {
|
||||
Object.assign(this, JSON.parse(JSON.stringify(_KubernetesPodNodeAffinity)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* KubernetesPodPodAffinity Model
|
||||
*/
|
||||
const _KubernetesPodPodAffinity = Object.freeze({
|
||||
PreferredDuringSchedulingIgnoredDuringExecution: [],
|
||||
equiredDuringSchedulingIgnoredDuringExecution: [],
|
||||
});
|
||||
|
||||
export class KubernetesPodPodAffinity {
|
||||
constructor() {
|
||||
Object.assign(this, JSON.parse(JSON.stringify(_KubernetesPodPodAffinity)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* KubernetesPodPodAntiAffinity Model
|
||||
*/
|
||||
const _KubernetesPodPodAntiAffinity = Object.freeze({
|
||||
preferredDuringSchedulingIgnoredDuringExecution: [],
|
||||
requiredDuringSchedulingIgnoredDuringExecution: [],
|
||||
});
|
||||
|
||||
export class KubernetesPodPodAntiAffinity {
|
||||
constructor() {
|
||||
Object.assign(this, JSON.parse(JSON.stringify(_KubernetesPodPodAntiAffinity)));
|
||||
}
|
||||
// this model will contain non transformed data (raw payload data)
|
||||
// either during creation flow (model > api)
|
||||
// than during reading flow (api > model)
|
||||
export function KubernetesPodAffinity() {
|
||||
return {
|
||||
nodeAffinity: {}, // KubernetesPodNodeAffinityPayload
|
||||
// podAffinity: {},
|
||||
// podAntiAffinity: {},
|
||||
};
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ const _KubernetesPod = Object.freeze({
|
|||
Labels: [],
|
||||
Affinity: {}, // KubernetesPodAffinity
|
||||
Tolerations: [], // KubernetesPodToleration[]
|
||||
NodeSelector: undefined,
|
||||
});
|
||||
|
||||
export class KubernetesPod {
|
||||
|
|
29
app/kubernetes/pod/payloads/affinities.js
Normal file
29
app/kubernetes/pod/payloads/affinities.js
Normal file
|
@ -0,0 +1,29 @@
|
|||
export function KubernetesPodNodeAffinityPayload() {
|
||||
return {
|
||||
requiredDuringSchedulingIgnoredDuringExecution: {
|
||||
nodeSelectorTerms: [], // []KubernetesNodeSelectorTermPayload
|
||||
},
|
||||
preferredDuringSchedulingIgnoredDuringExecution: [], // []KubernetesPreferredSchedulingTermPayload
|
||||
};
|
||||
}
|
||||
|
||||
export function KubernetesPreferredSchedulingTermPayload() {
|
||||
return {
|
||||
weight: 1,
|
||||
preference: {}, // KubernetesNodeSelectorTermPayload
|
||||
};
|
||||
}
|
||||
|
||||
export function KubernetesNodeSelectorTermPayload() {
|
||||
return {
|
||||
matchExpressions: [], // []KubernetesNodeSelectorRequirementPayload
|
||||
};
|
||||
}
|
||||
|
||||
export function KubernetesNodeSelectorRequirementPayload() {
|
||||
return {
|
||||
key: '', // string
|
||||
operator: '', // KubernetesPodNodeAffinityNodeSelectorRequirementOperators
|
||||
values: [], // []string
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue