mirror of https://github.com/rancher/ui.git
Support GKE regional or zonal clusters
https://github.com/rancher/rancher/issues/22045
This commit is contained in:
parent
941d91fa58
commit
72d594d5c9
|
|
@ -71,8 +71,12 @@ const diskType = [
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
const REGIONS = ['asia-east1', 'asia-east2', 'asia-northeast1', 'asia-northeast2', 'asia-south1', 'asia-southeast1', 'australia-southeast1', 'europe-north1', 'europe-west1', 'europe-west2', 'europe-west3', 'europe-west4', 'europe-west6', 'northamerica-northeast1', 'southamerica-east1', 'us-central1', 'us-east1', 'us-east4', 'us-west1', 'us-west2']
|
||||||
|
|
||||||
const DEFAULT_AUTH_SCOPES = ['devstorage.read_only', 'logging.write', 'monitoring', 'servicecontrol', 'service.management.readonly', 'trace.append']
|
const DEFAULT_AUTH_SCOPES = ['devstorage.read_only', 'logging.write', 'monitoring', 'servicecontrol', 'service.management.readonly', 'trace.append']
|
||||||
|
|
||||||
|
const ZONE_TYPE = 'zonal';
|
||||||
|
const REGION_TYPE = 'regional';
|
||||||
|
|
||||||
export default Component.extend(ClusterDriver, {
|
export default Component.extend(ClusterDriver, {
|
||||||
intl: service(),
|
intl: service(),
|
||||||
|
|
@ -94,6 +98,7 @@ export default Component.extend(ClusterDriver, {
|
||||||
diskTypeContent: diskType,
|
diskTypeContent: diskType,
|
||||||
scopeConfig: {},
|
scopeConfig: {},
|
||||||
hideNewField: false,
|
hideNewField: false,
|
||||||
|
locationType: ZONE_TYPE,
|
||||||
|
|
||||||
isNew: equal('mode', 'new'),
|
isNew: equal('mode', 'new'),
|
||||||
editing: equal('mode', 'edit'),
|
editing: equal('mode', 'edit'),
|
||||||
|
|
@ -116,6 +121,7 @@ export default Component.extend(ClusterDriver, {
|
||||||
maxNodeCount: 5,
|
maxNodeCount: 5,
|
||||||
imageType: 'UBUNTU',
|
imageType: 'UBUNTU',
|
||||||
diskType: 'pd-standard',
|
diskType: 'pd-standard',
|
||||||
|
region: 'us-west2',
|
||||||
taints: [],
|
taints: [],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -193,7 +199,13 @@ export default Component.extend(ClusterDriver, {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
set(this, 'initialMasterVersion', get(this, 'config.masterVersion'));
|
setProperties(this, {
|
||||||
|
initialMasterVersion: get(this, 'config.masterVersion'),
|
||||||
|
regionChoices: REGIONS.map((region) => {
|
||||||
|
return { name: region }
|
||||||
|
}),
|
||||||
|
locationType: get(this, 'config.zone') ? ZONE_TYPE : REGION_TYPE,
|
||||||
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
|
|
@ -410,6 +422,10 @@ export default Component.extend(ClusterDriver, {
|
||||||
|
|
||||||
locationContent: computed('config.zone', function() {
|
locationContent: computed('config.zone', function() {
|
||||||
const zone = get(this, 'config.zone')
|
const zone = get(this, 'config.zone')
|
||||||
|
|
||||||
|
if ( !zone ) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
const arr = zone.split('-')
|
const arr = zone.split('-')
|
||||||
const locationName = `${ arr[0] }-${ arr[1] }`
|
const locationName = `${ arr[0] }-${ arr[1] }`
|
||||||
const zoneChoices = get(this, 'zoneChoices')
|
const zoneChoices = get(this, 'zoneChoices')
|
||||||
|
|
@ -502,7 +518,7 @@ export default Component.extend(ClusterDriver, {
|
||||||
data: {
|
data: {
|
||||||
credentials: get(this, 'config.credential'),
|
credentials: get(this, 'config.credential'),
|
||||||
projectId: get(this, 'config.projectId'),
|
projectId: get(this, 'config.projectId'),
|
||||||
zone: get(this, 'config.zone'),
|
zone: get(this, 'config.zone') || `${ get(this, 'config.region') }-b`,
|
||||||
}
|
}
|
||||||
}).then((xhr) => {
|
}).then((xhr) => {
|
||||||
const out = xhr.body;
|
const out = xhr.body;
|
||||||
|
|
@ -525,7 +541,7 @@ export default Component.extend(ClusterDriver, {
|
||||||
data: {
|
data: {
|
||||||
credentials: get(this, 'config.credential'),
|
credentials: get(this, 'config.credential'),
|
||||||
projectId: get(this, 'config.projectId'),
|
projectId: get(this, 'config.projectId'),
|
||||||
zone: get(this, 'config.zone'),
|
zone: get(this, 'config.zone') || `${ get(this, 'config.region') }-b`,
|
||||||
}
|
}
|
||||||
}).then((xhr) => {
|
}).then((xhr) => {
|
||||||
const out = xhr.body.items;
|
const out = xhr.body.items;
|
||||||
|
|
@ -568,7 +584,7 @@ export default Component.extend(ClusterDriver, {
|
||||||
|
|
||||||
fetchSubnetworks() {
|
fetchSubnetworks() {
|
||||||
const zone = get(this, 'config.zone')
|
const zone = get(this, 'config.zone')
|
||||||
const zoneSplit = zone.split('-')
|
const locationType = get(this, 'locationType');
|
||||||
|
|
||||||
return get(this, 'globalStore').rawRequest({
|
return get(this, 'globalStore').rawRequest({
|
||||||
url: '/meta/gkeSubnetworks',
|
url: '/meta/gkeSubnetworks',
|
||||||
|
|
@ -576,7 +592,7 @@ export default Component.extend(ClusterDriver, {
|
||||||
data: {
|
data: {
|
||||||
credentials: get(this, 'config.credential'),
|
credentials: get(this, 'config.credential'),
|
||||||
projectId: get(this, 'config.projectId'),
|
projectId: get(this, 'config.projectId'),
|
||||||
region: `${ zoneSplit[0] }-${ zoneSplit[1] }`,
|
region: locationType === ZONE_TYPE ? `${ zone.split('-')[0] }-${ zone.split('-')[1] }` : get(this, 'config.region'),
|
||||||
}
|
}
|
||||||
}).then((xhr) => {
|
}).then((xhr) => {
|
||||||
const out = xhr.body.items || [];
|
const out = xhr.body.items || [];
|
||||||
|
|
@ -678,6 +694,14 @@ export default Component.extend(ClusterDriver, {
|
||||||
willSave() {
|
willSave() {
|
||||||
const config = get(this, 'config') || {}
|
const config = get(this, 'config') || {}
|
||||||
|
|
||||||
|
const locationType = get(this, 'locationType');
|
||||||
|
|
||||||
|
if ( locationType === ZONE_TYPE ) {
|
||||||
|
set(config, 'region', null);
|
||||||
|
} else {
|
||||||
|
set(config, 'zone', null);
|
||||||
|
}
|
||||||
|
|
||||||
if (!get(config, 'enableNodepoolAutoscaling')) {
|
if (!get(config, 'enableNodepoolAutoscaling')) {
|
||||||
setProperties(config, {
|
setProperties(config, {
|
||||||
minNodeCount: 0,
|
minNodeCount: 0,
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,29 @@
|
||||||
}}
|
}}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col span-6">
|
<div class="col span-6">
|
||||||
|
<label class="acc-label">
|
||||||
|
{{t "clusterNew.googlegke.locationType.label"}}
|
||||||
|
</label>
|
||||||
|
{{#input-or-display
|
||||||
|
editable=isNew
|
||||||
|
value=locationType
|
||||||
|
}}
|
||||||
|
<div class="radio">
|
||||||
|
<label>
|
||||||
|
{{radio-button selection=locationType value="zonal"}}
|
||||||
|
{{t "clusterNew.googlegke.locationType.zone"}}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="radio">
|
||||||
|
<label>
|
||||||
|
{{radio-button selection=locationType value="regional"}}
|
||||||
|
{{t "clusterNew.googlegke.locationType.region"}}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
{{/input-or-display}}
|
||||||
|
</div>
|
||||||
|
{{#if (eq locationType "zonal")}}
|
||||||
|
<div class="col span-4">
|
||||||
<label class="acc-label">
|
<label class="acc-label">
|
||||||
{{t "clusterNew.googlegke.zone.label"}}
|
{{t "clusterNew.googlegke.zone.label"}}
|
||||||
</label>
|
</label>
|
||||||
|
|
@ -64,7 +87,7 @@
|
||||||
{{/input-or-display}}
|
{{/input-or-display}}
|
||||||
</div>
|
</div>
|
||||||
{{#unless hideNewField}}
|
{{#unless hideNewField}}
|
||||||
<div class="col span-6">
|
<div class="col span-2">
|
||||||
<label class="acc-label">
|
<label class="acc-label">
|
||||||
{{t "clusterNew.googlegke.locations.label"}}
|
{{t "clusterNew.googlegke.locations.label"}}
|
||||||
</label>
|
</label>
|
||||||
|
|
@ -82,6 +105,30 @@
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</div>
|
</div>
|
||||||
{{/unless}}
|
{{/unless}}
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{#if (eq locationType "regional")}}
|
||||||
|
<div class="col span-6">
|
||||||
|
<label class="acc-label">
|
||||||
|
{{t "clusterNew.googlegke.region.label"}}
|
||||||
|
</label>
|
||||||
|
{{#input-or-display
|
||||||
|
editable=isNew
|
||||||
|
value=config.region
|
||||||
|
}}
|
||||||
|
{{new-select
|
||||||
|
classNames="form-control select-algin-checkbox"
|
||||||
|
optionValuePath="name"
|
||||||
|
optionLabelPath="name"
|
||||||
|
content=regionChoices
|
||||||
|
value=config.region
|
||||||
|
prompt="clusterNew.googlegke.region.prompt"
|
||||||
|
localizedPrompt=true
|
||||||
|
disabled=editing
|
||||||
|
}}
|
||||||
|
{{/input-or-display}}
|
||||||
|
</div>
|
||||||
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
|
||||||
|
|
@ -2884,6 +2884,13 @@ clusterNew:
|
||||||
project:
|
project:
|
||||||
label: Project
|
label: Project
|
||||||
placeholder: e.g. my-project
|
placeholder: e.g. my-project
|
||||||
|
locationType:
|
||||||
|
label: Location Type
|
||||||
|
zone: Zonal
|
||||||
|
region: Regional
|
||||||
|
region:
|
||||||
|
label: Region
|
||||||
|
prompt: Choose a Region...
|
||||||
machineType:
|
machineType:
|
||||||
label: Machine Type
|
label: Machine Type
|
||||||
prompt: Choose a Type...
|
prompt: Choose a Type...
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue