feat(k8s) EE-1543 Allow Services to be managed for external kube apps
This commit is contained in:
@@ -16,7 +16,8 @@ function _publishedPortToServicePort(formValues, publishedPort, type) {
|
||||
const name = formValues.Name;
|
||||
const res = new KubernetesServicePort();
|
||||
res.name = _.toLower(name + '-' + publishedPort.ContainerPort + '-' + publishedPort.Protocol);
|
||||
res.port = type === KubernetesServiceTypes.LOAD_BALANCER ? publishedPort.LoadBalancerPort : publishedPort.ContainerPort;
|
||||
// if generatePublishedPortsFormValuesFromPublishedPorts backups the ServicePort then use it instead of ContainerPort
|
||||
res.port = type === KubernetesServiceTypes.LOAD_BALANCER ? publishedPort.LoadBalancerPort : publishedPort.ServicePort || publishedPort.ContainerPort;
|
||||
res.targetPort = publishedPort.ContainerPort;
|
||||
res.protocol = publishedPort.Protocol;
|
||||
if (type === KubernetesServiceTypes.NODE_PORT && publishedPort.NodePort) {
|
||||
@@ -48,7 +49,7 @@ class KubernetesServiceConverter {
|
||||
res.Type = KubernetesServiceTypes.LOAD_BALANCER;
|
||||
}
|
||||
const ports = _.map(formValues.PublishedPorts, (item) => _publishedPortToServicePort(formValues, item, res.Type));
|
||||
res.Ports = _.uniqBy(_.without(ports, undefined), (p) => p.targetPort + p.protocol);
|
||||
res.Ports = _.uniqBy(_.without(ports, undefined), (p) => p.targetPort + p.protocol + p.port);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@@ -289,6 +289,12 @@ class KubernetesApplicationHelper {
|
||||
}
|
||||
res.Protocol = port.Protocol;
|
||||
res.ContainerPort = port.TargetPort;
|
||||
|
||||
// when editing an external app ports, backup the ServicePort to the form values so that the service can be correctly patched
|
||||
if (port.Port !== port.TargetPort) {
|
||||
res.ServicePort = port.Port;
|
||||
}
|
||||
|
||||
if (serviceType === KubernetesServiceTypes.LOAD_BALANCER) {
|
||||
res.LoadBalancerPort = port.Port;
|
||||
res.LoadBalancerNodePort = port.NodePort;
|
||||
|
||||
@@ -113,6 +113,7 @@ export function KubernetesApplicationPublishedPortFormValue() {
|
||||
IsNew: true,
|
||||
ContainerPort: '',
|
||||
NodePort: '',
|
||||
ServicePort: '',
|
||||
LoadBalancerPort: '',
|
||||
LoadBalancerNodePort: undefined, // only filled to save existing loadbalancer nodePort and drop it when moving app exposure from LB to Internal/NodePort
|
||||
Protocol: 'TCP',
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1057,6 +1057,10 @@ class KubernetesCreateApplicationController {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
isEditingExternalApp() {
|
||||
return this.state.isEdit && KubernetesApplicationHelper.isExternalApplication(this.application);
|
||||
}
|
||||
/* #endregion */
|
||||
|
||||
/* #region ON INIT */
|
||||
|
||||
@@ -198,14 +198,7 @@
|
||||
<rd-widget>
|
||||
<rd-widget-body>
|
||||
<div ng-if="!ctrl.isSystemNamespace()" style="margin-bottom: 15px;">
|
||||
<button
|
||||
ng-if="!ctrl.isExternalApplication()"
|
||||
type="button"
|
||||
class="btn btn-sm btn-primary"
|
||||
ui-sref="kubernetes.applications.application.edit"
|
||||
style="margin-left: 0;"
|
||||
data-cy="k8sAppDetail-editAppButton"
|
||||
>
|
||||
<button type="button" class="btn btn-sm btn-primary" ui-sref="kubernetes.applications.application.edit" style="margin-left: 0;" data-cy="k8sAppDetail-editAppButton">
|
||||
<i class="fa fa-file-code space-right" aria-hidden="true"></i>Edit this application
|
||||
</button>
|
||||
<button
|
||||
|
||||
Reference in New Issue
Block a user