Search in sources :

Example 1 with KubernetesDeploymentEndpointWaiter

use of com.liveperson.ephemerals.provider.kubernetes.wait.KubernetesDeploymentEndpointWaiter in project ephemerals by LivePersonInc.

the class KubernetesDeploymentHandler method deploy.

@Override
public DeploymentEndpoints deploy(Deployment deployment) {
    // Create service on KubernetesServiceBuilder cluster
    Service service = kubernetesDeploymentStrategy.service(deployment);
    kubernetesClient.services().inNamespace(kubernetesClient.getNamespace()).create(service);
    // Create pods and replication controller
    ReplicationController replicationController = kubernetesDeploymentStrategy.replicationController(deployment);
    kubernetesClient.replicationControllers().inNamespace(kubernetesClient.getNamespace()).create(replicationController);
    // Wait for deployment to finish by polling KubernetesServiceBuilder and waiting for 'FINISHED' status
    KubernetesDeploymentStatusWaiter deploymentStatusWaiter = new KubernetesDeploymentStatusWaiter(kubernetesClient, deployment, DeploymentStatus.FINISHED);
    try {
        deploymentStatusWaiter.start();
    } catch (TimeoutException e) {
        throw new DeploymentException(e);
    }
    DeploymentEndpoints endpoints = new DeploymentEndpoints();
    for (DeploymentPort deploymentPort : deployment.getDeploymentUnit().getPorts()) {
        KubernetesDeploymentEndpointWaiter kubernetesDeploymentEndpointWaiter = new KubernetesDeploymentEndpointWaiter(kubernetesClient, deployment, deploymentPort);
        try {
            kubernetesDeploymentEndpointWaiter.start();
            endpoints.add(kubernetesDeploymentEndpointWaiter.getEndpoint());
        } catch (TimeoutException e) {
            throw new DeploymentException(e);
        }
    }
    return endpoints;
}
Also used : KubernetesDeploymentStatusWaiter(com.liveperson.ephemerals.provider.kubernetes.wait.KubernetesDeploymentStatusWaiter) ReplicationController(io.fabric8.kubernetes.api.model.ReplicationController) KubernetesDeploymentEndpointWaiter(com.liveperson.ephemerals.provider.kubernetes.wait.KubernetesDeploymentEndpointWaiter) Service(io.fabric8.kubernetes.api.model.Service) TimeoutException(java.util.concurrent.TimeoutException)

Aggregations

KubernetesDeploymentEndpointWaiter (com.liveperson.ephemerals.provider.kubernetes.wait.KubernetesDeploymentEndpointWaiter)1 KubernetesDeploymentStatusWaiter (com.liveperson.ephemerals.provider.kubernetes.wait.KubernetesDeploymentStatusWaiter)1 ReplicationController (io.fabric8.kubernetes.api.model.ReplicationController)1 Service (io.fabric8.kubernetes.api.model.Service)1 TimeoutException (java.util.concurrent.TimeoutException)1