Search in sources :

Example 1 with BridgeIngress

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

the class BridgeIngressSteps method deployBridgeIngressWithDefaultSecret.

@When("^deploy BridgeIngress with default secret:$")
public void deployBridgeIngressWithDefaultSecret(String bridgeIngressYaml) {
    InputStream resourceStream = new ByteArrayInputStream(bridgeIngressYaml.getBytes(StandardCharsets.UTF_8));
    BridgeIngress bridgeIngress = context.getClient().resources(BridgeIngress.class).inNamespace(context.getNamespace()).load(resourceStream).createOrReplace();
    Secret secret = new SecretBuilder().withMetadata(new ObjectMetaBuilder().withLabels(new LabelsBuilder().withManagedByOperator().withComponent(BridgeIngress.COMPONENT_NAME).build()).withNamespace(bridgeIngress.getMetadata().getNamespace()).withName(bridgeIngress.getMetadata().getName()).build()).build();
    context.getClient().secrets().inNamespace(bridgeIngress.getMetadata().getNamespace()).withName(bridgeIngress.getMetadata().getName()).createOrReplace(secret);
}
Also used : BridgeIngress(com.redhat.service.smartevents.shard.operator.resources.BridgeIngress) Secret(io.fabric8.kubernetes.api.model.Secret) SecretBuilder(io.fabric8.kubernetes.api.model.SecretBuilder) LabelsBuilder(com.redhat.service.smartevents.shard.operator.utils.LabelsBuilder) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) ObjectMetaBuilder(io.fabric8.kubernetes.api.model.ObjectMetaBuilder) When(io.cucumber.java.en.When)

Example 2 with BridgeIngress

use of com.redhat.service.smartevents.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.smartevents.shard.operator.resources.BridgeIngress) Namespace(io.fabric8.kubernetes.api.model.Namespace)

Example 3 with BridgeIngress

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

the class TemplateProviderImpl method loadBridgeIngressKubernetesIngressTemplate.

@Override
public Ingress loadBridgeIngressKubernetesIngressTemplate(BridgeIngress bridgeIngress) {
    Ingress ingress = loadYaml(Ingress.class, BRIDGE_INGRESS_KUBERNETES_INGRESS_PATH);
    updateMetadata(bridgeIngress, ingress.getMetadata());
    return ingress;
}
Also used : BridgeIngress(com.redhat.service.smartevents.shard.operator.resources.BridgeIngress) Ingress(io.fabric8.kubernetes.api.model.networking.v1.Ingress)

Example 4 with BridgeIngress

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

the class KubernetesNetworkingService method buildIngress.

private Ingress buildIngress(BridgeIngress bridgeIngress, Service service) {
    Ingress ingress = templateProvider.loadBridgeIngressKubernetesIngressTemplate(bridgeIngress);
    IngressBackend ingressBackend = new IngressBackendBuilder().withService(new IngressServiceBackendBuilder().withName(service.getMetadata().getName()).withPort(new ServiceBackendPortBuilder().withNumber(service.getSpec().getPorts().get(0).getPort()).build()).build()).build();
    HTTPIngressPath httpIngressPath = new HTTPIngressPathBuilder().withBackend(ingressBackend).withPath("/" + service.getMetadata().getName() + PATH_REGEX).withPathType("Prefix").build();
    IngressRule ingressRule = new IngressRuleBuilder().withHttp(new HTTPIngressRuleValueBuilder().withPaths(httpIngressPath).build()).build();
    IngressSpec ingressSpec = new IngressSpecBuilder().withRules(ingressRule).build();
    ingress.setSpec(ingressSpec);
    return ingress;
}
Also used : IngressRuleBuilder(io.fabric8.kubernetes.api.model.networking.v1.IngressRuleBuilder) IngressSpec(io.fabric8.kubernetes.api.model.networking.v1.IngressSpec) IngressRule(io.fabric8.kubernetes.api.model.networking.v1.IngressRule) IngressBackendBuilder(io.fabric8.kubernetes.api.model.networking.v1.IngressBackendBuilder) HTTPIngressRuleValueBuilder(io.fabric8.kubernetes.api.model.networking.v1.HTTPIngressRuleValueBuilder) IngressSpecBuilder(io.fabric8.kubernetes.api.model.networking.v1.IngressSpecBuilder) IngressServiceBackendBuilder(io.fabric8.kubernetes.api.model.networking.v1.IngressServiceBackendBuilder) ServiceBackendPortBuilder(io.fabric8.kubernetes.api.model.networking.v1.ServiceBackendPortBuilder) BridgeIngress(com.redhat.service.smartevents.shard.operator.resources.BridgeIngress) Ingress(io.fabric8.kubernetes.api.model.networking.v1.Ingress) HTTPIngressPathBuilder(io.fabric8.kubernetes.api.model.networking.v1.HTTPIngressPathBuilder) HTTPIngressPath(io.fabric8.kubernetes.api.model.networking.v1.HTTPIngressPath) IngressBackend(io.fabric8.kubernetes.api.model.networking.v1.IngressBackend)

Example 5 with BridgeIngress

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

the class BridgeIngressControllerTest method testBridgeIngressDeployment_deploymentReplicaFailure.

@Test
void testBridgeIngressDeployment_deploymentReplicaFailure() {
    // Given
    BridgeIngress bridgeIngress = buildBridgeIngress();
    deployBridgeIngressSecret(bridgeIngress);
    // When
    bridgeIngressController.reconcile(bridgeIngress, null);
    Deployment deployment = getDeploymentFor(bridgeIngress);
    // Then
    kubernetesResourcePatcher.patchDeploymentAsReplicaFailed(deployment.getMetadata().getName(), deployment.getMetadata().getNamespace());
    UpdateControl<BridgeIngress> updateControl = bridgeIngressController.reconcile(bridgeIngress, null);
    assertThat(updateControl.isUpdateStatus()).isTrue();
    assertThat(updateControl.getResource().getStatus().getConditionByType(ConditionType.Ready).get().getReason()).isEqualTo(ConditionReason.DeploymentFailed);
    assertThat(updateControl.getResource().getStatus().getConditionByType(ConditionType.Augmentation).get().getStatus()).isEqualTo(ConditionStatus.False);
}
Also used : BridgeIngress(com.redhat.service.smartevents.shard.operator.resources.BridgeIngress) Deployment(io.fabric8.kubernetes.api.model.apps.Deployment) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Aggregations

BridgeIngress (com.redhat.service.smartevents.shard.operator.resources.BridgeIngress)19 QuarkusTest (io.quarkus.test.junit.QuarkusTest)12 Test (org.junit.jupiter.api.Test)12 BridgeDTO (com.redhat.service.smartevents.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.smartevents.shard.operator.BridgeIngressService)1 WithPrometheus (com.redhat.service.smartevents.shard.operator.WithPrometheus)1 LabelsBuilder (com.redhat.service.smartevents.shard.operator.utils.LabelsBuilder)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