use of io.fabric8.kubernetes.api.model.Namespace in project strimzi by strimzi.
the class KafkaConnectS2IAssemblyOperator method createOrUpdate.
@Override
public void createOrUpdate(Reconciliation reconciliation, ConfigMap assemblyCm, Handler<AsyncResult<Void>> handler) {
String namespace = reconciliation.namespace();
if (isOpenShift) {
KafkaConnectS2ICluster connect = KafkaConnectS2ICluster.fromConfigMap(assemblyCm);
Future<Void> chainFuture = Future.future();
deploymentConfigOperations.scaleDown(namespace, connect.getName(), connect.getReplicas()).compose(scale -> serviceOperations.reconcile(namespace, connect.getName(), connect.generateService())).compose(i -> deploymentConfigOperations.reconcile(namespace, connect.getName(), connect.generateDeploymentConfig())).compose(i -> imagesStreamOperations.reconcile(namespace, connect.getSourceImageStreamName(), connect.generateSourceImageStream())).compose(i -> imagesStreamOperations.reconcile(namespace, connect.getName(), connect.generateTargetImageStream())).compose(i -> buildConfigOperations.reconcile(namespace, connect.getName(), connect.generateBuildConfig())).compose(i -> deploymentConfigOperations.scaleUp(namespace, connect.getName(), connect.getReplicas()).map((Void) null)).compose(chainFuture::complete, chainFuture);
chainFuture.setHandler(handler);
} else {
handler.handle(Future.failedFuture("S2I only available on OpenShift"));
}
}
use of io.fabric8.kubernetes.api.model.Namespace in project strimzi by strimzi.
the class StatefulSetOperator method restartPod.
private Future<Void> restartPod(String namespace, String name, Predicate<String> isReady, String podName) {
Future<Void> result = Future.future();
log.info("Roll {}/{}: Rolling pod {}", namespace, name, podName);
Future<Void> deleted = Future.future();
Future<CompositeFuture> deleteFinished = Future.future();
Watcher<Pod> watcher = new RollingUpdateWatcher(deleted);
Watch watch = podOperations.watch(namespace, podName, watcher);
// Delete the pod
log.debug("Roll {}/{}: Waiting for pod {} to be deleted", namespace, name, podName);
Future podReconcileFuture = podOperations.reconcile(namespace, podName, null);
CompositeFuture.join(podReconcileFuture, deleted).setHandler(deleteResult -> {
watch.close();
if (deleteResult.succeeded()) {
log.debug("Roll {}/{}: Pod {} was deleted", namespace, name, podName);
}
deleteFinished.handle(deleteResult);
});
deleteFinished.compose(ix -> {
log.debug("Roll {}/{}: Waiting for new pod {} to get ready", namespace, name, podName);
Future<Void> readyFuture = Future.future();
vertx.setPeriodic(1_000, timerId -> {
p(isReady, podName).setHandler(x -> {
if (x.succeeded()) {
if (x.result()) {
vertx.cancelTimer(timerId);
readyFuture.complete();
}
// else not ready
} else {
vertx.cancelTimer(timerId);
readyFuture.fail(x.cause());
}
});
});
return readyFuture;
}).setHandler(result);
return result;
}
use of io.fabric8.kubernetes.api.model.Namespace in project zalenium by zalando.
the class KubernetesContainerClient method registerNode.
@Override
public ContainerClientRegistration registerNode(String zaleniumContainerName, URL remoteHost) {
String podIpAddress = remoteHost.getHost();
// The only way to lookup a pod name by IP address is by looking at all pods in the namespace it seems.
PodList list = client.pods().withLabels(createdByZaleniumMap).list();
String containerId = null;
Pod currentPod = null;
for (Pod pod : list.getItems()) {
if (podIpAddress.equals(pod.getStatus().getPodIP())) {
containerId = pod.getMetadata().getName();
currentPod = pod;
break;
}
}
if (containerId == null) {
throw new IllegalStateException("Unable to locate pod by ip address, registration will fail");
}
ContainerClientRegistration registration = new ContainerClientRegistration();
List<EnvVar> podEnvironmentVariables = currentPod.getSpec().getContainers().get(0).getEnv();
Optional<EnvVar> noVncPort = podEnvironmentVariables.stream().filter(env -> "NOVNC_PORT".equals(env.getName())).findFirst();
if (noVncPort.isPresent()) {
Integer noVncPortInt = Integer.decode(noVncPort.get().getValue());
registration.setNoVncPort(noVncPortInt);
} else {
logger.warn(String.format("%s Couldn't find NOVNC_PORT, live preview will not work.", containerId));
}
registration.setIpAddress(currentPod.getStatus().getPodIP());
registration.setContainerId(containerId);
return registration;
}
use of io.fabric8.kubernetes.api.model.Namespace in project fabric8 by fabric8io.
the class KubernetesAssert method getReplicationController.
protected ReplicationController getReplicationController(String replicationControllerId, String namespace) {
assertThat(replicationControllerId).isNotNull();
ReplicationController replicationController = null;
try {
replicationController = client.replicationControllers().inNamespace(namespace).withName(replicationControllerId).get();
} catch (Exception e) {
fail("Could not find replicationController for '" + replicationControllerId + "'");
}
assertThat(replicationController).isNotNull();
return replicationController;
}
use of io.fabric8.kubernetes.api.model.Namespace in project fabric8 by fabric8io.
the class KubernetesAssert method services.
public ServicesAssert services() {
ServiceList serviceList = client.services().inNamespace(namespace()).list();
assertThat(serviceList).isNotNull();
List<Service> services = serviceList.getItems();
return new ServicesAssert(client, services);
}
Aggregations