use of io.kubernetes.client.models.V1PodSpec in project twister2 by DSC-SPIDAL.
the class KubernetesUtils method constructPodTemplate.
public static V1PodTemplateSpec constructPodTemplate(ResourceContainer reqContainer, String serviceLabel, long jobFileSize, Config config) {
V1PodTemplateSpec template = new V1PodTemplateSpec();
V1ObjectMeta templateMetaData = new V1ObjectMeta();
HashMap<String, String> labels = new HashMap<String, String>();
labels.put("app", serviceLabel);
templateMetaData.setLabels(labels);
template.setMetadata(templateMetaData);
V1PodSpec podSpec = new V1PodSpec();
podSpec.setTerminationGracePeriodSeconds(0L);
V1Volume volume = new V1Volume();
volume.setName(POD_SHARED_VOLUME_NAME);
V1EmptyDirVolumeSource volumeSource = new V1EmptyDirVolumeSource();
volumeSource.setMedium("Memory");
volume.setEmptyDir(volumeSource);
podSpec.setVolumes(Arrays.asList(volume));
int containersPerPod = KubernetesContext.containersPerPod(config);
int basePort = KubernetesContext.workerBasePort(config);
ArrayList<V1Container> containers = new ArrayList<V1Container>();
for (int i = 0; i < containersPerPod; i++) {
containers.add(constructContainer(i, reqContainer, jobFileSize, basePort + 1, config));
}
podSpec.setContainers(containers);
template.setSpec(podSpec);
return template;
}
use of io.kubernetes.client.models.V1PodSpec in project incubator-heron by apache.
the class AppsV1beta1Controller method getPodSpec.
private V1PodSpec getPodSpec(List<String> executorCommand, Resource resource, int numberOfInstances) {
final V1PodSpec podSpec = new V1PodSpec();
// set the termination period to 0 so pods can be deleted quickly
podSpec.setTerminationGracePeriodSeconds(0L);
// set the pod tolerations so pods are rescheduled when nodes go down
// https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/#taint-based-evictions
podSpec.setTolerations(getTolerations());
podSpec.containers(Collections.singletonList(getContainer(executorCommand, resource, numberOfInstances)));
addVolumesIfPresent(podSpec);
return podSpec;
}
use of io.kubernetes.client.models.V1PodSpec in project weblogic-kubernetes-operator by oracle.
the class PodHelper method validateCurrentPod.
private static boolean validateCurrentPod(V1Pod build, V1Pod current) {
if (!AnnotationHelper.checkFormatAnnotation(current.getMetadata())) {
return false;
}
V1PodSpec buildSpec = build.getSpec();
V1PodSpec currentSpec = current.getSpec();
List<V1Container> buildContainers = buildSpec.getContainers();
List<V1Container> currentContainers = currentSpec.getContainers();
if (buildContainers != null) {
if (currentContainers == null) {
return false;
}
for (V1Container bc : buildContainers) {
V1Container fcc = null;
for (V1Container cc : currentContainers) {
if (cc.getName().equals(bc.getName())) {
fcc = cc;
break;
}
}
if (fcc == null) {
return false;
}
if (!fcc.getImage().equals(bc.getImage()) || !fcc.getImagePullPolicy().equals(bc.getImagePullPolicy())) {
return false;
}
if (!compareUnordered(fcc.getPorts(), bc.getPorts())) {
return false;
}
if (!compareUnordered(fcc.getEnv(), bc.getEnv())) {
return false;
}
if (!compareUnordered(fcc.getEnvFrom(), bc.getEnvFrom())) {
return false;
}
}
}
return true;
}
Aggregations