use of com.marcnuri.yakc.model.io.k8s.api.networking.v1.Ingress in project xp-operator by enonic.
the class OperatorIngressLabel method setStatus.
private void setStatus(final Ingress ingress) {
// Collect all nodegroup vhost states
Map<String, Xp7ConfigStatus.State> states = searchers.xp7Config().stream().filter(inSameNamespaceAs(ingress)).filter(isDeleted().negate()).filter(this::isVHostConfig).collect(Collectors.toMap(c -> c.getSpec().getNodeGroup(), c -> c.getStatus().getState()));
// Set all nodeGroups state
if (states.values().stream().anyMatch(s -> !s.equals(Xp7ConfigStatus.State.READY))) {
states.put(cfgStr("operator.charts.values.allNodesKey"), Xp7ConfigStatus.State.PENDING);
} else {
states.put(cfgStr("operator.charts.values.allNodesKey"), Xp7ConfigStatus.State.READY);
}
// Figure out state
boolean loaded = true;
for (IngressRule r : ingress.getSpec().getRules()) {
for (HTTPIngressPath p : r.getHttp().getPaths()) {
Xp7ConfigStatus.State pathState = states.get(p.getBackend().getService().getName());
if (pathState != null && !pathState.equals(Xp7ConfigStatus.State.READY)) {
loaded = false;
break;
}
}
}
// Update if true
if (loaded) {
K8sLogHelper.logEdit(clients.k8s().network().ingress().inNamespace(ingress.getMetadata().getNamespace()).withName(ingress.getMetadata().getName()), i -> {
Map<String, String> labels = i.getMetadata().getLabels();
if (labels == null) {
labels = new HashMap<>();
}
labels.put(cfgStr("operator.charts.values.labelKeys.ingressVhostLoaded"), "true");
i.getMetadata().setLabels(labels);
return i;
});
}
}
use of com.marcnuri.yakc.model.io.k8s.api.networking.v1.Ingress in project dekorate by dekorateio.
the class Feat547Test method shouldHaveMatchingLabels.
@Test
public void shouldHaveMatchingLabels() {
KubernetesList list = Serialization.unmarshalAsList(getClass().getClassLoader().getResourceAsStream("META-INF/dekorate/kubernetes.yml"));
assertNotNull(list);
Ingress i = findFirst(list, Ingress.class).orElseThrow(() -> new IllegalStateException());
assertTrue(i.getSpec().getRules().stream().flatMap(r -> r.getHttp().getPaths().stream()).anyMatch(p -> p.getPath().equals("/app")));
assertFalse(i.getMetadata().getLabels().isEmpty());
}
use of com.marcnuri.yakc.model.io.k8s.api.networking.v1.Ingress in project dekorate by dekorateio.
the class ThorntailAnnotationlessTest method shouldContainKubernetesIngress.
@Test
void shouldContainKubernetesIngress() {
KubernetesList list = Serialization.unmarshalAsList(ThorntailAnnotationlessTest.class.getClassLoader().getResourceAsStream("META-INF/dekorate/kubernetes.yml"));
assertNotNull(list);
Optional<Ingress> ingress = findFirst(list, Ingress.class);
assertTrue(ingress.isPresent());
assertNotNull(ingress.get().getSpec().getRules().get(0).getHttp().getPaths().get(0).getBackend().getService().getPort().getName());
assertNull(ingress.get().getSpec().getRules().get(0).getHttp().getPaths().get(0).getBackend().getService().getPort().getNumber());
}
use of com.marcnuri.yakc.model.io.k8s.api.networking.v1.Ingress in project dekorate by dekorateio.
the class Issue545Test method shouldHaveMatchingPath.
@Test
public void shouldHaveMatchingPath() {
KubernetesList list = Serialization.unmarshalAsList(getClass().getClassLoader().getResourceAsStream("META-INF/dekorate/kubernetes.yml"));
assertNotNull(list);
Deployment d = findFirst(list, Deployment.class).orElseThrow(() -> new IllegalStateException());
assertNotNull(d);
Container c = d.getSpec().getTemplate().getSpec().getContainers().get(0);
assertNotNull(c);
assertTrue(c.getPorts().stream().filter(p -> "http".equals(p.getName())).findAny().isPresent());
Ingress i = findFirst(list, Ingress.class).orElseThrow(() -> new IllegalStateException());
assertTrue(i.getSpec().getRules().stream().flatMap(r -> r.getHttp().getPaths().stream()).anyMatch(p -> p.getPath().equals("/app")));
}
use of com.marcnuri.yakc.model.io.k8s.api.networking.v1.Ingress in project jkube by eclipse.
the class ApplyServiceTest method testApplyToMultipleNamespaceNoNamespaceConfigured.
@Test
public void testApplyToMultipleNamespaceNoNamespaceConfigured() throws InterruptedException {
// Given
ConfigMap configMap = new ConfigMapBuilder().withNewMetadata().withName("cm1").withNamespace("ns1").endMetadata().build();
Ingress ingress = new IngressBuilder().withNewMetadata().withName("ing1").withNamespace("ns2").endMetadata().build();
ServiceAccount serviceAccount = new ServiceAccountBuilder().withNewMetadata().withName("sa1").endMetadata().build();
List<HasMetadata> entities = new ArrayList<>();
entities.add(configMap);
entities.add(serviceAccount);
entities.add(ingress);
WebServerEventCollector collector = new WebServerEventCollector();
mockServer.expect().post().withPath("/api/v1/namespaces/ns1/configmaps").andReply(collector.record("configmap-ns1-create").andReturn(HTTP_OK, configMap)).once();
mockServer.expect().post().withPath("/apis/networking.k8s.io/v1/namespaces/ns2/ingresses").andReply(collector.record("ingress-ns2-create").andReturn(HTTP_OK, ingress)).once();
mockServer.expect().post().withPath("/api/v1/namespaces/default/serviceaccounts").andReply(collector.record("serviceaccount-default-create").andReturn(HTTP_OK, serviceAccount)).once();
String configuredNamespace = applyService.getNamespace();
applyService.setNamespace(null);
applyService.setFallbackNamespace("default");
// When
applyService.applyEntities(null, entities, log, 5);
// Then
collector.assertEventsRecordedInOrder("configmap-ns1-create", "serviceaccount-default-create", "ingress-ns2-create");
assertEquals(5, mockServer.getOpenShiftMockServer().getRequestCount());
applyService.setFallbackNamespace(null);
applyService.setNamespace(configuredNamespace);
}
Aggregations