Fix service port ingress issue

https://github.com/rancher/rancher/issues/15809
This commit is contained in:
loganhz 2018-11-14 13:50:20 +08:00
parent e50cb88fad
commit c8ed933365
5 changed files with 20 additions and 8 deletions

View File

@ -63,12 +63,10 @@ export default Resource.extend({
const list = [];
const ports = get(this, 'ports');
if (get(this, 'recordType') === WORKLOAD) {
ports.forEach((p) => {
list.push(p.targetPort.toString());
list.push(p.port.toString());
})
}
ports.forEach((p) => {
list.push(p.targetPort.toString());
list.push(p.port.toString());
});
return list.uniq().map((p) => ({ port: p }));
}),

View File

@ -1,4 +1,4 @@
import { get, set, observer } from '@ember/object'
import { get, set, observer, computed } from '@ember/object'
import Component from '@ember/component';
import layout from './template';
import { inject as service } from '@ember/service';
@ -63,6 +63,10 @@ export default Component.extend({
});
}),
hasServiceTargets: computed('pathArray.@each.backendType}', function() {
return !!get(this, 'pathArray').findBy('backendType', 'service');
}),
initPathArray() {
const pathArray = [];
const paths = get(this, 'rule.paths');

View File

@ -1,3 +1,6 @@
{{#if hasServiceTargets}}
{{banner-message color="bg-info" icon="icon-info" message=(t 'formIngressBackends.warning' htmlSafe=true)}}
{{/if}}
<div class="clearfix">
{{#if editing}}
<label class="acc-label">{{t 'formIngressBackends.label'}}</label>
@ -65,7 +68,7 @@
<td class="p-5" data-title="{{t 'formIngressBackends.targetPort.label'}}">
{{#input-or-display editable=editing value=path.targetPort classesForDisplay="clip"}}
{{#if (and (eq path.backendType 'service') (eq path.service.recordType 'workload'))}}
{{#if (and path.service (eq path.backendType 'service'))}}
{{new-select
classNames="form-control input-sm"
optionValuePath="port"
@ -73,6 +76,11 @@
content=path.service.availablePorts
value=path.targetPort
}}
{{else if (eq path.backendType 'service')}}
{{new-select
classNames="form-control input-sm"
content=[]
}}
{{else}}
{{input-integer class="input-sm" min="1" max="65535" value=path.targetPort placeholder=(t 'formIngressBackends.targetPort.placeholder')}}
{{/if}}

View File

@ -3266,6 +3266,7 @@ formIngress:
formIngressBackends:
label: Target Backend
noRules: No Backends
warning: If the target is a service, only the port exposed by the service can be selected. You can go to Service Discovery tab and edit the service to add ports by editing the YAML.
addServiceLabel: Service
addWorkloadLabel: Workload
service:

View File

@ -3263,6 +3263,7 @@ formIngress:
formIngressBackends:
label: 目标后端
noRules: 没有后端
warning: 如果目标后端是一个服务您只可以使用该服务所暴露的端口。您可以在服务发现页找到该服务然后通过编辑YAML的方式添加所需要的端口。
addServiceLabel: 服务
addWorkloadLabel: 工作负载
service: