use of io.fabric8.openshift.api.model.Build in project kubernetes by ballerinax.
the class DeploymentHandler method generate.
/**
* Generate kubernetes deployment definition from annotation.
*
* @return Generated kubernetes @{@link Deployment} definition
* @throws KubernetesPluginException If an error occurs while generating artifact.
*/
public String generate() throws KubernetesPluginException {
List<ContainerPort> containerPorts = null;
if (deploymentModel.getPorts() != null) {
containerPorts = populatePorts(deploymentModel.getPorts());
}
Container container = generateContainer(deploymentModel, containerPorts);
Deployment deployment = new DeploymentBuilder().withNewMetadata().withName(deploymentModel.getName()).withNamespace(deploymentModel.getNamespace()).withLabels(deploymentModel.getLabels()).endMetadata().withNewSpec().withReplicas(deploymentModel.getReplicas()).withNewTemplate().withNewMetadata().addToLabels(deploymentModel.getLabels()).endMetadata().withNewSpec().withContainers(container).withVolumes(populateVolume(deploymentModel)).endSpec().endTemplate().endSpec().build();
try {
return SerializationUtils.dumpWithoutRuntimeStateAsYaml(deployment);
} catch (JsonProcessingException e) {
String errorMessage = "Error while parsing yaml file for deployment: " + deploymentModel.getName();
throw new KubernetesPluginException(errorMessage, e);
}
}
use of io.fabric8.openshift.api.model.Build in project kubernetes by ballerinax.
the class DockerHandler method pushImage.
/**
* Push docker image.
*
* @param dockerModel DockerModel
* @throws InterruptedException When error with docker build process
* @throws IOException When error with docker build process
*/
public void pushImage(DockerModel dockerModel) throws InterruptedException, IOException, KubernetesPluginException {
AuthConfig authConfig = new AuthConfigBuilder().withUsername(dockerModel.getUsername()).withPassword(dockerModel.getPassword()).build();
Config config = new ConfigBuilder().withDockerUrl(dockerModel.getDockerHost()).addToAuthConfigs(RegistryUtils.extractRegistry(dockerModel.getName()), authConfig).build();
DockerClient client = new DefaultDockerClient(config);
final DockerError dockerError = new DockerError();
OutputHandle handle = client.image().withName(dockerModel.getName()).push().usingListener(new EventListener() {
@Override
public void onSuccess(String message) {
pushDone.countDown();
}
@Override
public void onError(String message) {
pushDone.countDown();
dockerError.setErrorMsg("error pushing docker image: " + message);
}
@Override
public void onError(Throwable t) {
pushDone.countDown();
dockerError.setErrorMsg("error pushing docker image: " + t.getMessage());
}
@Override
public void onEvent(String event) {
printDebug(event);
}
}).toRegistry();
pushDone.await();
handle.close();
client.close();
handleError(dockerError);
}
use of io.fabric8.openshift.api.model.Build in project kubernetes by ballerinax.
the class PersistentVolumeClaimHandler method generate.
@Override
public String generate() throws KubernetesPluginException {
Quantity quantity = new QuantityBuilder().withAmount(volumeClaimModel.getVolumeClaimSize()).build();
Map<String, Quantity> requests = new HashMap<>();
requests.put("storage", quantity);
PersistentVolumeClaim secret = new PersistentVolumeClaimBuilder().withNewMetadata().withName(volumeClaimModel.getName()).endMetadata().withNewSpec().withAccessModes(volumeClaimModel.getAccessMode()).withNewResources().withRequests(requests).endResources().endSpec().build();
try {
return SerializationUtils.dumpWithoutRuntimeStateAsYaml(secret);
} catch (JsonProcessingException e) {
String errorMessage = "Error while parsing yaml file for volume claim: " + volumeClaimModel.getName();
throw new KubernetesPluginException(errorMessage, e);
}
}
use of io.fabric8.openshift.api.model.Build in project fabric8 by jboss-fuse.
the class CamelProfileScriptTest method testFeatures.
@Test
public void testFeatures() throws Exception {
System.out.println(executeCommand("fabric:create -n --wait-for-provisioning"));
// System.out.println(executeCommand("shell:info"));
// System.out.println(executeCommand("fabric:info"));
// System.out.println(executeCommand("fabric:profile-list"));
ServiceProxy<FabricService> fabricProxy = ServiceProxy.createServiceProxy(bundleContext, FabricService.class);
try {
FabricService fabricService = fabricProxy.getService();
Set<ContainerProxy> containers = ContainerBuilder.create(fabricProxy).withName("feature-camel").withProfiles("feature-camel").assertProvisioningResult().build();
try {
CuratorFramework curator = fabricService.adapt(CuratorFramework.class);
assertProvisionedFeature(fabricService, curator, containers, "camel-script-javascript", "feature-camel", "scriptengines-javascript");
} finally {
ContainerBuilder.destroy(containers);
}
} finally {
fabricProxy.close();
}
}
use of io.fabric8.openshift.api.model.Build in project fabric8 by jboss-fuse.
the class CamelProfileTest method testFeatures.
@Test
public void testFeatures() throws Exception {
System.out.println(executeCommand("fabric:create -n --wait-for-provisioning"));
// System.out.println(executeCommand("shell:info"));
// System.out.println(executeCommand("fabric:info"));
// System.out.println(executeCommand("fabric:profile-list"));
ServiceProxy<FabricService> fabricProxy = ServiceProxy.createServiceProxy(bundleContext, FabricService.class);
try {
FabricService fabricService = fabricProxy.getService();
Set<ContainerProxy> containers = ContainerBuilder.create(fabricProxy).withName("feature-camel").withProfiles("feature-camel").assertProvisioningResult().build();
try {
CuratorFramework curator = fabricService.adapt(CuratorFramework.class);
assertProvisionedFeature(fabricService, curator, containers, "camel-http", "feature-camel", "camel-http");
assertProvisionedFeature(fabricService, curator, containers, "camel-jetty", "feature-camel", "camel-jetty");
assertProvisionedFeature(fabricService, curator, containers, "camel-jms", "feature-camel", "camel-jms");
assertProvisionedFeature(fabricService, curator, containers, "camel-ftp", "feature-camel", "camel-ftp");
assertProvisionedFeature(fabricService, curator, containers, "camel-quartz", "feature-camel", "camel-quartz");
} finally {
ContainerBuilder.destroy(containers);
}
} finally {
fabricProxy.close();
}
}
Aggregations