use of com.liveperson.ephemerals.provider.kubernetes.wait.KubernetesLoadBalancerWaiter in project ephemerals by LivePersonInc.
the class KubernetesDeploymentHandler method destroy.
@Override
public void destroy(Deployment deployment) {
List<ReplicationController> apps = kubernetesClient.replicationControllers().withLabel(DEPLOYMENT_LABEL_KEY, deployment.getId()).list().getItems();
for (ReplicationController rc : apps) {
String deploymentId = rc.getMetadata().getName();
logger.info("Deleting service, replication controller and pods for deployment: {}", deploymentId);
Service svc = kubernetesClient.services().withName(deploymentId).get();
if (svc.getSpec().getType().equals(KubernetesServiceType.LOAD_BALANCER.getValue())) {
KubernetesLoadBalancerWaiter kubernetesLoadBalancerWaiter = new KubernetesLoadBalancerWaiter(kubernetesClient, deployment);
try {
kubernetesLoadBalancerWaiter.start();
} catch (TimeoutException e) {
throw new DeploymentException(e);
}
}
Boolean svcDeleted = kubernetesClient.services().withName(deploymentId).delete();
logger.info("Deleted service for deployment: {} {}", deploymentId, svcDeleted);
Boolean rcDeleted = kubernetesClient.replicationControllers().withName(deploymentId).delete();
logger.info("Deleted replication controller for deployment: {} {}", deploymentId, rcDeleted);
Map<String, String> selector = new HashMap<>();
selector.put(DEPLOYMENT_LABEL_KEY, deploymentId);
Boolean podDeleted = kubernetesClient.pods().withLabels(selector).delete();
logger.info("Deleted pods for deployment: {} {}", deploymentId, podDeleted);
}
}
Aggregations