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');
|
let config = get(this, 'cluster.googleKubernetesEngineConfig');
|
||||||
|
|
||||||
if ( !config ) {
|
if ( !config ) {
|
||||||
config = this.get('globalStore').createRecord({
|
config = get(this, 'globalStore').createRecord({
|
||||||
type: 'googleKubernetesEngineConfig',
|
type: 'googleKubernetesEngineConfig',
|
||||||
diskSizeGb: 100,
|
diskSizeGb: 100,
|
||||||
enableAlphaFeature: false,
|
enableAlphaFeature: false,
|
||||||
|
|
@ -112,6 +112,7 @@ export default Component.extend(ClusterDriver, {
|
||||||
maxNodeCount: 1,
|
maxNodeCount: 1,
|
||||||
imageType: 'UBUNTU',
|
imageType: 'UBUNTU',
|
||||||
diskType: 'pd-standard',
|
diskType: 'pd-standard',
|
||||||
|
taints: [],
|
||||||
});
|
});
|
||||||
|
|
||||||
setProperties(this, {
|
setProperties(this, {
|
||||||
|
|
@ -136,8 +137,47 @@ export default Component.extend(ClusterDriver, {
|
||||||
stackdriverTrace: 'trace.append',
|
stackdriverTrace: 'trace.append',
|
||||||
cloudSourceRepositories: 'none',
|
cloudSourceRepositories: 'none',
|
||||||
cloudDebugger: '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'));
|
set(this, 'initialMasterVersion', get(this, 'config.masterVersion'));
|
||||||
|
|
@ -167,13 +207,21 @@ export default Component.extend(ClusterDriver, {
|
||||||
},
|
},
|
||||||
|
|
||||||
setLabels(section) {
|
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);
|
set(this, 'config.resourceLabels', out);
|
||||||
},
|
},
|
||||||
|
|
||||||
setNodeLabels(section) {
|
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);
|
set(this, 'config.labels', out);
|
||||||
},
|
},
|
||||||
|
|
@ -181,6 +229,11 @@ export default Component.extend(ClusterDriver, {
|
||||||
updateNameservers(nameservers) {
|
updateNameservers(nameservers) {
|
||||||
set(this, 'config.masterAuthorizedNetworkCidrBlocks', nameservers);
|
set(this, 'config.masterAuthorizedNetworkCidrBlocks', nameservers);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
setTaints(value) {
|
||||||
|
console.log(value, 'value')
|
||||||
|
set(this, 'config.taints', value);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
credentialChanged: observer('config.credential', function() {
|
credentialChanged: observer('config.credential', function() {
|
||||||
|
|
@ -510,10 +563,8 @@ export default Component.extend(ClusterDriver, {
|
||||||
validate() {
|
validate() {
|
||||||
const model = get(this, 'cluster');
|
const model = get(this, 'cluster');
|
||||||
const errors = model.validationErrors();
|
const errors = model.validationErrors();
|
||||||
const intl = get(this, 'intl')
|
const { intl, config = {} } = this
|
||||||
|
const { minNodeCount, maxNodeCount } = config
|
||||||
const minNodeCount = get(this, 'config.minNodeCount')
|
|
||||||
const maxNodeCount = get(this, 'config.maxNodeCount')
|
|
||||||
|
|
||||||
if (maxNodeCount < minNodeCount) {
|
if (maxNodeCount < minNodeCount) {
|
||||||
errors.pushObject(intl.t('clusterNew.googlegke.maxNodeCount.minError'))
|
errors.pushObject(intl.t('clusterNew.googlegke.maxNodeCount.minError'))
|
||||||
|
|
@ -523,6 +574,16 @@ export default Component.extend(ClusterDriver, {
|
||||||
errors.pushObject(intl.t('clusterNew.name.required'))
|
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);
|
set(this, 'errors', errors);
|
||||||
|
|
||||||
return errors.length === 0;
|
return errors.length === 0;
|
||||||
|
|
@ -545,7 +606,6 @@ export default Component.extend(ClusterDriver, {
|
||||||
if (!get(this, 'config.useIpAliases')) {
|
if (!get(this, 'config.useIpAliases')) {
|
||||||
setProperties(config, {
|
setProperties(config, {
|
||||||
ipPolicyCreateSubnetwork: false,
|
ipPolicyCreateSubnetwork: false,
|
||||||
network: null,
|
|
||||||
ipPolicyClusterSecondaryRangeName: null,
|
ipPolicyClusterSecondaryRangeName: null,
|
||||||
ipPolicyClusterIpv4CidrBlock: null,
|
ipPolicyClusterIpv4CidrBlock: null,
|
||||||
ipPolicyServicesSecondaryRangeName: null,
|
ipPolicyServicesSecondaryRangeName: null,
|
||||||
|
|
@ -599,6 +659,14 @@ export default Component.extend(ClusterDriver, {
|
||||||
set(config, 'oauthScopes', arr)
|
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, {
|
setProperties(config, {
|
||||||
issueClientCertificate: true,
|
issueClientCertificate: true,
|
||||||
enablePrivateNodes: get(config, 'enablePrivateEndpoint'),
|
enablePrivateNodes: get(config, 'enablePrivateEndpoint'),
|
||||||
|
|
|
||||||
|
|
@ -428,13 +428,13 @@
|
||||||
{{#if config.enableMasterAuthorizedNetwork}}
|
{{#if config.enableMasterAuthorizedNetwork}}
|
||||||
<div class="col span-6">
|
<div class="col span-6">
|
||||||
{{form-value-array
|
{{form-value-array
|
||||||
initialValues=config.masterAuthorizedNetworkCidrBlocks
|
initialValues=config.masterAuthorizedNetworkCidrBlocks
|
||||||
editing=(or (eq mode 'edit') (eq mode 'new'))
|
editing=(or (eq mode 'edit') (eq mode 'new'))
|
||||||
valueLabel="clusterNew.googlegke.masterAuthorizedNetworkCidrBlocks.label"
|
valueLabel="clusterNew.googlegke.masterAuthorizedNetworkCidrBlocks.label"
|
||||||
valuePlaceholder="clusterNew.googlegke.masterAuthorizedNetworkCidrBlocks.placeholder"
|
valuePlaceholder="clusterNew.googlegke.masterAuthorizedNetworkCidrBlocks.placeholder"
|
||||||
addActionLabel="clusterNew.googlegke.masterAuthorizedNetworkCidrBlocks.addActionLabel"
|
addActionLabel="clusterNew.googlegke.masterAuthorizedNetworkCidrBlocks.addActionLabel"
|
||||||
changed=(action "updateNameservers")
|
changed=(action "updateNameservers")
|
||||||
cannotAdd=(gt config.masterAuthorizedNetworkCidrBlocks.length 10)
|
cannotAdd=(gt config.masterAuthorizedNetworkCidrBlocks.length 10)
|
||||||
}}
|
}}
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
@ -443,19 +443,12 @@
|
||||||
|
|
||||||
<div class="row mt-20">
|
<div class="row mt-20">
|
||||||
<div class="col span-12 mb-0">
|
<div class="col span-12 mb-0">
|
||||||
<label class="acc-label">{{t 'clusterNew.huaweicce.clusterLabels.label'}}</label>
|
<label class="acc-label">{{t "clusterNew.googlegke.clusterLabels.label"}}</label>
|
||||||
{{#if editing}}
|
{{form-key-value
|
||||||
{{#if (gt config.resourceLabels.length 0)}}
|
initialMap=resourceLabels
|
||||||
{{huawei-user-labels
|
changed=(action 'setLabels')
|
||||||
readOnly=true
|
addActionLabel="clusterNew.googlegke.nodeLabels.addAction"
|
||||||
initialLabels=config.resourceLabels
|
}}
|
||||||
}}
|
|
||||||
{{else}}
|
|
||||||
<div>{{t 'clusterNew.huaweicce.clusterLabels.none'}}</div>
|
|
||||||
{{/if}}
|
|
||||||
{{else}}
|
|
||||||
{{huawei-user-labels setLabels=(action 'setLabels')}}
|
|
||||||
{{/if}}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{/accordion-list-item}}
|
{{/accordion-list-item}}
|
||||||
|
|
@ -639,21 +632,20 @@
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{{form-gke-taints
|
||||||
|
taints=taints
|
||||||
|
editable=(eq mode 'new')
|
||||||
|
}}
|
||||||
|
|
||||||
<div class="row mt-20">
|
<div class="row mt-20">
|
||||||
<div class="col span-12 mb-0">
|
<div class="col span-12 mb-0">
|
||||||
<label class="acc-label">{{t 'clusterNew.huaweicce.nodeLabels.label'}}</label>
|
<label class="acc-label">{{t 'clusterNew.googlegke.nodeLabels.label'}}</label>
|
||||||
{{#if editing}}
|
{{form-key-value
|
||||||
{{#if (gt config.labels.length 0)}}
|
initialMap=labels
|
||||||
{{huawei-user-labels
|
changed=(action 'setNodeLabels')
|
||||||
readOnly=true
|
addActionLabel="clusterNew.googlegke.nodeLabels.addAction"
|
||||||
initialLabels=config.labels
|
editing=(eq mode 'new')
|
||||||
}}
|
}}
|
||||||
{{else}}
|
|
||||||
<div>{{t 'clusterNew.huaweicce.nodeLabels.none'}}</div>
|
|
||||||
{{/if}}
|
|
||||||
{{else}}
|
|
||||||
{{huawei-user-labels setLabels=(action 'setNodeLabels')}}
|
|
||||||
{{/if}}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{/accordion-list-item}}
|
{{/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
|
label: Node Subnet
|
||||||
nodeLabels:
|
nodeLabels:
|
||||||
label: Node Labels
|
label: Node Labels
|
||||||
|
addAction: Add Label
|
||||||
|
clusterLabels:
|
||||||
|
label: Cluster Labels
|
||||||
localSsdCount:
|
localSsdCount:
|
||||||
label: Local SSD disks
|
label: Local SSD disks
|
||||||
diskType:
|
diskType:
|
||||||
|
|
@ -2575,6 +2578,18 @@ clusterNew:
|
||||||
label: Cloud Source Repositories
|
label: Cloud Source Repositories
|
||||||
cloudDebugger:
|
cloudDebugger:
|
||||||
label: Cloud Debugger
|
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:
|
huaweicce:
|
||||||
label: Huawei Cloud Container Engine
|
label: Huawei Cloud Container Engine
|
||||||
shortLabel: Huawei CCE
|
shortLabel: Huawei CCE
|
||||||
|
|
|
||||||
|
|
@ -2283,6 +2283,23 @@ clusterNew:
|
||||||
label: 网络
|
label: 网络
|
||||||
subNetwork:
|
subNetwork:
|
||||||
label: 子网
|
label: 子网
|
||||||
|
taints:
|
||||||
|
label: 节点污点
|
||||||
|
addAction: 添加污点
|
||||||
|
effect:
|
||||||
|
label: 效果
|
||||||
|
key:
|
||||||
|
label: 键
|
||||||
|
placeholder: 键
|
||||||
|
value:
|
||||||
|
label: 值
|
||||||
|
placeholder: 值
|
||||||
|
required: '必须填写污点键和值'
|
||||||
|
nodeLabels:
|
||||||
|
label: 节点标签
|
||||||
|
addAction: 添加标签
|
||||||
|
clusterLabels:
|
||||||
|
label: 集群标签
|
||||||
header:
|
header:
|
||||||
iPAllocationPolicy: IP Allocation策略
|
iPAllocationPolicy: IP Allocation策略
|
||||||
privateCluster: 私有集群
|
privateCluster: 私有集群
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue