use of io.fabric8.kubernetes.api.model.networking.v1.IngressBuilder in project kubernetes-client by fabric8io.
the class IngressIT method update.
@Test
public void update() {
Ingress ingress = client.network().v1().ingresses().inNamespace(session.getNamespace()).withName("ingress-update").edit(i -> new IngressBuilder(i).editOrNewMetadata().addToAnnotations("foo", "bar").endMetadata().build());
assertNotNull(ingress);
assertEquals("bar", ingress.getMetadata().getAnnotations().get("foo"));
}
use of io.fabric8.kubernetes.api.model.networking.v1.IngressBuilder in project kubernetes-client by fabric8io.
the class CreateOrReplaceIT method testCreateOrReplaceIngress.
@Test
public void testCreateOrReplaceIngress() {
Ingress ingress = new IngressBuilder().withNewMetadata().withName(getTestResourcePrefix() + "-ing").endMetadata().withNewSpec().addNewRule().withNewHttp().addNewPath().withPath("/testPath").withPathType("Prefix").withNewBackend().withNewService().withName("test").withNewPort().withNumber(80).endPort().endService().endBackend().endPath().endHttp().endRule().endSpec().build();
// 1st createOrReplace(); should create the resource
ingress = client.network().v1().ingresses().inNamespace(session.getNamespace()).createOrReplace(ingress);
assertNotNull(ingress);
assertEquals(getTestResourcePrefix() + "-ing", ingress.getMetadata().getName());
assertEquals(1, ingress.getSpec().getRules().size());
// Modify resource
ingress.getMetadata().setAnnotations(Collections.singletonMap("nginx.ingress.kubernetes.io/rewrite-target", "/"));
// 2nd createOrReplace; should update the resource
ingress = client.network().v1().ingresses().inNamespace(session.getNamespace()).createOrReplace(ingress);
assertNotNull(ingress);
assertEquals("/", ingress.getMetadata().getAnnotations().get("nginx.ingress.kubernetes.io/rewrite-target"));
}
use of io.fabric8.kubernetes.api.model.networking.v1.IngressBuilder in project che-server by eclipse-che.
the class IngressServerResolverTest method createIngress.
private Ingress createIngress(String name, String machineName, Pair<String, ServerConfig> server) {
Serializer serializer = Annotations.newSerializer();
serializer.machineName(machineName);
serializer.server(server.first, server.second);
return new IngressBuilder().withNewMetadata().withName(name).withAnnotations(serializer.annotations()).endMetadata().withNewSpec().withRules(new IngressRule(null, new HTTPIngressRuleValue(singletonList(new HTTPIngressPath(new IngressBackend(null, new IngressServiceBackend(name, new ServiceBackendPort("8080", 8080))), INGRESS_PATH_PREFIX, null))))).endSpec().withNewStatus().withLoadBalancer(new LoadBalancerStatusBuilder().addNewIngress().withIp("127.0.0.1").endIngress().build()).endStatus().build();
}
use of io.fabric8.kubernetes.api.model.networking.v1.IngressBuilder in project devspaces-images by redhat-developer.
the class IngressServerResolverTest method createIngress.
private Ingress createIngress(String name, String machineName, Pair<String, ServerConfig> server) {
Serializer serializer = Annotations.newSerializer();
serializer.machineName(machineName);
serializer.server(server.first, server.second);
return new IngressBuilder().withNewMetadata().withName(name).withAnnotations(serializer.annotations()).endMetadata().withNewSpec().withRules(new IngressRule(null, new HTTPIngressRuleValue(singletonList(new HTTPIngressPath(new IngressBackend(null, new IngressServiceBackend(name, new ServiceBackendPort("8080", 8080))), INGRESS_PATH_PREFIX, null))))).endSpec().withNewStatus().withLoadBalancer(new LoadBalancerStatusBuilder().addNewIngress().withIp("127.0.0.1").endIngress().build()).endStatus().build();
}
use of io.fabric8.kubernetes.api.model.networking.v1.IngressBuilder in project devspaces-images by redhat-developer.
the class KubernetesEnvironmentFactoryTest method ignoreIgressesWhenRecipeContainsThem.
@Test
public void ignoreIgressesWhenRecipeContainsThem() throws Exception {
when(k8sRecipeParser.parse(any(InternalRecipe.class))).thenReturn(asList(new IngressBuilder().withNewMetadata().withName("ingress1").endMetadata().build(), new IngressBuilder().withNewMetadata().withName("ingress2").endMetadata().build()));
final KubernetesEnvironment parsed = k8sEnvFactory.doCreate(internalRecipe, emptyMap(), emptyList());
assertTrue(parsed.getIngresses().isEmpty());
assertEquals(parsed.getWarnings().size(), 1);
assertEquals(parsed.getWarnings().get(0), new WarningImpl(INGRESSES_IGNORED_WARNING_CODE, INGRESSES_IGNORED_WARNING_MESSAGE));
}
Aggregations