mirror of https://github.com/rancher/ui.git
pod affinity/antiaffinity preferred/required dropdowns
This commit is contained in:
parent
c8ff871e0a
commit
3da4135901
|
|
@ -86,15 +86,110 @@ export default Component.extend({
|
||||||
value: null,
|
value: null,
|
||||||
mode: 'new',
|
mode: 'new',
|
||||||
|
|
||||||
podAffinity: computed('value.podAffinity', function(){
|
actions: {
|
||||||
return get(this.value, 'podAffinity') || {}
|
affinityChanged(key, val){
|
||||||
}),
|
// TODO nb update affinity
|
||||||
|
console.log('affinity ', key, ' changed to: ', val)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
podAntiAffinity: computed('value.podAntiAffinity', function(){
|
podAffinity: computed('value.podAffinity.{preferredDuringSchedulingIgnoredDuringExecution,requiredDuringSchedulingIgnoredDuringExecution}', {
|
||||||
return get(this.value, 'podAntiAffinity') || {}
|
get(){
|
||||||
}),
|
if (!this.value?.podAffinity){
|
||||||
|
set(this.value, 'podAffinity', {})
|
||||||
|
}
|
||||||
|
this.initPreferredRequired(this.value.podAffinity)
|
||||||
|
|
||||||
nodeAffinity: computed('value.nodeAffinity', function(){
|
return get(this.value, 'podAffinity')
|
||||||
return get(this.value, 'nodeAffinity') || {}
|
},
|
||||||
|
set(key, val){
|
||||||
|
// TODO nb move withoutId to own function
|
||||||
|
const withoutId = {
|
||||||
|
preferredDuringSchedulingIgnoredDuringExecution: (val.preferredDuringSchedulingIgnoredDuringExecution || []).map((term) => {
|
||||||
|
delete term._id;
|
||||||
|
|
||||||
|
return term
|
||||||
}),
|
}),
|
||||||
|
requiredDuringSchedulingIgnoredDuringExecution: (val.requiredDuringSchedulingIgnoredDuringExecution || []).map((term) => {
|
||||||
|
delete term._id;
|
||||||
|
|
||||||
|
return term
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
set(this.value, 'podAffinity', withoutId)
|
||||||
|
this.notifyPropertyChange('value')
|
||||||
|
|
||||||
|
return val
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
|
||||||
|
podAntiAffinity: computed('value.podAntiAffinity.{preferredDuringSchedulingIgnoredDuringExecution,requiredDuringSchedulingIgnoredDuringExecution}', {
|
||||||
|
get(){
|
||||||
|
if (!this.value?.podAntiAffinity){
|
||||||
|
set(this.value, 'podAntiAffinity', {})
|
||||||
|
}
|
||||||
|
this.initPreferredRequired(this.value.podAntiAffinity)
|
||||||
|
|
||||||
|
return get(this.value, 'podAntiAffinity')
|
||||||
|
},
|
||||||
|
set(key, val){
|
||||||
|
const withoutId = {
|
||||||
|
preferredDuringSchedulingIgnoredDuringExecution: (val.preferredDuringSchedulingIgnoredDuringExecution || []).map((term) => {
|
||||||
|
delete term._id;
|
||||||
|
|
||||||
|
return term
|
||||||
|
}),
|
||||||
|
requiredDuringSchedulingIgnoredDuringExecution: (val.requiredDuringSchedulingIgnoredDuringExecution || []).map((term) => {
|
||||||
|
delete term._id;
|
||||||
|
|
||||||
|
return term
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
set(this.value, 'podAntiAffinity', withoutId)
|
||||||
|
this.notifyPropertyChange('value')
|
||||||
|
|
||||||
|
return val
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
|
||||||
|
nodeAffinity: computed('value.nodeAffinity.{preferredDuringSchedulingIgnoredDuringExecution,requiredDuringSchedulingIgnoredDuringExecution}', {
|
||||||
|
get(){
|
||||||
|
if (!this.value?.nodeAffinity){
|
||||||
|
set(this.value, 'nodeAffinity', {})
|
||||||
|
}
|
||||||
|
this.initPreferredRequired(this.value.nodeAffinity)
|
||||||
|
|
||||||
|
return get(this.value, 'nodeAffinity')
|
||||||
|
},
|
||||||
|
set(key, val){
|
||||||
|
const withoutId = {
|
||||||
|
preferredDuringSchedulingIgnoredDuringExecution: (val.preferredDuringSchedulingIgnoredDuringExecution || []).map((term) => {
|
||||||
|
delete term._id;
|
||||||
|
|
||||||
|
return term
|
||||||
|
}),
|
||||||
|
requiredDuringSchedulingIgnoredDuringExecution: (val.requiredDuringSchedulingIgnoredDuringExecution || []).map((term) => {
|
||||||
|
delete term._id;
|
||||||
|
|
||||||
|
return term
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
set(this.value, 'nodeAffinity', withoutId)
|
||||||
|
this.notifyPropertyChange('value')
|
||||||
|
|
||||||
|
return val
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
|
||||||
|
initPreferredRequired: (val) => {
|
||||||
|
if (!val.preferredDuringSchedulingIgnoredDuringExecution){
|
||||||
|
set(val, 'preferredDuringSchedulingIgnoredDuringExecution', [])
|
||||||
|
}
|
||||||
|
if (!val.requiredDuringSchedulingIgnoredDuringExecution){
|
||||||
|
set(val, 'requiredDuringSchedulingIgnoredDuringExecution', [])
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
@ -9,13 +9,9 @@
|
||||||
<FormPodAffinityK8s
|
<FormPodAffinityK8s
|
||||||
@mode={{mode}}
|
@mode={{mode}}
|
||||||
@value={{podAffinity}}
|
@value={{podAffinity}}
|
||||||
/>
|
@podAffinity={{podAffinity}}
|
||||||
</div>
|
@podAntiAffinity={{podAntiAffinity}}
|
||||||
<div class="row">
|
@update={{action "affinityChanged"}}
|
||||||
<FormPodAffinityK8s
|
|
||||||
@anti={{true}}
|
|
||||||
@mode={{mode}}
|
|
||||||
@value={{podAntiAffinity}}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -106,7 +106,8 @@ export default Component.extend({
|
||||||
return get(this, 'agentConfig.overrideAffinity') || {}
|
return get(this, 'agentConfig.overrideAffinity') || {}
|
||||||
},
|
},
|
||||||
set(key, val){
|
set(key, val){
|
||||||
// TODO nb update agentConfig
|
set(this.agentConfig, 'overrideAffinity', val)
|
||||||
|
|
||||||
return val
|
return val
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import {
|
||||||
set,
|
set,
|
||||||
observer
|
observer
|
||||||
} from '@ember/object';
|
} from '@ember/object';
|
||||||
|
import { randomStr } from '../../utils/util';
|
||||||
|
|
||||||
/** podAffinity: {
|
/** podAffinity: {
|
||||||
* preferredDuringSchedulingIgnoredDuringExecution:
|
* preferredDuringSchedulingIgnoredDuringExecution:
|
||||||
|
|
@ -16,13 +17,57 @@ import {
|
||||||
* requiredDuringSchedulingIgnoredDuringExecution:
|
* requiredDuringSchedulingIgnoredDuringExecution:
|
||||||
* - podaffinityterm
|
* - podaffinityterm
|
||||||
* }
|
* }
|
||||||
|
* podAntiAffinity: same shape
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
export const TERM_PRIORITY = {
|
||||||
|
PREFERRED: 'preferred',
|
||||||
|
REQUIRED: 'required'
|
||||||
|
}
|
||||||
|
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
layout,
|
layout,
|
||||||
|
|
||||||
|
TERM_PRIORITY,
|
||||||
|
podAffinity: null,
|
||||||
|
podAntiAffinity: null,
|
||||||
value: null,
|
value: null,
|
||||||
mode: 'new',
|
mode: 'new',
|
||||||
anti: false,
|
anti: false,
|
||||||
|
allTerms: [],
|
||||||
|
/**
|
||||||
|
* this component renders one list for required & preferred arrays of terms in affinity & antiAffinity
|
||||||
|
* each podaffinitytermk8s component can change between affinity and antiaffinity and between required and perferred
|
||||||
|
* the overall list shouldn't re-order when a term is moved to a different underlying array so rather than computing this off the arrays in spec
|
||||||
|
* this list will track which array a term should belong to and the arrays in spec will be computed off this
|
||||||
|
* list of all terms
|
||||||
|
* - {
|
||||||
|
* priority: preferred/required
|
||||||
|
* anti: bool
|
||||||
|
* term:preferred or required term
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
init(){
|
||||||
|
this._super(...arguments);
|
||||||
|
const allTerms = []
|
||||||
|
const addTerms = function(terms = [], priority, isAnti){
|
||||||
|
terms.forEach((term) => {
|
||||||
|
allTerms.push({
|
||||||
|
priority,
|
||||||
|
anti: isAnti,
|
||||||
|
term
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
addTerms(this.podAffinity?.preferredDuringSchedulingIgnoredDuringExecution, TERM_PRIORITY.PREFERRED, false)
|
||||||
|
addTerms(this.podAffinity?.requiredDuringSchedulingIgnoredDuringExecution, TERM_PRIORITY.REQUIRED, false)
|
||||||
|
addTerms(this.podAntiAffinity?.preferredDuringSchedulingIgnoredDuringExecution, TERM_PRIORITY.PREFERRED, true)
|
||||||
|
addTerms(this.podAntiAffinity?.requiredDuringSchedulingIgnoredDuringExecution, TERM_PRIORITY.REQUIRED, true)
|
||||||
|
|
||||||
|
set(this, 'allTerms', allTerms)
|
||||||
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
addRequired(){
|
addRequired(){
|
||||||
|
|
@ -32,8 +77,137 @@ export default Component.extend({
|
||||||
this.preferredDuringSchedulingIgnoredDuringExecution.pushObject({})
|
this.preferredDuringSchedulingIgnoredDuringExecution.pushObject({})
|
||||||
},
|
},
|
||||||
|
|
||||||
removeTerm(term, key){
|
addTerm(){
|
||||||
get(this, key).removeObject(term)
|
const neu = {
|
||||||
|
priority: TERM_PRIORITY.REQUIRED,
|
||||||
|
anti: false,
|
||||||
|
term: { _id: randomStr() }
|
||||||
|
}
|
||||||
|
|
||||||
|
this.allTerms.push(neu)
|
||||||
|
get(this.podAffinity, 'requiredDuringSchedulingIgnoredDuringExecution').addObject(neu.term)
|
||||||
|
this.notifyPropertyChange('allTerms')
|
||||||
|
this.notifyPropertyChange('podAffinity')
|
||||||
|
|
||||||
|
// TODO nb update relevent spec array
|
||||||
|
},
|
||||||
|
|
||||||
|
removeTerm(term){
|
||||||
|
// TODO nb update relevent spec array
|
||||||
|
get(this, 'allTerms').removeObject(term)
|
||||||
|
if (term.anti){
|
||||||
|
if (term.priority === TERM_PRIORITY.REQUIRED){
|
||||||
|
const removeFrom = get(this.podAntiAffinity, 'requiredDuringSchedulingIgnoredDuringExecution')
|
||||||
|
|
||||||
|
removeFrom.removeObject(term.term)
|
||||||
|
} else {
|
||||||
|
const removeFrom = get(this.podAntiAffinity, 'preferredDuringSchedulingIgnoredDuringExecution')
|
||||||
|
|
||||||
|
removeFrom.removeObject(term.term)
|
||||||
|
}
|
||||||
|
this.notifyPropertyChange('podAntiAffinity')
|
||||||
|
} else {
|
||||||
|
if (term.priority === TERM_PRIORITY.REQUIRED){
|
||||||
|
const removeFrom = get(this.podAffinity, 'requiredDuringSchedulingIgnoredDuringExecution')
|
||||||
|
|
||||||
|
removeFrom.removeObject(term.term)
|
||||||
|
} else {
|
||||||
|
const removeFrom = get(this.podAffinity, 'preferredDuringSchedulingIgnoredDuringExecution')
|
||||||
|
|
||||||
|
removeFrom.removeObject(term.term)
|
||||||
|
}
|
||||||
|
this.notifyPropertyChange('podAffinity')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
affinityChanged(){
|
||||||
|
// TODO nb this.update()
|
||||||
|
// needed?
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
typeChanged(term, old, neu){
|
||||||
|
if (term.anti){
|
||||||
|
if (old === TERM_PRIORITY.REQUIRED){
|
||||||
|
const removeFrom = get(this.podAntiAffinity, 'requiredDuringSchedulingIgnoredDuringExecution')
|
||||||
|
const addTo = get(this.podAntiAffinity, 'preferredDuringSchedulingIgnoredDuringExecution')
|
||||||
|
|
||||||
|
// removeFrom.removeObject(term.term)
|
||||||
|
set(this.podAntiAffinity, 'requiredDuringSchedulingIgnoredDuringExecution', this.removeFromSpec(term.term, removeFrom))
|
||||||
|
|
||||||
|
addTo.pushObject(term.term)
|
||||||
|
} else {
|
||||||
|
const removeFrom = get(this.podAntiAffinity, 'preferredDuringSchedulingIgnoredDuringExecution')
|
||||||
|
const addTo = get(this.podAntiAffinity, 'requiredDuringSchedulingIgnoredDuringExecution')
|
||||||
|
|
||||||
|
// removeFrom.removeObject(term.term)
|
||||||
|
set(this.podAntiAffinity, 'preferredDuringSchedulingIgnoredDuringExecution', this.removeFromSpec(term.term, removeFrom))
|
||||||
|
|
||||||
|
addTo.pushObject(term.term)
|
||||||
|
}
|
||||||
|
this.notifyPropertyChange('podAntiAffinity')
|
||||||
|
} else {
|
||||||
|
if (old === TERM_PRIORITY.REQUIRED){
|
||||||
|
const removeFrom = get(this.podAffinity, 'requiredDuringSchedulingIgnoredDuringExecution')
|
||||||
|
const addTo = get(this.podAffinity, 'preferredDuringSchedulingIgnoredDuringExecution')
|
||||||
|
|
||||||
|
// removeFrom.removeObject(term.term)
|
||||||
|
set(this.podAffinity, 'requiredDuringSchedulingIgnoredDuringExecution', this.removeFromSpec(term.term, removeFrom))
|
||||||
|
|
||||||
|
addTo.pushObject(term.term)
|
||||||
|
} else {
|
||||||
|
const removeFrom = get(this.podAffinity, 'preferredDuringSchedulingIgnoredDuringExecution')
|
||||||
|
const addTo = get(this.podAffinity, 'requiredDuringSchedulingIgnoredDuringExecution')
|
||||||
|
|
||||||
|
// removeFrom.removeObject(term.term)
|
||||||
|
set(this.podAffinity, 'preferredDuringSchedulingIgnoredDuringExecution', this.removeFromSpec(term.term, removeFrom))
|
||||||
|
addTo.pushObject(term.term)
|
||||||
|
}
|
||||||
|
this.notifyPropertyChange('podAffinity')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
antiChanged(term, old, neu){
|
||||||
|
if (old){
|
||||||
|
if (term.priority === TERM_PRIORITY.REQUIRED){
|
||||||
|
const removeFrom = get(this.podAntiAffinity, 'requiredDuringSchedulingIgnoredDuringExecution')
|
||||||
|
const addTo = get(this.podAffinity, 'requiredDuringSchedulingIgnoredDuringExecution')
|
||||||
|
|
||||||
|
// removeFrom.removeObject(term.term)
|
||||||
|
set(this.podAntiAffinity, 'requiredDuringSchedulingIgnoredDuringExecution', this.removeFromSpec(term.term, removeFrom))
|
||||||
|
|
||||||
|
addTo.pushObject(term.term)
|
||||||
|
} else {
|
||||||
|
const removeFrom = get(this.podAntiAffinity, 'preferredDuringSchedulingIgnoredDuringExecution')
|
||||||
|
const addTo = get(this.podAffinity, 'preferredDuringSchedulingIgnoredDuringExecution')
|
||||||
|
|
||||||
|
// removeFrom.removeObject(term.term)
|
||||||
|
set(this.podAntiAffinity, 'preferredDuringSchedulingIgnoredDuringExecution', this.removeFromSpec(term.term, removeFrom))
|
||||||
|
|
||||||
|
addTo.pushObject(term.term)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (term.priority === TERM_PRIORITY.REQUIRED){
|
||||||
|
const removeFrom = get(this.podAffinity, 'requiredDuringSchedulingIgnoredDuringExecution')
|
||||||
|
const addTo = get(this.podAntiAffinity, 'requiredDuringSchedulingIgnoredDuringExecution')
|
||||||
|
|
||||||
|
// removeFrom.removeObject(term.term)
|
||||||
|
set(this.podAffinity, 'requiredDuringSchedulingIgnoredDuringExecution', this.removeFromSpec(term.term, removeFrom))
|
||||||
|
|
||||||
|
addTo.pushObject(term.term)
|
||||||
|
} else {
|
||||||
|
const removeFrom = get(this.podAffinity, 'preferredDuringSchedulingIgnoredDuringExecution')
|
||||||
|
const addTo = get(this.podAntiAffinity, 'preferredDuringSchedulingIgnoredDuringExecution')
|
||||||
|
|
||||||
|
// removeFrom.removeObject(term.term)
|
||||||
|
set(this.podAffinity, 'preferredDuringSchedulingIgnoredDuringExecution', this.removeFromSpec(term.term, removeFrom))
|
||||||
|
|
||||||
|
addTo.pushObject(term.term)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.notifyPropertyChange('podAffinity')
|
||||||
|
this.notifyPropertyChange('podAntiAffinity')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -43,14 +217,38 @@ export default Component.extend({
|
||||||
return mode === 'new' || mode === 'edit'
|
return mode === 'new' || mode === 'edit'
|
||||||
}),
|
}),
|
||||||
|
|
||||||
requiredDuringSchedulingIgnoredDuringExecution: computed('value.requiredDuringSchedulingIgnoredDuringExecution', function(){
|
removeFromSpec: (term, array) => {
|
||||||
return get(this.value, 'requiredDuringSchedulingIgnoredDuringExecution') || []
|
return array.filter((each) => each._id !== term._id)
|
||||||
}),
|
},
|
||||||
|
|
||||||
preferredDuringSchedulingIgnoredDuringExecution: computed('value.preferredDuringSchedulingIngnoredDuringExecution', function(){
|
// affinityRequiredDuringSchedulingIgnoredDuringExecution: computed('podAffinity.requiredDuringSchedulingIgnoredDuringExecution', {
|
||||||
return get(this.value, 'preferredDuringSchedulingIgnoredDuringExecution') || []
|
// get(){
|
||||||
}),
|
// return get(this.podAffinity, 'requiredDuringSchedulingIgnoredDuringExecution') || []
|
||||||
|
// },
|
||||||
|
// set(key, val){
|
||||||
|
// debugger
|
||||||
|
// if (get(this.podAffinity, 'requiredDuringSchedulingIgnoredDuringExecution')){
|
||||||
|
// get(this.podAffinity, 'requiredDuringSchedulingIgnoredDuringExecution').addObject(val)
|
||||||
|
// } else {
|
||||||
|
// set(this.podAffinity, 'requiredDuringSchedulingIgnoredDuringExecution', [val])
|
||||||
|
// }
|
||||||
|
// this.notifyPropertyChange('podAffinity')
|
||||||
|
|
||||||
|
// return val
|
||||||
|
// }
|
||||||
|
// }),
|
||||||
|
|
||||||
|
// affinityPreferredDuringSchedulingIgnoredDuringExecution: computed('podAffinity.preferredDuringSchedulingIngnoredDuringExecution', function(){
|
||||||
|
// return get(this.podAffinity, 'preferredDuringSchedulingIgnoredDuringExecution') || []
|
||||||
|
// }),
|
||||||
|
|
||||||
|
// antiAffinityRequiredDuringSchedulingIgnoredDuringExecution: computed('podAntiAffinity.requiredDuringSchedulingIgnoredDuringExecution', function(){
|
||||||
|
// return get(this.podAntiAffinity, 'requiredDuringSchedulingIgnoredDuringExecution') || []
|
||||||
|
// }),
|
||||||
|
|
||||||
|
// antiAffinityPreferredDuringSchedulingIgnoredDuringExecution: computed('podAntiAffinity.preferredDuringSchedulingIngnoredDuringExecution', function(){
|
||||||
|
// return get(this.podAntiAffinity, 'preferredDuringSchedulingIgnoredDuringExecution') || []
|
||||||
|
// }),
|
||||||
|
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
@ -9,41 +9,23 @@
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col span-6">
|
<div class="col span-12">
|
||||||
<div>
|
<div>
|
||||||
{{#each requiredDuringSchedulingIgnoredDuringExecution as |requiredTerm|}}
|
{{#each allTerms as |term|}}
|
||||||
<FormPodAffinityTermK8s
|
<FormPodAffinityTermK8s
|
||||||
@value={{requiredTerm}}
|
@value={{term}}
|
||||||
@mode={{mode}}
|
@mode={{mode}}
|
||||||
@remove={{action "removeTerm" requiredTerm "requiredDuringSchedulingIgnoredDuringExecution"}}
|
@remove={{action "removeTerm" term}}
|
||||||
|
@typeChanged={{action "typeChanged" term}}
|
||||||
|
@antiChanged={{action "antiChanged" term}}
|
||||||
/>
|
/>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</div>
|
</div>
|
||||||
{{#if editing}}
|
{{#if editing}}
|
||||||
<button class="btn bg-link icon-btn" type="button" {{action "addRequired"}}>
|
<button class="btn bg-link icon-btn" type="button" {{action "addTerm"}}>
|
||||||
<i class="icon icon-plus text-small"/>
|
<i class="icon icon-plus text-small"/>
|
||||||
<span>
|
<span>
|
||||||
{{t "clusterNew.agentConfig.overrideAffinity.podAffinity.addRequired"}}
|
{{t "clusterNew.agentConfig.overrideAffinity.podAffinity.addTerm"}}
|
||||||
</span>
|
|
||||||
</button>
|
|
||||||
{{/if}}
|
|
||||||
</div>
|
|
||||||
<div class="col span-6">
|
|
||||||
<div>
|
|
||||||
{{#each preferredDuringSchedulingIgnoredDuringExecution as |preferredTerm|}}
|
|
||||||
<FormPodAffinityTermK8s
|
|
||||||
@value={{preferredTerm}}
|
|
||||||
@mode={{mode}}
|
|
||||||
@preferred={{true}}
|
|
||||||
@remove={{action "removeTerm" prefferedTerm "preferredDuringSchedulingIgnoredDuringExecution"}}
|
|
||||||
/>
|
|
||||||
{{/each}}
|
|
||||||
</div>
|
|
||||||
{{#if editing}}
|
|
||||||
<button class="btn bg-link icon-btn" type="button" {{action "addPreferred"}}>
|
|
||||||
<i class="icon icon-plus text-small"/>
|
|
||||||
<span>
|
|
||||||
{{t "clusterNew.agentConfig.overrideAffinity.podAffinity.addPreferred"}}
|
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import {
|
||||||
set,
|
set,
|
||||||
observer
|
observer
|
||||||
} from '@ember/object';
|
} from '@ember/object';
|
||||||
|
import { TERM_PRIORITY } from '../form-pod-affinity-k8s/component';
|
||||||
|
|
||||||
/** if preferred:
|
/** if preferred:
|
||||||
* - {
|
* - {
|
||||||
|
|
@ -46,10 +47,38 @@ export default Component.extend({
|
||||||
layout,
|
layout,
|
||||||
namespaceModes,
|
namespaceModes,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {
|
||||||
|
* priority: preferred or required
|
||||||
|
* anti: bool - podAffinity or podAntiAffinity
|
||||||
|
* term: podaffinityterm OR
|
||||||
|
* {
|
||||||
|
* weight,
|
||||||
|
* podAffintyTerm
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
*/
|
||||||
value: null,
|
value: null,
|
||||||
mode: 'new',
|
mode: 'new',
|
||||||
perferred: false,
|
|
||||||
remove: null,
|
remove: null,
|
||||||
|
typeChanged: null,
|
||||||
|
antiChanged: null,
|
||||||
|
|
||||||
|
priorityOptions: [{
|
||||||
|
value: TERM_PRIORITY.REQUIRED,
|
||||||
|
label: 'clusterNew.agentConfig.overrideAffinity.podAffinity.typeOptions.required'
|
||||||
|
}, {
|
||||||
|
value: TERM_PRIORITY.PREFERRED,
|
||||||
|
label: 'clusterNew.agentConfig.overrideAffinity.podAffinity.typeOptions.preferred'
|
||||||
|
}],
|
||||||
|
|
||||||
|
affinityOptions: [{
|
||||||
|
value: 'true',
|
||||||
|
label: 'clusterNew.agentConfig.overrideAffinity.podAffinity.typeOptions.antiAffinity'
|
||||||
|
}, {
|
||||||
|
value: 'false',
|
||||||
|
label: 'clusterNew.agentConfig.overrideAffinity.podAffinity.typeOptions.affinity'
|
||||||
|
}],
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
removeTerm(){
|
removeTerm(){
|
||||||
|
|
@ -95,7 +124,6 @@ export default Component.extend({
|
||||||
return namespaces.join(', ')
|
return namespaces.join(', ')
|
||||||
},
|
},
|
||||||
set(key, val){
|
set(key, val){
|
||||||
// TODO nb delete if not set
|
|
||||||
if (val || val === ''){
|
if (val || val === ''){
|
||||||
// a,b,c or a, b, c
|
// a,b,c or a, b, c
|
||||||
const parsed = val.split(/,\s*/g).map((ns) => ns.trim()).filter((ns) => !!ns)
|
const parsed = val.split(/,\s*/g).map((ns) => ns.trim()).filter((ns) => !!ns)
|
||||||
|
|
@ -126,6 +154,39 @@ export default Component.extend({
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
priority: computed('priorityOptions', 'value.priority', {
|
||||||
|
get(){
|
||||||
|
return get(this.value, 'priority')
|
||||||
|
},
|
||||||
|
set(key, val){
|
||||||
|
const old = get(this.value, 'priority')
|
||||||
|
|
||||||
|
set(this.value, 'priority', val)
|
||||||
|
this.typeChanged(old, val)
|
||||||
|
|
||||||
|
return val
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
|
||||||
|
anti: computed('affinityOptions', 'value.anti', {
|
||||||
|
get(){
|
||||||
|
const isAnti = get(this.value, 'anti')
|
||||||
|
|
||||||
|
|
||||||
|
return isAnti ? 'true' : 'false'
|
||||||
|
},
|
||||||
|
set(key, val){
|
||||||
|
const old = get(this, 'anti') === 'true'
|
||||||
|
const neu = val === 'true'
|
||||||
|
|
||||||
|
set(this.value, 'anti', neu)
|
||||||
|
|
||||||
|
this.antiChanged(old, neu)
|
||||||
|
|
||||||
|
return val
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
|
||||||
namespaceMode: namespaceModes.ALL,
|
namespaceMode: namespaceModes.ALL,
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,34 @@
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
{{/if }}
|
{{/if }}
|
||||||
|
<div class="row mt-10">
|
||||||
|
<div class="col span-6">
|
||||||
|
{{!-- <label class="acc-label">
|
||||||
|
{{t "clusterNew.agentConfig.overrideAffinity.podAffinity.priority"}}
|
||||||
|
</label> --}}
|
||||||
|
<NewSelect
|
||||||
|
@class="form-control"
|
||||||
|
@value={{priority}}
|
||||||
|
@optionLabelPath="label"
|
||||||
|
@optionValuePath="value"
|
||||||
|
@localizedLabel={{true}}
|
||||||
|
@content={{priorityOptions}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="col span-6">
|
||||||
|
{{!-- <label class="acc-label">
|
||||||
|
{{t "clusterNew.agentConfig.overrideAffinity.podAffinity.priority"}}
|
||||||
|
</label> --}}
|
||||||
|
<NewSelect
|
||||||
|
@class="form-control"
|
||||||
|
@value={{anti}}
|
||||||
|
@optionLabelPath="label"
|
||||||
|
@optionValuePath="value"
|
||||||
|
@localizedLabel={{true}}
|
||||||
|
@content={{affinityOptions}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col span-12">
|
<div class="col span-12">
|
||||||
<div class="radio">
|
<div class="radio">
|
||||||
|
|
|
||||||
|
|
@ -3360,16 +3360,21 @@ clusterNew:
|
||||||
title: Pod AntiAffinity
|
title: Pod AntiAffinity
|
||||||
podAffinity:
|
podAffinity:
|
||||||
title: Pod Affinity
|
title: Pod Affinity
|
||||||
addRequired: Add Required Pod Affinity Term
|
addTerm: Add Pod Affinity Term
|
||||||
addPreferred: Add Preferred Pod Affinity Term
|
|
||||||
topologyKey:
|
topologyKey:
|
||||||
label: Topology Key
|
label: Topology Key
|
||||||
placeholder: e.g. failure-domain.beta.kubernetes.io/zone
|
placeholder: e.g. failure-domain.beta.kubernetes.io/zone
|
||||||
|
typeOptions:
|
||||||
|
affinity: Affinity
|
||||||
|
antiAffinity: AntiAffinity
|
||||||
|
preferred: Preferred
|
||||||
|
required: Required
|
||||||
namespaces:
|
namespaces:
|
||||||
radioOptions:
|
radioOptions:
|
||||||
all: All Namespaces
|
all: All Namespaces
|
||||||
thisPod: This pod's namespace
|
thisPod: This pod's namespace
|
||||||
inList: 'Namespaces in this list:'
|
inList: 'Namespaces in this list:'
|
||||||
|
priority: Priority
|
||||||
nodeAffinity:
|
nodeAffinity:
|
||||||
title: Node Affinity
|
title: Node Affinity
|
||||||
aliyunack:
|
aliyunack:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue