use of io.fabric8.openshift.api.model.DeploymentConfig in project vertx-openshift-it by cescoffier.
the class ConfigurationIT method deployApp.
private static String deployApp(String name, String templatePath) throws IOException {
String appName;
List<? extends HasMetadata> entities = deploymentAssistant.deploy(name, new File(templatePath));
Optional<String> first = entities.stream().filter(hm -> hm instanceof DeploymentConfig).map(hm -> (DeploymentConfig) hm).map(dc -> dc.getMetadata().getName()).findFirst();
if (first.isPresent()) {
appName = first.get();
} else {
throw new IllegalStateException("Application deployment config not found");
}
Route route = deploymentAssistant.getRoute(appName);
assertThat(route).isNotNull();
return "http://" + route.getSpec().getHost();
}
use of io.fabric8.openshift.api.model.DeploymentConfig in project vertx-openshift-it by cescoffier.
the class HealthCheckIT method getContainers.
private List<Container> getContainers() {
DeploymentConfig dc = client.deploymentConfigs().withName(deploymentAssistant.applicationName()).get();
ensureThat("the deployment config " + deploymentAssistant.applicationName() + " exists", () -> assertThat(dc).isNotNull());
return dc.getSpec().getTemplate().getSpec().getContainers();
}
use of io.fabric8.openshift.api.model.DeploymentConfig in project vertx-openshift-it by cescoffier.
the class CircuitBreakerIT method deployApp.
/**
* @param name
* @param templatePath
* @return the app route
* @throws IOException
*/
private static String deployApp(String name, String templatePath) throws IOException {
String appName = "";
List<? extends HasMetadata> entities = OPENSHIFT.deploy(name, new File(templatePath));
Optional<String> first = entities.stream().filter(hm -> hm instanceof DeploymentConfig).map(hm -> (DeploymentConfig) hm).map(dc -> dc.getMetadata().getName()).findFirst();
if (first.isPresent()) {
appName = first.get();
} else {
throw new IllegalStateException("Application deployment config not found");
}
Route route = OPENSHIFT.client().routes().inNamespace(OPENSHIFT.project()).withName(appName).get();
assertThat(route).isNotNull();
return "http://" + route.getSpec().getHost();
}
use of io.fabric8.openshift.api.model.DeploymentConfig in project vertx-openshift-it by cescoffier.
the class Deployment method deployIfNeeded.
public static String deployIfNeeded(KubernetesClient client, File input) {
OpenShiftClient oc = oc(client);
assertThat(input).isFile();
try {
byte[] bytes = Files.readBytes(input);
try (ByteArrayInputStream bis = new ByteArrayInputStream(bytes)) {
DeploymentConfig deploymentConfig = oc.deploymentConfigs().load(bis).get();
assertThat(deploymentConfig).isNotNull();
if (oc.deploymentConfigs().withName(deploymentConfig.getMetadata().getName()).get() != null) {
System.out.println("Skipping the creation of dc/" + deploymentConfig.getMetadata().getName());
return deploymentConfig.getMetadata().getName();
}
oc.deploymentConfigs().create(deploymentConfig);
OC.execute("deploy", deploymentConfig.getMetadata().getName(), "--latest", "-n", oc.getNamespace());
return deploymentConfig.getMetadata().getName();
}
} catch (Exception e) {
throw new RuntimeException("Unable to deploy deployment config " + input.getAbsolutePath(), e);
}
}
use of io.fabric8.openshift.api.model.DeploymentConfig in project vertx-openshift-it by cescoffier.
the class Kube method setReplicasAndWait.
public static DeploymentConfig setReplicasAndWait(KubernetesClient client, String name, int number) {
OpenShiftClient oc = oc(client);
DeploymentConfig config = oc.deploymentConfigs().withName(name).get();
if (config == null) {
fail("Unable to find the deployment config " + name);
return null;
}
if (config.getSpec().getReplicas() == number) {
return config;
}
config = oc.deploymentConfigs().withName(name).edit().editSpec().withReplicas(number).endSpec().done();
if (number == 0) {
// Wait until no pods
await().atMost(duration()).until(() -> getPodsForDeploymentConfig(client, name).size() == 0);
} else {
// Wait until the right number of pods
await().atMost(duration()).until(() -> getPodsForDeploymentConfig(client, name).size() == number);
// Wait for readiness
await().atMost(duration()).until(() -> getPodsForDeploymentConfig(client, name).stream().filter(KubernetesHelper::isPodReady).count() == number);
}
return config;
}
Aggregations