feat(xo-web/kubernetes): add number of cp choice (#6809)

See xoa#120
This commit is contained in:
Gabriel Gunullu
2023-05-26 16:08:11 +02:00
committed by GitHub
parent 1816d0240e
commit eb84d4a7ef
5 changed files with 104 additions and 57 deletions

View File

@@ -13,6 +13,7 @@
- [REST API] _Rolling Pool Update_ action available `pools/<uuid>/actions/rolling_update`
- [Self Service] Ability to set a default value for the "Share VM" feature for Self Service users during creation/edition (PR [#6838](https://github.com/vatesfr/xen-orchestra/pull/6838))
- [Self service] Add default tags to all VMs that will be created by a Self Service (PRs [#6810](https://github.com/vatesfr/xen-orchestra/pull/6810), [#6812](https://github.com/vatesfr/xen-orchestra/pull/6812))
- [Kubernetes] Add the possibility to choose the number of fault tolerance for the control planes (PR [#6809](https://github.com/vatesfr/xen-orchestra/pull/6809))
### Bug fixes

View File

@@ -683,6 +683,21 @@ export default {
// Original text: 'High Availability'
highAvailability: 'Alta disponibilità',
// Original text: 'Control plane fault tolerance'
recipeFaultTolerance: 'Tolleranza ai guasti del piano di controllo',
// Original text: 'No fault tolerance (one control plane)'
recipeNoneFaultTolerance: 'No fault tolerance (one control plane)',
// Original text: 'One fault tolerance (three control planes)'
recipeOneFaultTolerance: 'Una tolleranza ai guasti (tre piani di controllo)',
// Original text: 'Two fault tolerances (five control planes)'
recipeTwoFaultTolerance: 'Due tolleranze di errore (cinque piani di controllo)',
// Original text: 'Three fault tolerances (seven control planes)'
recipeThreeFaultTolerance: 'Tre tolleranze di errore (sette piani di controllo)',
// Original text: 'Shared {type}'
srSharedType: 'Condiviso {type}',

View File

@@ -2436,7 +2436,11 @@ const messages = {
recipeNumberOfNodesLabel: 'Number of worker nodes',
recipeSshKeyLabel: 'SSH key',
recipeStaticIpAddresses: 'Static IP addresses',
recipeHighAvailability: 'High Availability Cluster',
recipeFaultTolerance: 'Control plane fault tolerance',
recipeNoneFaultTolerance: 'No fault tolerance (one control plane)',
recipeOneFaultTolerance: 'One fault tolerance (three control planes)',
recipeTwoFaultTolerance: 'Two fault tolerances (five control planes)',
recipeThreeFaultTolerance: 'Three fault tolerances (seven control planes)',
recipeHaControPlaneIpAddress: 'Control plane { i, number } node IP address/subnet mask',
recipeVip: 'VIP address',
recipeControlPlaneIpAddress: 'Control plane node IP address/subnet mask',

View File

@@ -8,6 +8,26 @@ import { injectIntl } from 'react-intl'
import { injectState, provideState } from 'reaclette'
import { isSrWritable } from 'xo'
import { SelectPool, SelectNetwork, SelectSr } from 'select-objects'
import { Select } from 'form'
const FAULT_TOLERANCE = [
{
label: _('recipeNoneFaultTolerance'),
value: 0,
},
{
label: _('recipeOneFaultTolerance'),
value: 1,
},
{
label: _('recipeTwoFaultTolerance'),
value: 2,
},
{
label: _('recipeThreeFaultTolerance'),
value: 3,
},
]
export default decorate([
injectIntl,
@@ -42,6 +62,15 @@ export default decorate([
[name]: value,
})
},
onChangeFaultTolerance(__, faultTolerance) {
const { onChange, value } = this.props
onChange({
...value,
faultTolerance: faultTolerance.value,
// n * 2 + 1 is the formula to meet the quorum of RAFT consensus algorithm
controlPlanePoolSize: faultTolerance.value * 2 + 1,
})
},
onChangeWorkerIp(__, ev) {
const { name, value } = ev.target
const { onChange, value: prevValue } = this.props
@@ -149,17 +178,15 @@ export default decorate([
/>
</FormGrid.Row>
<FormGrid.Row>
<label>
<input
className='mt-1'
name='highAvailability'
onChange={effects.toggleStaticIpAddress}
type='checkbox'
value={value.highAvailability}
/>
&nbsp;
{_('recipeHighAvailability')}
</label>
<label>{_('recipeFaultTolerance')}</label>
<Select
className='mb-1'
name='faultTolerance'
onChange={effects.onChangeFaultTolerance}
options={FAULT_TOLERANCE}
required
value={value.faultTolerance}
/>
</FormGrid.Row>
<FormGrid.Row>
<label>
@@ -176,48 +203,49 @@ export default decorate([
</FormGrid.Row>
{value.nbNodes > 0 &&
value.staticIpAddress && [
value.highAvailability && [
Array.from({ length: 3 }).map((v, i) => (
<FormGrid.Row key={i}>
<label>{_('recipeHaControPlaneIpAddress', { i: i + 1 })}</label>
<input
className='form-control'
name={`controlPlaneIpAddress.${i}`}
onChange={effects.onChangeCpIp}
placeholder={formatMessage(messages.recipeHaControPlaneIpAddress, { i: i + 1 })}
required
type='text'
value={value[`controlPlaneIpAddress.${i}`]}
/>
</FormGrid.Row>
)),
<FormGrid.Row key='vipAddrRow'>
<label>{_('recipeVip')}</label>
<input
className='form-control'
name='vipAddress'
onChange={effects.onChangeValue}
placeholder={formatMessage(messages.recipeVip)}
required
type='text'
value={value.vipAddress}
/>
</FormGrid.Row>,
],
!value.highAvailability && [
<FormGrid.Row key='controlPlaneIpAddrRow'>
<label>{_('recipeControlPlaneIpAddress')}</label>
<input
className='form-control'
name='controlPlaneIpAddress'
onChange={effects.onChangeValue}
placeholder={formatMessage(messages.recipeControlPlaneIpAddress)}
required
type='text'
value={value.controlPlaneIpAddress}
/>
</FormGrid.Row>,
],
value.faultTolerance > 0
? [
Array.from({ length: value.controlPlanePoolSize }).map((v, i) => (
<FormGrid.Row key={i}>
<label>{_('recipeHaControPlaneIpAddress', { i: i + 1 })}</label>
<input
className='form-control'
name={`controlPlaneIpAddress.${i}`}
onChange={effects.onChangeCpIp}
placeholder={formatMessage(messages.recipeHaControPlaneIpAddress, { i: i + 1 })}
required
type='text'
value={value[`controlPlaneIpAddress.${i}`]}
/>
</FormGrid.Row>
)),
<FormGrid.Row key='vipAddrRow'>
<label>{_('recipeVip')}</label>
<input
className='form-control'
name='vipAddress'
onChange={effects.onChangeValue}
placeholder={formatMessage(messages.recipeVip)}
required
type='text'
value={value.vipAddress}
/>
</FormGrid.Row>,
]
: [
<FormGrid.Row key='controlPlaneIpAddrRow'>
<label>{_('recipeControlPlaneIpAddress')}</label>
<input
className='form-control'
name='controlPlaneIpAddress'
onChange={effects.onChangeValue}
placeholder={formatMessage(messages.recipeControlPlaneIpAddress)}
required
type='text'
value={value.controlPlaneIpAddress}
/>
</FormGrid.Row>,
],
<FormGrid.Row key='gatewayRow'>
<label>{_('recipeGatewayIpAddress')}</label>
<input

View File

@@ -55,7 +55,7 @@ export default decorate([
controlPlaneIpAddress,
controlPlaneIpAddresses,
gatewayIpAddress,
highAvailability,
controlPlanePoolSize,
nameservers,
nbNodes,
network,
@@ -68,12 +68,11 @@ export default decorate([
markRecipeAsCreating(RECIPE_INFO.id)
const tag = await createKubernetesCluster({
clusterName,
clusterName,
controlPlaneIpAddress,
controlPlaneIpAddresses,
gatewayIpAddress,
highAvailability,
controlPlanePoolSize,
nameservers,
nbNodes: +nbNodes,
network: network.id,