diff --git a/app/kubernetes/helpers/application/index.js b/app/kubernetes/helpers/application/index.js index ff405a3d6..1d358ed5c 100644 --- a/app/kubernetes/helpers/application/index.js +++ b/app/kubernetes/helpers/application/index.js @@ -281,47 +281,50 @@ class KubernetesApplicationHelper { let services = []; if (app.Services) { app.Services.forEach(function (service) { - const svc = new KubernetesService(); - svc.Namespace = service.metadata.namespace; - svc.Name = service.metadata.name; - svc.StackName = service.StackName; - svc.ApplicationOwner = app.ApplicationOwner; - svc.ApplicationName = app.ApplicationName; - svc.Type = service.spec.type; - if (service.spec.type === KubernetesServiceTypes.CLUSTER_IP) { - svc.Type = 1; - } else if (service.spec.type === KubernetesServiceTypes.NODE_PORT) { - svc.Type = 2; - } else if (service.spec.type === KubernetesServiceTypes.LOAD_BALANCER) { - svc.Type = 3; - } + //skip generate formValues if service = headless service ( clusterIp === "None" ) + if (service.spec.clusterIP !== 'None') { + const svc = new KubernetesService(); + svc.Namespace = service.metadata.namespace; + svc.Name = service.metadata.name; + svc.StackName = service.StackName; + svc.ApplicationOwner = app.ApplicationOwner; + svc.ApplicationName = app.ApplicationName; + svc.Type = service.spec.type; + if (service.spec.type === KubernetesServiceTypes.CLUSTER_IP) { + svc.Type = 1; + } else if (service.spec.type === KubernetesServiceTypes.NODE_PORT) { + svc.Type = 2; + } else if (service.spec.type === KubernetesServiceTypes.LOAD_BALANCER) { + svc.Type = 3; + } - let ports = []; - service.spec.ports.forEach(function (port) { - const svcport = new KubernetesServicePort(); - svcport.name = port.name; - svcport.port = port.port; - svcport.nodePort = port.nodePort; - svcport.protocol = port.protocol; - svcport.targetPort = port.targetPort; + let ports = []; + service.spec.ports.forEach(function (port) { + const svcport = new KubernetesServicePort(); + svcport.name = port.name; + svcport.port = port.port; + svcport.nodePort = port.nodePort; + svcport.protocol = port.protocol; + svcport.targetPort = port.targetPort; - app.Ingresses.value.forEach((ingress) => { - const ingressMatched = _.find(ingress.Paths, { ServiceName: service.metadata.name }); - if (ingressMatched) { - svcport.ingress = { - IngressName: ingressMatched.IngressName, - Host: ingressMatched.Host, - Path: ingressMatched.Path, - }; - svc.Ingress = true; - } + app.Ingresses.value.forEach((ingress) => { + const ingressMatched = _.find(ingress.Paths, { ServiceName: service.metadata.name }); + if (ingressMatched) { + svcport.ingress = { + IngressName: ingressMatched.IngressName, + Host: ingressMatched.Host, + Path: ingressMatched.Path, + }; + svc.Ingress = true; + } + }); + + ports.push(svcport); }); - - ports.push(svcport); - }); - svc.Ports = ports; - svc.Selector = app.Raw.spec.selector.matchLabels; - services.push(svc); + svc.Ports = ports; + svc.Selector = app.Raw.spec.selector.matchLabels; + services.push(svc); + } }); return services; diff --git a/app/kubernetes/services/applicationService.js b/app/kubernetes/services/applicationService.js index d2a736f58..cc7613081 100644 --- a/app/kubernetes/services/applicationService.js +++ b/app/kubernetes/services/applicationService.js @@ -429,10 +429,10 @@ class KubernetesApplicationService { if (apiService === this.KubernetesStatefulSetService) { const headlessServicePayload = angular.copy(payload); headlessServicePayload.Name = application instanceof KubernetesStatefulSet ? application.ServiceName : application.HeadlessServiceName; - await this.KubernetesServiceService.delete(headlessServicePayload); } if (application.ServiceType) { + // delete headless service && non-headless service await this.KubernetesServiceService.delete(application.Services); if (application.Ingresses.length) { diff --git a/app/kubernetes/views/applications/edit/application.html b/app/kubernetes/views/applications/edit/application.html index 5e5763ff7..9bdaaf941 100644 --- a/app/kubernetes/views/applications/edit/application.html +++ b/app/kubernetes/views/applications/edit/application.html @@ -257,7 +257,7 @@ This application is not exposing any port. -