Merge pull request #2145 from loganhz/node-name

Add node name in advacned options when adding custom cluster
This commit is contained in:
Westly Wright 2018-08-14 10:38:06 -07:00 committed by GitHub
commit caf931e0ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 41 additions and 1 deletions

View File

@ -7,6 +7,8 @@ import { satisfies } from 'shared/utils/parse-version';
import { sortVersions } from 'shared/utils/sort'; import { sortVersions } from 'shared/utils/sort';
import { inject as service } from '@ember/service'; import { inject as service } from '@ember/service';
import { underlineToCamel, removeEmpty, keysToCamel, validateEndpoint } from 'shared/utils/util'; import { underlineToCamel, removeEmpty, keysToCamel, validateEndpoint } from 'shared/utils/util';
import { validateHostname } from 'ember-api-store/utils/validate';
import C from 'shared/utils/constants'; import C from 'shared/utils/constants';
import YAML from 'npm:yamljs'; import YAML from 'npm:yamljs';
import json2yaml from 'npm:json2yaml'; import json2yaml from 'npm:json2yaml';
@ -84,6 +86,7 @@ export default InputTextFile.extend(ClusterDriver, {
registryUser: null, registryUser: null,
registryPass: null, registryPass: null,
clusterOptErrors: null, clusterOptErrors: null,
nodeNameErrors: null,
existingNodes: null, existingNodes: null,
initialNodeCounts: null, initialNodeCounts: null,
@ -259,6 +262,18 @@ export default InputTextFile.extend(ClusterDriver, {
}); });
}), }),
isNodeNameValid: computed('nodeName', function() {
if ( get(this, 'nodeName') === undefined || get(this, 'nodeName.length') === 0 ) {
return true;
} else {
const errors = validateHostname(get(this, 'nodeName'), 'Node Name', get(this, 'intl'));
set(this, 'nodeNameErrors', errors);
return errors.length === 0;
}
}),
isAddressValid: computed('address', function() { isAddressValid: computed('address', function() {
return get(this, 'address') === undefined || get(this, 'address.length') === 0 || validateEndpoint(get(this, 'address')); return get(this, 'address') === undefined || get(this, 'address.length') === 0 || validateEndpoint(get(this, 'address'));
}), }),
@ -280,7 +295,7 @@ export default InputTextFile.extend(ClusterDriver, {
return cur - orig; return cur - orig;
}), }),
command: computed('labels', 'token.nodeCommand', 'etcd', 'controlplane', 'worker', 'address', 'internalAddress', function() { command: computed('labels', 'token.nodeCommand', 'etcd', 'controlplane', 'worker', 'address', 'internalAddress', 'nodeName', function() {
let out = get(this, 'token.nodeCommand'); let out = get(this, 'token.nodeCommand');
if ( !out ) { if ( !out ) {
@ -288,10 +303,15 @@ export default InputTextFile.extend(ClusterDriver, {
} }
const address = get(this, 'address'); const address = get(this, 'address');
const nodeName = get(this, 'nodeName');
const internalAddress = get(this, 'internalAddress'); const internalAddress = get(this, 'internalAddress');
const roles = ['etcd', 'controlplane', 'worker']; const roles = ['etcd', 'controlplane', 'worker'];
const labels = get(this, 'labels') || {}; const labels = get(this, 'labels') || {};
if ( nodeName ) {
out += ` --node-name ${ nodeName }`;
}
if (address) { if (address) {
out += ` --address ${ address }`; out += ` --address ${ address }`;
} }

View File

@ -258,6 +258,22 @@
</li> </li>
</ul> </ul>
</div> </div>
<div class="row mt-20">
{{t 'clusterNew.rke.nodeName.title'}}
<p class="help-block">{{t 'clusterNew.rke.nodeName.detail'}}</p>
<ul class="list-unstyled">
<li>
<div class="row">
<div class="col span-6">
{{input type="text" value=nodeName placeholder=(t 'clusterNew.rke.nodeName.placeholder')}}
{{#unless isNodeNameValid}}
{{top-errors errors=nodeNameErrors}}
{{/unless}}
</div>
</div>
</li>
</ul>
</div>
<div class="row mt-20"> <div class="row mt-20">
{{t 'clusterNew.rke.labels.title'}} {{t 'clusterNew.rke.labels.title'}}
<p class="help-block">{{t 'clusterNew.rke.labels.detail'}}</p> <p class="help-block">{{t 'clusterNew.rke.labels.detail'}}</p>

View File

@ -2021,6 +2021,10 @@ clusterNew:
election: election:
label: etcd Election Timeout label: etcd Election Timeout
placeholder: Time for an election to timeout placeholder: Time for an election to timeout
nodeName:
title: Node Name
detail: Optionally configure the node name as identification instead of the actual hostname
placeholder: e.g. my-worker-node
address: address:
title: Node Address title: Node Address
detail: Optionally configure the public address and internal address for machines detail: Optionally configure the public address and internal address for machines