use of io.fabric8.kubernetes.api.model.LoadBalancerIngressBuilder in project carbon-apimgt by wso2.
the class ServiceDiscovererKubernetesTestCase method init.
/**
* ServiceName Namespace Criteria Type Ports LoadBalancer ExternalIP
*
* service0 dev app=web ClusterIP http - included
* service1 dev - ExternalName http - -
* service2 dev - LoadBalancer https IP -
* service3 prod app=web ClusterIP http - -
* service4 prod - LoadBalancer http hostname -
*/
@BeforeTest(description = "Create a list of services with all combinations included")
void init() {
Map<String, String> oneLabel = createOneLabelHashMap();
ServicePortBuilder httpPortBuilder = new ServicePortBuilder().withName("http").withPort(80);
ServicePort httpPort = httpPortBuilder.build();
ServicePort nodePort2 = new ServicePortBuilder().withName("https").withPort(443).withNodePort(30002).build();
ServicePort nodePort4 = httpPortBuilder.withNodePort(30004).build();
List<LoadBalancerIngress> ipIngresses = new ArrayList<>();
LoadBalancerIngress ingressWithIP = new LoadBalancerIngressBuilder().withIp("100.1.1.2").build();
ipIngresses.add(ingressWithIP);
List<LoadBalancerIngress> hostnameIngresses = new ArrayList<>();
LoadBalancerIngress ingressWithHostname = new LoadBalancerIngressBuilder().withHostname("abc.com").build();
hostnameIngresses.add(ingressWithHostname);
Service service0 = new ServiceBuilder().withNewMetadata().withName("service0").withNamespace("dev").withLabels(oneLabel).and().withNewSpec().withType("ClusterIP").withClusterIP("1.1.1.0").withPorts(httpPort).withExternalIPs("100.2.1.0").and().build();
Service service1 = new ServiceBuilder().withNewMetadata().withName("service1").withNamespace("dev").and().withNewSpec().withType("ExternalName").withExternalName("aaa.com").withPorts(httpPort).and().build();
Service service2 = new ServiceBuilder().withNewMetadata().withName("service2").withNamespace("dev").and().withNewSpec().withType("LoadBalancer").withClusterIP("1.1.1.2").withPorts(nodePort2).and().withNewStatus().withNewLoadBalancer().withIngress(ipIngresses).endLoadBalancer().and().build();
Service service3 = new ServiceBuilder().withNewMetadata().withName("service3").withNamespace("prod").withLabels(oneLabel).and().withNewSpec().withType("ClusterIP").withClusterIP("1.1.1.3").withPorts(httpPort).and().build();
Service service4 = new ServiceBuilder().withNewMetadata().withName("service4").withNamespace("prod").and().withNewSpec().withType("LoadBalancer").withClusterIP("1.1.1.4").withPorts(nodePort4).and().withNewStatus().withNewLoadBalancer().withIngress(hostnameIngresses).endLoadBalancer().and().build();
List<Service> servicesList = new ArrayList<>();
servicesList.add(service0);
servicesList.add(service1);
servicesList.add(service2);
servicesList.add(service3);
servicesList.add(service4);
this.listOfServices = servicesList;
}
Aggregations