Merge pull request #2163 from loganhz/port

Support service node port range in cluster options
This commit is contained in:
Westly Wright 2018-08-23 12:02:14 -07:00 committed by GitHub
commit fa036dfbdd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 65 additions and 8 deletions

View File

@ -19,6 +19,7 @@ const protocolOptions = [
export default Component.extend({
intl: service(),
scope: service(),
layout,
initialPorts: null,
@ -26,11 +27,15 @@ export default Component.extend({
kindChoices: null,
ports: null,
nodePortFrom: null,
nodePortTo: null,
nodePortPlaceholder: null,
protocolOptions,
init() {
this._super(...arguments);
this.initPorts();
this.nodePortRangeDidChange();
this.initKindChoices();
},
@ -113,6 +118,38 @@ export default Component.extend({
this.set('errors', errors.uniq());
this.sendAction('changed', ports.slice());
}),
nodePortRangeDidChange: observer('intl.locale', 'scope.currentCluster.rancherKubernetesEngineConfig.services.kubeApi.serviceNodePortRange', function() {
const intl = get(this, 'intl');
const nodePortRange = get(this, 'scope.currentCluster.rancherKubernetesEngineConfig.services.kubeApi.serviceNodePortRange')
if ( nodePortRange ) {
const ports = nodePortRange.split('-');
if ( ports.length === 2 ) {
const from = parseInt(ports[0], 10);
const to = parseInt(ports[1], 10);
setProperties(this, {
nodePortFrom: from,
nodePortTo: to,
nodePortPlaceholder: intl.t('formPorts.nodePort.customPortRangePlaceholder', {
range: nodePortRange,
port: from
})
});
return;
}
}
setProperties(this, {
nodePortFrom: 1,
nodePortTo: 65535,
nodePortPlaceholder: intl.t('formPorts.nodePort.placeholder')
});
}),
initPorts() {
let ports = get(this, 'initialPorts') || [];

View File

@ -61,7 +61,7 @@
<td data-title="{{t 'formPorts.sourcePort.label'}}">
{{#if (or (eq port.kind "ClusterIP") (eq port.kind "NodePort"))}}
{{#if editing}}
{{input-random-port min="1" max="65535" value=port.sourcePort placeholder="formPorts.nodePort.placeholder" standardKey=(if (eq port.kind "ClusterIP") "formPorts.sourcePort.clusterIpDefault" "generic.random")}}
{{input-random-port min=nodePortFrom max=nodePortTo value=port.sourcePort placeholder=nodePortPlaceholder standardKey=(if (eq port.kind "ClusterIP") "formPorts.sourcePort.clusterIpDefault" "generic.random")}}
{{else if port.sourcePort}}
{{port.sourcePort}}
{{else}}

View File

@ -1,5 +1,5 @@
{{#if showEdit}}
{{input-integer class="form-control input-sm" min=min max=max value=value placeholder=(t placeholder)}}
{{input-integer class="form-control input-sm" min=min max=max value=value placeholder=placeholder}}
{{else}}
<div class="edit btn bg-transparent pl-0" {{action "showEdit"}}>{{t standardKey}} <i class="icon icon-edit"></i></div>
{{/if}}

View File

@ -202,6 +202,7 @@ export default InputTextFile.extend(ClusterDriver, {
kubeApi: globalStore.createRecord({
type: 'kubeAPIService',
podSecurityPolicy: false,
serviceNodePortRange: '30000-32767',
}),
etcd: globalStore.createRecord({
type: 'etcdService',

View File

@ -165,6 +165,17 @@
{{/if}}
</div>
</div>
<div class="row">
<div class="col span-4">
<label class="acc-label">{{t 'clusterNew.rke.serviceNodePortRange.label'}}</label>
{{input
type="text"
value=cluster.rancherKubernetesEngineConfig.services.kubeApi.serviceNodePortRange
className="form-control"
placeholder=(t 'clusterNew.rke.serviceNodePortRange.placeholder')
}}
</div>
</div>
<div class="row">
<div class="col span-12">
{{cru-cloud-provider

View File

@ -2070,6 +2070,9 @@ clusterNew:
auth:
label: Auth Provider
x509: x509
serviceNodePortRange:
label: Node Port Range
placeholder: e.g. 30000-32767
network:
label: Network Provider
flannel: Flannel
@ -3609,7 +3612,8 @@ formPorts:
ipPlaceholder: "e.g. 80 or 19.82.2.24:80"
clusterIpDefault: "Same as container port"
nodePort:
placeholder: "e.g. 30000"
placeholder: "Default node port range is 30000-32767, e.g. 30000"
customPortRangePlaceholder: "Node port range is {range}, e.g. {port}"
containerPort:
label: Publish the container port
placeholder: "e.g. 8080"

View File

@ -2061,6 +2061,9 @@ clusterNew:
auth:
label: 认证提供者
x509: x509
serviceNodePortRange:
label: Node Port范围
placeholder: '例如: 30000-32767'
network:
label: 网络组件
flannel: Flannel
@ -3600,7 +3603,8 @@ formPorts:
ipPlaceholder: '例如: 80或19.82.2.24:80'
clusterIpDefault: '与容器端口相同'
nodePort:
placeholder: '端口范围30000-32768例如: 30000'
placeholder: '默认端口范围30000-32768例如: 30000'
customPortRangePlaceholder: "端口范围{range},例如: {port}"
containerPort:
label: 容器端口
placeholder: "例如: 8080"