public ServiceInstance(Service service) { this.service = service; this.id = getName(service); ServiceSpec spec = KubernetesHelper.getOrCreateSpec(service); List<ServicePort> ports = spec.getPorts(); if (spec.getPortalIP().equals(HEADLESS_PORTAL_IP)) { //do nothing service is headless } else if (ports != null && !ports.isEmpty()) { for (ServicePort servicePort : ports) { servicePorts.add(toNamedServicePort(id, servicePort)); } } else { throw new IllegalArgumentException("Service: " + id + " doesn't have a valid port configuration."); } this.selector = KubernetesHelper.getSelector(service); Objects.notNull(this.selector, "No selector for service " + id); if (selector.isEmpty()) { throw new IllegalArgumentException("Empty selector for service " + id); } this.filter = KubernetesHelper.createPodFilter(selector); // TODO should we use some service metadata to choose the load balancer? this.loadBalancer = new RoundRobinLoadBalancer(); }
public String updateService(@NotNull String id, Service entity) throws Exception { // lets set the IP ServiceSpec spec = entity.getSpec(); if (spec == null) { spec = new ServiceSpec(); entity.setSpec(spec); } if (!HEADLESS_PORTAL_IP.equals(spec.getPortalIP())) { spec.setPortalIP(getHostName()); } // lets ensure there's a default namespace set String namespace = KubernetesHelper.getNamespace(entity); if (Strings.isBlank(namespace)) { getOrCreateMetadata(entity).setNamespace(DEFAULT_NAMESPACE); } model.updateService(id, entity); return null; }
ServiceSpec spec = service.getSpec(); if (spec != null) { String host = spec.getPortalIP(); if (host != null && host.length() > 0) { return defaultProtocolText + host;
public ServiceSpecBuilder( ServiceSpecFluent<?> fluent , ServiceSpec instance ){ this.fluent = fluent; fluent.withDeprecatedPublicIPs(instance.getDeprecatedPublicIPs()); fluent.withPortalIP(instance.getPortalIP()); fluent.withPorts(instance.getPorts()); fluent.withSelector(instance.getSelector()); fluent.withSessionAffinity(instance.getSessionAffinity()); fluent.withType(instance.getType()); } public ServiceSpecBuilder( ServiceSpec instance ){
public ServiceSpecBuilder( ServiceSpec instance ){ this.fluent = this; this.withDeprecatedPublicIPs(instance.getDeprecatedPublicIPs()); this.withPortalIP(instance.getPortalIP()); this.withPorts(instance.getPorts()); this.withSelector(instance.getSelector()); this.withSessionAffinity(instance.getSessionAffinity()); this.withType(instance.getType()); }
public ServiceSpecBuilder( ServiceSpec instance ){ this.fluent = this; this.withCreateExternalLoadBalancer(instance.getCreateExternalLoadBalancer()); this.withPortalIP(instance.getPortalIP()); this.withPorts(instance.getPorts()); this.withPublicIPs(instance.getPublicIPs()); this.withSelector(instance.getSelector()); this.withSessionAffinity(instance.getSessionAffinity()); this.withType(instance.getType()); }
public ServiceSpecBuilder( ServiceSpecFluent<?> fluent , ServiceSpec instance ){ this.fluent = fluent; fluent.withCreateExternalLoadBalancer(instance.getCreateExternalLoadBalancer()); fluent.withPortalIP(instance.getPortalIP()); fluent.withPorts(instance.getPorts()); fluent.withPublicIPs(instance.getPublicIPs()); fluent.withSelector(instance.getSelector()); fluent.withSessionAffinity(instance.getSessionAffinity()); fluent.withType(instance.getType()); } public ServiceSpecBuilder( ServiceSpec instance ){
public ServiceSpecFluentImpl(ServiceSpec instance){ this.withClusterIP(instance.getClusterIP()); this.withDeprecatedPublicIPs(instance.getDeprecatedPublicIPs()); this.withExternalIPs(instance.getExternalIPs()); this.withLoadBalancerIP(instance.getLoadBalancerIP()); this.withLoadBalancerSourceRanges(instance.getLoadBalancerSourceRanges()); this.withPortalIP(instance.getPortalIP()); this.withPorts(instance.getPorts()); this.withSelector(instance.getSelector()); this.withSessionAffinity(instance.getSessionAffinity()); this.withType(instance.getType()); }
public ServiceSpecBuilder(ServiceSpecFluent<?> fluent,ServiceSpec instance,Boolean validationEnabled){ this.fluent = fluent; fluent.withClusterIP(instance.getClusterIP()); fluent.withDeprecatedPublicIPs(instance.getDeprecatedPublicIPs()); fluent.withExternalIPs(instance.getExternalIPs()); fluent.withLoadBalancerIP(instance.getLoadBalancerIP()); fluent.withLoadBalancerSourceRanges(instance.getLoadBalancerSourceRanges()); fluent.withPortalIP(instance.getPortalIP()); fluent.withPorts(instance.getPorts()); fluent.withSelector(instance.getSelector()); fluent.withSessionAffinity(instance.getSessionAffinity()); fluent.withType(instance.getType()); this.validationEnabled = validationEnabled; } public ServiceSpecBuilder(ServiceSpec instance){
public ServiceSpecBuilder(ServiceSpec instance,Boolean validationEnabled){ this.fluent = this; this.withClusterIP(instance.getClusterIP()); this.withDeprecatedPublicIPs(instance.getDeprecatedPublicIPs()); this.withExternalIPs(instance.getExternalIPs()); this.withLoadBalancerIP(instance.getLoadBalancerIP()); this.withLoadBalancerSourceRanges(instance.getLoadBalancerSourceRanges()); this.withPortalIP(instance.getPortalIP()); this.withPorts(instance.getPorts()); this.withSelector(instance.getSelector()); this.withSessionAffinity(instance.getSessionAffinity()); this.withType(instance.getType()); this.validationEnabled = validationEnabled; }