Search in sources :

Example 6 with BridgeIngress

use of com.redhat.service.bridge.shard.operator.resources.BridgeIngress in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class CustomerNamespaceProviderImplTest method testNamespaceNotDeletedWithBridges.

@Test
void testNamespaceNotDeletedWithBridges() {
    final BridgeDTO dto = TestSupport.newRequestedBridgeDTO();
    dto.setCustomerId("cooper");
    bridgeIngressService.createBridgeIngress(dto);
    // Wait until BridgeIngress is really created, can take some time due to client caching
    Awaitility.await().atMost(Duration.ofSeconds(5)).until(() -> kubernetesClient.resources(BridgeIngress.class).inNamespace(customerNamespaceProvider.resolveName(dto.getCustomerId())).withName(BridgeIngress.resolveResourceName(dto.getId())).get() != null);
    // try to delete the namespace...
    customerNamespaceProvider.deleteNamespaceIfEmpty(kubernetesClient.namespaces().withName("ob-cooper").get());
    final Namespace namespace = kubernetesClient.namespaces().withName(customerNamespaceProvider.resolveName(dto.getCustomerId())).get();
    assertThat(namespace).isNotNull();
}
Also used : BridgeIngress(com.redhat.service.bridge.shard.operator.resources.BridgeIngress) BridgeDTO(com.redhat.service.bridge.infra.models.dto.BridgeDTO) Namespace(io.fabric8.kubernetes.api.model.Namespace) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 7 with BridgeIngress

use of com.redhat.service.bridge.shard.operator.resources.BridgeIngress in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class BridgeIngressServiceTest method testBridgeIngressRedeployment.

@Test
public void testBridgeIngressRedeployment() {
    // Given
    BridgeDTO dto = TestSupport.newProvisioningBridgeDTO();
    String patchedCustomerId = TestSupport.CUSTOMER_ID + "-patched";
    // When
    bridgeIngressService.createBridgeIngress(dto);
    dto.setCustomerId(patchedCustomerId);
    bridgeIngressService.createBridgeIngress(dto);
    // Then
    BridgeIngress bridgeIngress = fetchBridgeIngress(dto);
    assertThat(bridgeIngress).isNotNull();
    assertThat(bridgeIngress.getSpec().getCustomerId()).isEqualTo(patchedCustomerId);
    Secret secret = fetchBridgeIngressSecret(dto);
    assertThat(secret).isNotNull();
    assertThat(secret.getMetadata().getName()).isEqualTo(bridgeIngress.getMetadata().getName());
}
Also used : BridgeIngress(com.redhat.service.bridge.shard.operator.resources.BridgeIngress) Secret(io.fabric8.kubernetes.api.model.Secret) BridgeDTO(com.redhat.service.bridge.infra.models.dto.BridgeDTO) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 8 with BridgeIngress

use of com.redhat.service.bridge.shard.operator.resources.BridgeIngress in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class KubernetesNetworkingService method fetchOrCreateNetworkIngress.

@Override
public NetworkResource fetchOrCreateNetworkIngress(BridgeIngress bridgeIngress, Service service) {
    Ingress expected = buildIngress(bridgeIngress, service);
    Ingress existing = client.network().v1().ingresses().inNamespace(service.getMetadata().getNamespace()).withName(service.getMetadata().getName()).get();
    if (existing == null || !expected.getSpec().equals(existing.getSpec())) {
        client.network().v1().ingresses().inNamespace(service.getMetadata().getNamespace()).withName(service.getMetadata().getName()).createOrReplace(expected);
        return buildNetworkingResource(expected);
    }
    return buildNetworkingResource(existing);
}
Also used : Ingress(io.fabric8.kubernetes.api.model.networking.v1.Ingress) BridgeIngress(com.redhat.service.bridge.shard.operator.resources.BridgeIngress)

Example 9 with BridgeIngress

use of com.redhat.service.bridge.shard.operator.resources.BridgeIngress in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class BridgeIngressServiceImpl method createBridgeIngress.

@Override
public void createBridgeIngress(BridgeDTO bridgeDTO) {
    final Namespace namespace = customerNamespaceProvider.fetchOrCreateCustomerNamespace(bridgeDTO.getCustomerId());
    BridgeIngress expected = BridgeIngress.fromDTO(bridgeDTO, namespace.getMetadata().getName(), ingressImage);
    BridgeIngress existing = kubernetesClient.resources(BridgeIngress.class).inNamespace(namespace.getMetadata().getName()).withName(BridgeIngress.resolveResourceName(bridgeDTO.getId())).get();
    if (existing == null || !expected.getSpec().equals(existing.getSpec())) {
        BridgeIngress bridgeIngress = kubernetesClient.resources(BridgeIngress.class).inNamespace(namespace.getMetadata().getName()).createOrReplace(expected);
        // create or update the secrets for the bridgeIngress
        createOrUpdateBridgeIngressSecret(bridgeIngress, bridgeDTO);
    }
}
Also used : BridgeIngress(com.redhat.service.bridge.shard.operator.resources.BridgeIngress) Namespace(io.fabric8.kubernetes.api.model.Namespace)

Example 10 with BridgeIngress

use of com.redhat.service.bridge.shard.operator.resources.BridgeIngress in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class BridgeIngressServiceTest method testBridgeIngressDeletion.

@Test
public void testBridgeIngressDeletion() {
    // Given
    BridgeDTO dto = TestSupport.newProvisioningBridgeDTO();
    // When
    bridgeIngressService.createBridgeIngress(dto);
    bridgeIngressService.deleteBridgeIngress(dto);
    // Then
    BridgeIngress bridgeIngress = fetchBridgeIngress(dto);
    assertThat(bridgeIngress).isNull();
}
Also used : BridgeIngress(com.redhat.service.bridge.shard.operator.resources.BridgeIngress) BridgeDTO(com.redhat.service.bridge.infra.models.dto.BridgeDTO) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Aggregations

BridgeIngress (com.redhat.service.bridge.shard.operator.resources.BridgeIngress)16 QuarkusTest (io.quarkus.test.junit.QuarkusTest)11 Test (org.junit.jupiter.api.Test)11 BridgeDTO (com.redhat.service.bridge.infra.models.dto.BridgeDTO)6 Secret (io.fabric8.kubernetes.api.model.Secret)4 Deployment (io.fabric8.kubernetes.api.model.apps.Deployment)4 Ingress (io.fabric8.kubernetes.api.model.networking.v1.Ingress)3 Namespace (io.fabric8.kubernetes.api.model.Namespace)2 ObjectMetaBuilder (io.fabric8.kubernetes.api.model.ObjectMetaBuilder)2 SecretBuilder (io.fabric8.kubernetes.api.model.SecretBuilder)2 BridgeIngressService (com.redhat.service.bridge.shard.operator.BridgeIngressService)1 WithPrometheus (com.redhat.service.bridge.shard.operator.WithPrometheus)1 When (io.cucumber.java.en.When)1 Service (io.fabric8.kubernetes.api.model.Service)1 HTTPIngressPath (io.fabric8.kubernetes.api.model.networking.v1.HTTPIngressPath)1 HTTPIngressPathBuilder (io.fabric8.kubernetes.api.model.networking.v1.HTTPIngressPathBuilder)1 HTTPIngressRuleValueBuilder (io.fabric8.kubernetes.api.model.networking.v1.HTTPIngressRuleValueBuilder)1 IngressBackend (io.fabric8.kubernetes.api.model.networking.v1.IngressBackend)1 IngressBackendBuilder (io.fabric8.kubernetes.api.model.networking.v1.IngressBackendBuilder)1 IngressRule (io.fabric8.kubernetes.api.model.networking.v1.IngressRule)1