mirror of https://github.com/rancher/ui.git
Add form-gke-taints https://github.com/rancher/rancher/issues/16412
This commit is contained in:
parent
0c46dcf912
commit
e0ab35e901
|
|
@ -100,7 +100,7 @@ export default Component.extend(ClusterDriver, {
|
|||
let config = get(this, 'cluster.googleKubernetesEngineConfig');
|
||||
|
||||
if ( !config ) {
|
||||
config = this.get('globalStore').createRecord({
|
||||
config = get(this, 'globalStore').createRecord({
|
||||
type: 'googleKubernetesEngineConfig',
|
||||
diskSizeGb: 100,
|
||||
enableAlphaFeature: false,
|
||||
|
|
@ -112,6 +112,7 @@ export default Component.extend(ClusterDriver, {
|
|||
maxNodeCount: 1,
|
||||
imageType: 'UBUNTU',
|
||||
diskType: 'pd-standard',
|
||||
taints: [],
|
||||
});
|
||||
|
||||
setProperties(this, {
|
||||
|
|
@ -136,8 +137,47 @@ export default Component.extend(ClusterDriver, {
|
|||
stackdriverTrace: 'trace.append',
|
||||
cloudSourceRepositories: 'none',
|
||||
cloudDebugger: 'none'
|
||||
},
|
||||
resourceLabels: [],
|
||||
labels: [],
|
||||
taints: [],
|
||||
})
|
||||
} else {
|
||||
const {
|
||||
resourceLabels = [], labels = [], taints = []
|
||||
} = config
|
||||
let map = {}
|
||||
|
||||
if (resourceLabels) {
|
||||
resourceLabels.map((t = '') => {
|
||||
const split = t.split('=')
|
||||
|
||||
set(map, split[0], split[1])
|
||||
})
|
||||
set(this, 'resourceLabels', map)
|
||||
}
|
||||
|
||||
if (labels) {
|
||||
labels.map((t = '') => {
|
||||
const split = t.split('=')
|
||||
|
||||
set(map, split[0], split[1])
|
||||
})
|
||||
set(this, 'labels', map)
|
||||
}
|
||||
|
||||
let _taints = taints.map((t = '') => {
|
||||
const splitEffect = t.split(':')
|
||||
const splitLabel = (splitEffect[1] || '').split('=')
|
||||
|
||||
return {
|
||||
effect: splitEffect[0],
|
||||
key: splitLabel[0],
|
||||
value: splitLabel[1],
|
||||
}
|
||||
})
|
||||
|
||||
set(this, 'taints', _taints)
|
||||
}
|
||||
|
||||
set(this, 'initialMasterVersion', get(this, 'config.masterVersion'));
|
||||
|
|
@ -167,13 +207,21 @@ export default Component.extend(ClusterDriver, {
|
|||
},
|
||||
|
||||
setLabels(section) {
|
||||
const out = section.filter((f) => f.key && f.value).map((s) => `${ s.key }=${ s.value }`)
|
||||
const out = []
|
||||
|
||||
for (let key in section) {
|
||||
out.pushObject(`${ key }=${ section[key] }`)
|
||||
}
|
||||
|
||||
set(this, 'config.resourceLabels', out);
|
||||
},
|
||||
|
||||
setNodeLabels(section) {
|
||||
const out = section.filter((f) => f.key && f.value).map((s) => `${ s.key }=${ s.value }`)
|
||||
const out = []
|
||||
|
||||
for (let key in section) {
|
||||
out.pushObject(`${ key }=${ section[key] }`)
|
||||
}
|
||||
|
||||
set(this, 'config.labels', out);
|
||||
},
|
||||
|
|
@ -181,6 +229,11 @@ export default Component.extend(ClusterDriver, {
|
|||
updateNameservers(nameservers) {
|
||||
set(this, 'config.masterAuthorizedNetworkCidrBlocks', nameservers);
|
||||
},
|
||||
|
||||
setTaints(value) {
|
||||
console.log(value, 'value')
|
||||
set(this, 'config.taints', value);
|
||||
},
|
||||
},
|
||||
|
||||
credentialChanged: observer('config.credential', function() {
|
||||
|
|
@ -510,10 +563,8 @@ export default Component.extend(ClusterDriver, {
|
|||
validate() {
|
||||
const model = get(this, 'cluster');
|
||||
const errors = model.validationErrors();
|
||||
const intl = get(this, 'intl')
|
||||
|
||||
const minNodeCount = get(this, 'config.minNodeCount')
|
||||
const maxNodeCount = get(this, 'config.maxNodeCount')
|
||||
const { intl, config = {} } = this
|
||||
const { minNodeCount, maxNodeCount } = config
|
||||
|
||||
if (maxNodeCount < minNodeCount) {
|
||||
errors.pushObject(intl.t('clusterNew.googlegke.maxNodeCount.minError'))
|
||||
|
|
@ -523,6 +574,16 @@ export default Component.extend(ClusterDriver, {
|
|||
errors.pushObject(intl.t('clusterNew.name.required'))
|
||||
}
|
||||
|
||||
const taints = get(this, 'taints') || []
|
||||
|
||||
if (taints.length > 0) {
|
||||
const filter = taints.filter((t) => !t.key || !t.value)
|
||||
|
||||
if (filter.length > 0) {
|
||||
errors.pushObject(intl.t('clusterNew.googlegke.taints.required'))
|
||||
}
|
||||
}
|
||||
|
||||
set(this, 'errors', errors);
|
||||
|
||||
return errors.length === 0;
|
||||
|
|
@ -545,7 +606,6 @@ export default Component.extend(ClusterDriver, {
|
|||
if (!get(this, 'config.useIpAliases')) {
|
||||
setProperties(config, {
|
||||
ipPolicyCreateSubnetwork: false,
|
||||
network: null,
|
||||
ipPolicyClusterSecondaryRangeName: null,
|
||||
ipPolicyClusterIpv4CidrBlock: null,
|
||||
ipPolicyServicesSecondaryRangeName: null,
|
||||
|
|
@ -599,6 +659,14 @@ export default Component.extend(ClusterDriver, {
|
|||
set(config, 'oauthScopes', arr)
|
||||
}
|
||||
|
||||
const taints = get(this, 'taints') || []
|
||||
|
||||
if (taints.length > 0) {
|
||||
set(config, 'taints', taints.map((t) => {
|
||||
return `${ t.effect }:${ t.key }=${ t.value }`
|
||||
}))
|
||||
}
|
||||
|
||||
setProperties(config, {
|
||||
issueClientCertificate: true,
|
||||
enablePrivateNodes: get(config, 'enablePrivateEndpoint'),
|
||||
|
|
|
|||
|
|
@ -428,13 +428,13 @@
|
|||
{{#if config.enableMasterAuthorizedNetwork}}
|
||||
<div class="col span-6">
|
||||
{{form-value-array
|
||||
initialValues=config.masterAuthorizedNetworkCidrBlocks
|
||||
editing=(or (eq mode 'edit') (eq mode 'new'))
|
||||
valueLabel="clusterNew.googlegke.masterAuthorizedNetworkCidrBlocks.label"
|
||||
valuePlaceholder="clusterNew.googlegke.masterAuthorizedNetworkCidrBlocks.placeholder"
|
||||
addActionLabel="clusterNew.googlegke.masterAuthorizedNetworkCidrBlocks.addActionLabel"
|
||||
changed=(action "updateNameservers")
|
||||
cannotAdd=(gt config.masterAuthorizedNetworkCidrBlocks.length 10)
|
||||
initialValues=config.masterAuthorizedNetworkCidrBlocks
|
||||
editing=(or (eq mode 'edit') (eq mode 'new'))
|
||||
valueLabel="clusterNew.googlegke.masterAuthorizedNetworkCidrBlocks.label"
|
||||
valuePlaceholder="clusterNew.googlegke.masterAuthorizedNetworkCidrBlocks.placeholder"
|
||||
addActionLabel="clusterNew.googlegke.masterAuthorizedNetworkCidrBlocks.addActionLabel"
|
||||
changed=(action "updateNameservers")
|
||||
cannotAdd=(gt config.masterAuthorizedNetworkCidrBlocks.length 10)
|
||||
}}
|
||||
</div>
|
||||
{{/if}}
|
||||
|
|
@ -443,19 +443,12 @@
|
|||
|
||||
<div class="row mt-20">
|
||||
<div class="col span-12 mb-0">
|
||||
<label class="acc-label">{{t 'clusterNew.huaweicce.clusterLabels.label'}}</label>
|
||||
{{#if editing}}
|
||||
{{#if (gt config.resourceLabels.length 0)}}
|
||||
{{huawei-user-labels
|
||||
readOnly=true
|
||||
initialLabels=config.resourceLabels
|
||||
}}
|
||||
{{else}}
|
||||
<div>{{t 'clusterNew.huaweicce.clusterLabels.none'}}</div>
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{huawei-user-labels setLabels=(action 'setLabels')}}
|
||||
{{/if}}
|
||||
<label class="acc-label">{{t "clusterNew.googlegke.clusterLabels.label"}}</label>
|
||||
{{form-key-value
|
||||
initialMap=resourceLabels
|
||||
changed=(action 'setLabels')
|
||||
addActionLabel="clusterNew.googlegke.nodeLabels.addAction"
|
||||
}}
|
||||
</div>
|
||||
</div>
|
||||
{{/accordion-list-item}}
|
||||
|
|
@ -639,21 +632,20 @@
|
|||
{{/if}}
|
||||
</div>
|
||||
|
||||
{{form-gke-taints
|
||||
taints=taints
|
||||
editable=(eq mode 'new')
|
||||
}}
|
||||
|
||||
<div class="row mt-20">
|
||||
<div class="col span-12 mb-0">
|
||||
<label class="acc-label">{{t 'clusterNew.huaweicce.nodeLabels.label'}}</label>
|
||||
{{#if editing}}
|
||||
{{#if (gt config.labels.length 0)}}
|
||||
{{huawei-user-labels
|
||||
readOnly=true
|
||||
initialLabels=config.labels
|
||||
}}
|
||||
{{else}}
|
||||
<div>{{t 'clusterNew.huaweicce.nodeLabels.none'}}</div>
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{huawei-user-labels setLabels=(action 'setNodeLabels')}}
|
||||
{{/if}}
|
||||
<label class="acc-label">{{t 'clusterNew.googlegke.nodeLabels.label'}}</label>
|
||||
{{form-key-value
|
||||
initialMap=labels
|
||||
changed=(action 'setNodeLabels')
|
||||
addActionLabel="clusterNew.googlegke.nodeLabels.addAction"
|
||||
editing=(eq mode 'new')
|
||||
}}
|
||||
</div>
|
||||
</div>
|
||||
{{/accordion-list-item}}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,46 @@
|
|||
import { inject as service } from '@ember/service';
|
||||
import { get, computed } from '@ember/object';
|
||||
import Component from '@ember/component';
|
||||
import layout from './template';
|
||||
|
||||
const EFFECT = ['NO_SCHEDULE', 'PREFER_NO_SCHEDULE', 'NO_EXECUTE']
|
||||
|
||||
export default Component.extend({
|
||||
intl: service(),
|
||||
scope: service(),
|
||||
settings: service(),
|
||||
|
||||
layout,
|
||||
editing: false,
|
||||
showWarning: false,
|
||||
|
||||
taints: null,
|
||||
|
||||
init() {
|
||||
this._super(...arguments);
|
||||
},
|
||||
|
||||
actions: {
|
||||
addTaint() {
|
||||
get(this, 'taints').pushObject({
|
||||
effect: 'NO_SCHEDULE',
|
||||
key: '',
|
||||
value: '',
|
||||
});
|
||||
},
|
||||
|
||||
removeTaint(obj) {
|
||||
get(this, 'taints').removeObject(obj);
|
||||
},
|
||||
},
|
||||
|
||||
effectContent: computed(() => {
|
||||
return EFFECT.map((e) => {
|
||||
return {
|
||||
label: e,
|
||||
value: e,
|
||||
}
|
||||
})
|
||||
}),
|
||||
|
||||
});
|
||||
|
|
@ -0,0 +1,76 @@
|
|||
<label class="acc-label">{{t "clusterNew.googlegke.taints.label"}}</label>
|
||||
{{#if (gt taints.length 0)}}
|
||||
<table class="table fixed no-lines small mb-10">
|
||||
<thead>
|
||||
<tr class="hidden-sm">
|
||||
<th class="{{unless editing 'acc-label'}}">{{t 'clusterNew.googlegke.taints.effect.label'}}</th>
|
||||
<th width="10"></th>
|
||||
<th class="{{unless editing 'acc-label'}}">{{t 'clusterNew.googlegke.taints.key.label'}}{{field-required}}</th>
|
||||
<th width="10"></th>
|
||||
<th class="{{unless editing 'acc-label'}}">{{t 'clusterNew.googlegke.taints.value.label'}}{{field-required}}</th>
|
||||
<th width="40"> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#each taints as |taint|}}
|
||||
<tr>
|
||||
<td>
|
||||
{{#input-or-display
|
||||
editable=editable
|
||||
value=taint.effect
|
||||
}}
|
||||
{{searchable-select
|
||||
class="form-control"
|
||||
content=effectContent
|
||||
value=taint.effect
|
||||
}}
|
||||
{{/input-or-display}}
|
||||
</td>
|
||||
<td> </td>
|
||||
|
||||
<td>
|
||||
{{#input-or-display
|
||||
editable=editable
|
||||
value=taint.key
|
||||
}}
|
||||
{{input
|
||||
class="form-control"
|
||||
value=taint.key
|
||||
placeholder=(t "clusterNew.googlegke.taints.key.placeholder")
|
||||
}}
|
||||
{{/input-or-display}}
|
||||
</td>
|
||||
<td> </td>
|
||||
|
||||
<td>
|
||||
{{#input-or-display
|
||||
editable=editable
|
||||
value=taint.value
|
||||
}}
|
||||
{{input
|
||||
class="form-control"
|
||||
value=taint.value
|
||||
placeholder=(t "clusterNew.googlegke.taints.value.placeholder")
|
||||
}}
|
||||
{{/input-or-display}}
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<button class="btn bg-primary btn-sm" {{action "removeTaint" taint}}>
|
||||
<i class="icon icon-minus"/><span class="sr-only">{{t 'generic.remove'}}</span>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</tbody>
|
||||
</table>
|
||||
{{/if}}
|
||||
|
||||
{{#if editable}}
|
||||
<div>
|
||||
<button class="btn bg-link icon-btn p-0" {{action "addTaint"}}>
|
||||
<span class="darken"><i class="icon icon-plus text-small"/></span>
|
||||
<span>{{t "clusterNew.googlegke.taints.addAction"}}</span>
|
||||
</button>
|
||||
</div>
|
||||
{{/if}}
|
||||
|
|
@ -0,0 +1 @@
|
|||
export { default } from 'shared/components/form-gke-taints/component';
|
||||
|
|
@ -2522,6 +2522,9 @@ clusterNew:
|
|||
label: Node Subnet
|
||||
nodeLabels:
|
||||
label: Node Labels
|
||||
addAction: Add Label
|
||||
clusterLabels:
|
||||
label: Cluster Labels
|
||||
localSsdCount:
|
||||
label: Local SSD disks
|
||||
diskType:
|
||||
|
|
@ -2575,6 +2578,18 @@ clusterNew:
|
|||
label: Cloud Source Repositories
|
||||
cloudDebugger:
|
||||
label: Cloud Debugger
|
||||
taints:
|
||||
label: Taints
|
||||
addAction: Add Taint
|
||||
effect:
|
||||
label: Effect
|
||||
key:
|
||||
label: Key
|
||||
placeholder: Key
|
||||
value:
|
||||
label: Value
|
||||
placeholder: Value
|
||||
required: 'Taint "key" and "value" are required.'
|
||||
huaweicce:
|
||||
label: Huawei Cloud Container Engine
|
||||
shortLabel: Huawei CCE
|
||||
|
|
|
|||
|
|
@ -2283,6 +2283,23 @@ clusterNew:
|
|||
label: 网络
|
||||
subNetwork:
|
||||
label: 子网
|
||||
taints:
|
||||
label: 节点污点
|
||||
addAction: 添加污点
|
||||
effect:
|
||||
label: 效果
|
||||
key:
|
||||
label: 键
|
||||
placeholder: 键
|
||||
value:
|
||||
label: 值
|
||||
placeholder: 值
|
||||
required: '必须填写污点键和值'
|
||||
nodeLabels:
|
||||
label: 节点标签
|
||||
addAction: 添加标签
|
||||
clusterLabels:
|
||||
label: 集群标签
|
||||
header:
|
||||
iPAllocationPolicy: IP Allocation策略
|
||||
privateCluster: 私有集群
|
||||
|
|
|
|||
Loading…
Reference in New Issue