use of io.fabric8.kubernetes.api.model.extensions.Deployment 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.kubernetes.api.model.extensions.Deployment 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;
}
use of io.fabric8.kubernetes.api.model.extensions.Deployment in project fabric8 by jboss-fuse.
the class PatchBundlesCommandIntegrationTest method createdeployment.
@Deployment
public static JavaArchive createdeployment() {
final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "test.jar");
archive.addClass(ServiceLocator.class);
archive.addClass(IOHelpers.class);
archive.addPackage(ServiceTracker.class.getPackage());
archive.addPackages(true, OSGiManifestBuilder.class.getPackage());
archive.addPackage(CommandSupport.class.getPackage());
archive.setManifest(new Asset() {
public InputStream openStream() {
OSGiManifestBuilder builder = OSGiManifestBuilder.newInstance();
builder.addBundleSymbolicName(archive.getName());
builder.addBundleManifestVersion(2);
builder.addImportPackages(Bundle.class, Logger.class);
builder.addImportPackages(AbstractCommand.class, Action.class, Function.class, Validatable.class);
builder.addImportPackages(InvalidComponentException.class);
builder.addImportPackage("org.apache.felix.service.command;status=provisional");
return builder.openStream();
}
});
// add the original bundle as well as the patch zip files as resources
archive.add(createPatchableBundle("1.0.0"), "/bundles", ZipExporter.class);
archive.add(createPatchZipFile("patch-01"), "/patches", ZipExporter.class);
archive.add(createPatchZipFile("patch-02"), "/patches", ZipExporter.class);
archive.add(createPatchZipFile("patch-02-without-range"), "/patches", ZipExporter.class);
return archive;
}
use of io.fabric8.kubernetes.api.model.extensions.Deployment in project fabric8 by jboss-fuse.
the class ExtendedCreateChildContainerTest method deployment.
@Deployment
@StartLevelAware(autostart = true)
public static Archive<?> deployment() {
final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "extended-child-container-test.jar");
archive.addPackage(CommandSupport.class.getPackage());
archive.setManifest(new Asset() {
@Override
public InputStream openStream() {
OSGiManifestBuilder builder = OSGiManifestBuilder.newInstance();
builder.addBundleManifestVersion(2);
builder.addBundleSymbolicName(archive.getName());
builder.addBundleVersion("1.0.0");
builder.addImportPackages(ServiceLocator.class, FabricService.class);
builder.addImportPackages("io.fabric8.git");
builder.addImportPackages(AbstractCommand.class, Action.class);
builder.addImportPackage("org.apache.felix.service.command;status=provisional");
builder.addImportPackages(ConfigurationAdmin.class, ServiceTracker.class, Logger.class);
builder.addImportPackages(CuratorFramework.class, ZooKeeperUtils.class, ZkPath.class);
return builder.openStream();
}
});
return archive;
}
use of io.fabric8.kubernetes.api.model.extensions.Deployment in project fabric8 by jboss-fuse.
the class BootstrapServiceTest method deployment.
@Deployment
@StartLevelAware(autostart = true)
public static Archive<?> deployment() {
final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "bootstrap-service-test.jar");
archive.addPackage(CommandSupport.class.getPackage());
archive.setManifest(new Asset() {
@Override
public InputStream openStream() {
OSGiManifestBuilder builder = OSGiManifestBuilder.newInstance();
builder.addBundleManifestVersion(2);
builder.addBundleSymbolicName(archive.getName());
builder.addBundleVersion("1.0.0");
builder.addImportPackages(ServiceLocator.class, FabricService.class);
return builder.openStream();
}
});
return archive;
}
Aggregations