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);
}
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);
}
}
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;
}
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;
}
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);
}
Aggregations