use of io.fabric8.kubernetes.api.model.ContainerBuilder in project flink by apache.
the class PodTemplateMountDecorator method decorateFlinkPod.
@Override
public FlinkPod decorateFlinkPod(FlinkPod flinkPod) {
if (!getTaskManagerPodTemplateFile().isPresent()) {
return flinkPod;
}
final Pod mountedPod = decoratePod(flinkPod.getPodWithoutMainContainer());
final Container mountedMainContainer = new ContainerBuilder(flinkPod.getMainContainer()).addNewVolumeMount().withName(POD_TEMPLATE_VOLUME).withMountPath(POD_TEMPLATE_DIR_IN_POD).endVolumeMount().build();
return new FlinkPod.Builder(flinkPod).withPod(mountedPod).withMainContainer(mountedMainContainer).build();
}
use of io.fabric8.kubernetes.api.model.ContainerBuilder in project TOSCAna by StuPro-TOSCAna.
the class ResourceDeployment method build.
@Override
public ResourceDeployment build() {
ArrayList<Container> containers = new ArrayList<>();
// Create the Container objects of the containers belonging in the Pod
pod.getContainers().forEach(e -> {
Container container = new ContainerBuilder().withImage(e.getDockerImageTag().get()).withName(e.getCleanStackName()).withImagePullPolicy("Always").addAllToPorts(e.getOpenPorts().stream().map(Port::toContainerPort).collect(Collectors.toList())).build();
containers.add(container);
});
deployment = new DeploymentBuilder().withNewMetadata().withName(pod.getDeploymentName()).addToLabels("app", name).endMetadata().withNewSpec().withReplicas(pod.getReplicaCount()).withNewSelector().addToMatchLabels("app", name).endSelector().withNewTemplate().withNewMetadata().withName(name).addToLabels("app", name).endMetadata().withNewSpec().addAllToContainers(containers).endSpec().endTemplate().endSpec().build();
return this;
}
use of io.fabric8.kubernetes.api.model.ContainerBuilder in project docker-maven-plugin by fabric8io.
the class JibServiceUtilTest method testContainerFromImageConfiguration.
@Test
public void testContainerFromImageConfiguration(@Mocked JibContainerBuilder containerBuilder) throws Exception {
// Given
ImageConfiguration imageConfiguration = getSampleImageConfiguration();
// When
JibContainerBuilder jibContainerBuilder = containerFromImageConfiguration(ImageFormat.Docker.name(), imageConfiguration, null);
// Then
// @formatter:off
new Verifications() {
{
jibContainerBuilder.addLabel("foo", "bar");
times = 1;
jibContainerBuilder.setEntrypoint(Arrays.asList("java", "-jar", "foo.jar"));
times = 1;
jibContainerBuilder.setExposedPorts(new HashSet<>(Collections.singletonList(Port.tcp(8080))));
times = 1;
jibContainerBuilder.setUser("root");
times = 1;
jibContainerBuilder.setWorkingDirectory(AbsoluteUnixPath.get("/home/foo"));
times = 1;
jibContainerBuilder.setVolumes(new HashSet<>(Collections.singletonList(AbsoluteUnixPath.get("/mnt/volume1"))));
times = 1;
jibContainerBuilder.setFormat(ImageFormat.Docker);
times = 1;
}
};
// @formatter:on
}
use of io.fabric8.kubernetes.api.model.ContainerBuilder in project docker-maven-plugin by fabric8io.
the class JibBuildService method build.
public void build(String jibImageFormat, ImageConfiguration imageConfig, RegistryService.RegistryConfig registryConfig) throws MojoExecutionException {
try {
log.info("[[B]]JIB[[B]] image build started");
if (imageConfig.getBuildConfiguration().isDockerFileMode()) {
throw new MojoExecutionException("Dockerfile mode is not supported with JIB build strategy");
}
prependRegistry(imageConfig, mojoParameters.getProject().getProperties().getProperty(PUSH_REGISTRY));
BuildDirs buildDirs = new BuildDirs(imageConfig.getName(), mojoParameters);
final Credential pullRegistryCredential = getRegistryCredentials(registryConfig, false, imageConfig, log);
final JibContainerBuilder containerBuilder = containerFromImageConfiguration(jibImageFormat, imageConfig, pullRegistryCredential);
File dockerTarArchive = getAssemblyTarArchive(imageConfig, serviceHub, mojoParameters, log);
for (AssemblyConfiguration assemblyConfiguration : imageConfig.getBuildConfiguration().getAssemblyConfigurations()) {
// TODO: Improve Assembly Manager so that the effective assemblyFileEntries computed can be properly shared
// the call to DockerAssemblyManager.getInstance().createDockerTarArchive should not be necessary,
// files should be added using the AssemblyFileEntry list. DockerAssemblyManager, should provide
// a common way to achieve this so that both the tar builder and any other builder could get a hold of
// archive customizers, file entries, etc.
AssemblyFiles assemblyFiles = serviceHub.getDockerAssemblyManager().getAssemblyFiles(imageConfig.getName(), assemblyConfiguration, mojoParameters, log);
final Map<File, AssemblyFiles.Entry> files = assemblyFiles.getUpdatedEntriesAndRefresh().stream().collect(Collectors.toMap(AssemblyFiles.Entry::getDestFile, Function.identity(), (oldV, newV) -> newV));
JibServiceUtil.copyToContainer(containerBuilder, buildDirs.getOutputDirectory(), buildDirs.getOutputDirectory().getAbsolutePath(), files);
}
JibServiceUtil.buildContainer(containerBuilder, TarImage.at(dockerTarArchive.toPath()).named(imageConfig.getName()), log);
log.info(" %s successfully built", dockerTarArchive.getAbsolutePath());
} catch (Exception ex) {
throw new MojoExecutionException("Error when building JIB image", ex);
}
}
use of io.fabric8.kubernetes.api.model.ContainerBuilder in project vertx-openshift-it by cescoffier.
the class PhantomJSDeployment method createPhantomPod.
private void createPhantomPod() {
if (!retrievePod()) {
Container c = new ContainerBuilder().withName(PHANTOMJS).withImage("maschmid/phantomjs").withImagePullPolicy("Always").withEnv(new EnvVar("IGNORE_SSL_ERRORS", "true", null)).withPorts(new ContainerPortBuilder().withContainerPort(4444).withName("webdriver").build()).build();
Pod pb = new PodBuilder().withNewMetadata().withName(PHANTOMJS).addToLabels("name", PHANTOMJS).endMetadata().withNewSpec().withTerminationGracePeriodSeconds(0L).withDnsPolicy("ClusterFirst").withRestartPolicy("Always").withContainers(c).endSpec().build();
client.pods().create(pb);
}
}
Aggregations