io.kubernetes.client.openapi.models.V1Volume Java Examples
The following examples show how to use
io.kubernetes.client.openapi.models.V1Volume.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VolumesTests.java From incubator-heron with Apache License 2.0 | 6 votes |
@Test public void testAwsEbsVolume() { final String volumeId = "aws-ebs-1"; final String fsType = "ext4"; final Config config = Config.newBuilder() .put(KubernetesContext.HERON_KUBERNETES_VOLUME_TYPE, "awsElasticBlockStore") .put(KubernetesContext.HERON_KUBERNETES_VOLUME_AWS_EBS_VOLUME_ID, volumeId) .put(KubernetesContext.HERON_KUBERNETES_VOLUME_AWS_EBS_FS_TYPE, fsType) .build(); final V1Volume volume = Volumes.get().create(config); Assert.assertNotNull(volume); Assert.assertNotNull(volume.getAwsElasticBlockStore()); Assert.assertEquals(volume.getAwsElasticBlockStore().getVolumeID(), volumeId); Assert.assertEquals(volume.getAwsElasticBlockStore().getFsType(), fsType); }
Example #2
Source File: VolumesTests.java From incubator-heron with Apache License 2.0 | 6 votes |
@Test public void testNfsVolume() { final String path = "/test/dir1"; final String server = "10.10.10.10"; final Config config = Config.newBuilder() .put(KubernetesContext.HERON_KUBERNETES_VOLUME_TYPE, "nfs") .put(KubernetesContext.HERON_KUBERNETES_VOLUME_NFS_PATH, path) .put(KubernetesContext.HERON_KUBERNETES_VOLUME_NFS_SERVER, server) .build(); final V1Volume volume = Volumes.get().create(config); Assert.assertNotNull(volume); Assert.assertNotNull(volume.getNfs()); Assert.assertEquals(volume.getNfs().getPath(), path); Assert.assertEquals(volume.getNfs().getServer(), server); }
Example #3
Source File: AppsV1Controller.java From incubator-heron with Apache License 2.0 | 5 votes |
private void addVolumesIfPresent(V1PodSpec spec) { final Config config = getConfiguration(); if (KubernetesContext.hasVolume(config)) { final V1Volume volume = Volumes.get().create(config); if (volume != null) { LOG.fine("Adding volume: " + volume.toString()); spec.volumes(Collections.singletonList(volume)); } } }
Example #4
Source File: VolumesTests.java From incubator-heron with Apache License 2.0 | 5 votes |
@Test public void testHostPathVolume() { final String path = "/test/dir1"; final Config config = Config.newBuilder() .put(KubernetesContext.HERON_KUBERNETES_VOLUME_TYPE, "hostPath") .put(KubernetesContext.HERON_KUBERNETES_VOLUME_HOSTPATH_PATH, path) .build(); final V1Volume volume = Volumes.get().create(config); Assert.assertNotNull(volume); Assert.assertNotNull(volume.getHostPath()); Assert.assertEquals(volume.getHostPath().getPath(), path); }
Example #5
Source File: Volumes.java From incubator-heron with Apache License 2.0 | 5 votes |
@Override public V1Volume create(Config config) { final V1Volume volume = newVolume(config); final String volumeId = KubernetesContext.getAwsEbsVolumeId(config); final String fsType = KubernetesContext.getAwsEbsFsType(config); V1AWSElasticBlockStoreVolumeSource awsElasticBlockStoreVolumeSource = new V1AWSElasticBlockStoreVolumeSource() .volumeID(volumeId) .fsType(fsType); volume.setAwsElasticBlockStore(awsElasticBlockStoreVolumeSource); return volume; }
Example #6
Source File: Volumes.java From incubator-heron with Apache License 2.0 | 5 votes |
@Override public V1Volume create(Config config) { final V1Volume volume = newVolume(config); final String path = KubernetesContext.getNfsVolumePath(config); final String server = KubernetesContext.getNfsServer(config); V1NFSVolumeSource nfsVolumeSource = new V1NFSVolumeSource() .path(path) .server(server); volume.setNfs(nfsVolumeSource); return volume; }
Example #7
Source File: Volumes.java From incubator-heron with Apache License 2.0 | 5 votes |
@Override public V1Volume create(Config config) { final V1Volume volume = newVolume(config); final String path = KubernetesContext.getHostPathVolumePath(config); final V1HostPathVolumeSource hostPathVolume = new V1HostPathVolumeSource() .path(path); volume.hostPath(hostPathVolume); return volume; }
Example #8
Source File: Volumes.java From incubator-heron with Apache License 2.0 | 5 votes |
V1Volume create(Config config) { final String volumeType = KubernetesContext.getVolumeType(config); if (volumes.containsKey(volumeType)) { return volumes.get(volumeType).create(config); } return null; }
Example #9
Source File: V1alpha1PodPresetSpec.java From java with Apache License 2.0 | 5 votes |
public V1alpha1PodPresetSpec addVolumesItem(V1Volume volumesItem) { if (this.volumes == null) { this.volumes = new ArrayList<V1Volume>(); } this.volumes.add(volumesItem); return this; }
Example #10
Source File: RequestObjectBuilder.java From twister2 with Apache License 2.0 | 5 votes |
public static V1Volume createSecretVolume(String secretName) { V1Volume secretVolume = new V1Volume(); secretVolume.setName(KubernetesConstants.SECRET_VOLUME_NAME); V1SecretVolumeSource secretVolumeSource = new V1SecretVolumeSource(); secretVolumeSource.setSecretName(secretName); secretVolumeSource.setDefaultMode(256); secretVolume.setSecret(secretVolumeSource); return secretVolume; }
Example #11
Source File: RequestObjectBuilder.java From twister2 with Apache License 2.0 | 5 votes |
public static V1Volume createPersistentVolume(String claimName) { V1Volume persistentVolume = new V1Volume(); persistentVolume.setName(KubernetesConstants.PERSISTENT_VOLUME_NAME); V1PersistentVolumeClaimVolumeSource perVolSource = new V1PersistentVolumeClaimVolumeSource(); perVolSource.setClaimName(claimName); persistentVolume.setPersistentVolumeClaim(perVolSource); return persistentVolume; }
Example #12
Source File: RequestObjectBuilder.java From twister2 with Apache License 2.0 | 5 votes |
public static V1Volume createVolatileVolume(double volumeSize) { V1Volume volatileVolume = new V1Volume(); volatileVolume.setName(KubernetesConstants.POD_VOLATILE_VOLUME_NAME); V1EmptyDirVolumeSource volumeSource2 = new V1EmptyDirVolumeSource(); volumeSource2.setSizeLimit(new Quantity(String.format("%.2fGi", volumeSize))); volatileVolume.setEmptyDir(volumeSource2); return volatileVolume; }
Example #13
Source File: V1PodSpec.java From java with Apache License 2.0 | 5 votes |
/** * List of volumes that can be mounted by containers belonging to the pod. More info: https://kubernetes.io/docs/concepts/storage/volumes * @return volumes **/ @javax.annotation.Nullable @ApiModelProperty(value = "List of volumes that can be mounted by containers belonging to the pod. More info: https://kubernetes.io/docs/concepts/storage/volumes") public List<V1Volume> getVolumes() { return volumes; }
Example #14
Source File: V1PodSpec.java From java with Apache License 2.0 | 5 votes |
public V1PodSpec addVolumesItem(V1Volume volumesItem) { if (this.volumes == null) { this.volumes = new ArrayList<V1Volume>(); } this.volumes.add(volumesItem); return this; }
Example #15
Source File: V1alpha1PodPresetSpec.java From java with Apache License 2.0 | 5 votes |
/** * Volumes defines the collection of Volume to inject into the pod. * @return volumes **/ @javax.annotation.Nullable @ApiModelProperty(value = "Volumes defines the collection of Volume to inject into the pod.") public List<V1Volume> getVolumes() { return volumes; }
Example #16
Source File: RequestObjectBuilder.java From twister2 with Apache License 2.0 | 4 votes |
/** * construct pod template */ public static V1PodTemplateSpec constructPodTemplate(ComputeResource computeResource) { V1PodTemplateSpec template = new V1PodTemplateSpec(); V1ObjectMeta templateMetaData = new V1ObjectMeta(); HashMap<String, String> labels = KubernetesUtils.createJobLabels(jobID); labels.put("t2-wp", jobID); // worker pod templateMetaData.setLabels(labels); template.setMetadata(templateMetaData); V1PodSpec podSpec = new V1PodSpec(); podSpec.setTerminationGracePeriodSeconds(0L); ArrayList<V1Volume> volumes = new ArrayList<>(); V1Volume memoryVolume = new V1Volume(); memoryVolume.setName(KubernetesConstants.POD_MEMORY_VOLUME_NAME); V1EmptyDirVolumeSource volumeSource1 = new V1EmptyDirVolumeSource(); volumeSource1.setMedium("Memory"); memoryVolume.setEmptyDir(volumeSource1); volumes.add(memoryVolume); // a volatile disk based volume // create it if the requested disk space is positive if (computeResource.getDiskGigaBytes() > 0) { double volumeSize = computeResource.getDiskGigaBytes() * computeResource.getWorkersPerPod(); V1Volume volatileVolume = createVolatileVolume(volumeSize); volumes.add(volatileVolume); } if (SchedulerContext.persistentVolumeRequested(config)) { String claimName = jobID; V1Volume persistentVolume = createPersistentVolume(claimName); volumes.add(persistentVolume); } // if openmpi is used, we initialize a Secret volume on each pod if (SchedulerContext.useOpenMPI(config)) { String secretName = KubernetesContext.secretName(config); V1Volume secretVolume = createSecretVolume(secretName); volumes.add(secretVolume); } podSpec.setVolumes(volumes); int containersPerPod = computeResource.getWorkersPerPod(); // if openmpi is used, we initialize only one container for each pod if (SchedulerContext.useOpenMPI(config)) { containersPerPod = 1; } ArrayList<V1Container> containers = new ArrayList<V1Container>(); for (int i = 0; i < containersPerPod; i++) { containers.add(constructContainer(computeResource, i)); } podSpec.setContainers(containers); if (computeResource.getIndex() == 0) { constructAffinity(podSpec); } template.setSpec(podSpec); return template; }
Example #17
Source File: Volumes.java From incubator-heron with Apache License 2.0 | 4 votes |
private static V1Volume newVolume(Config config) { final String volumeName = KubernetesContext.getVolumeName(config); return new V1Volume().name(volumeName); }
Example #18
Source File: JobMasterRequestObject.java From twister2 with Apache License 2.0 | 4 votes |
/** * construct pod template */ public static V1PodTemplateSpec constructPodTemplate() { V1PodTemplateSpec template = new V1PodTemplateSpec(); V1ObjectMeta templateMetaData = new V1ObjectMeta(); HashMap<String, String> labels = KubernetesUtils.createJobLabels(jobID); labels.put("t2-mp", jobID); // job master pod templateMetaData.setLabels(labels); template.setMetadata(templateMetaData); V1PodSpec podSpec = new V1PodSpec(); podSpec.setTerminationGracePeriodSeconds(0L); ArrayList<V1Volume> volumes = new ArrayList<>(); V1Volume memoryVolume = new V1Volume(); memoryVolume.setName(KubernetesConstants.POD_MEMORY_VOLUME_NAME); V1EmptyDirVolumeSource volumeSource1 = new V1EmptyDirVolumeSource(); volumeSource1.setMedium("Memory"); memoryVolume.setEmptyDir(volumeSource1); volumes.add(memoryVolume); // a volatile disk based volume // create it if the requested disk space is positive if (JobMasterContext.volatileVolumeRequested(config)) { double vSize = JobMasterContext.volatileVolumeSize(config); V1Volume volatileVolume = RequestObjectBuilder.createVolatileVolume(vSize); volumes.add(volatileVolume); } if (JobMasterContext.persistentVolumeRequested(config)) { String claimName = jobID; V1Volume persistentVolume = RequestObjectBuilder.createPersistentVolume(claimName); volumes.add(persistentVolume); } podSpec.setVolumes(volumes); ArrayList<V1Container> containers = new ArrayList<V1Container>(); containers.add(constructContainer()); podSpec.setContainers(containers); template.setSpec(podSpec); return template; }
Example #19
Source File: V1PodSpec.java From java with Apache License 2.0 | 4 votes |
public void setVolumes(List<V1Volume> volumes) { this.volumes = volumes; }
Example #20
Source File: VolumesTests.java From incubator-heron with Apache License 2.0 | 4 votes |
@Test public void testNoVolume() { final Config config = Config.newBuilder().build(); final V1Volume volume = Volumes.get().create(config); Assert.assertNull(volume); }
Example #21
Source File: V1alpha1PodPresetSpec.java From java with Apache License 2.0 | 4 votes |
public void setVolumes(List<V1Volume> volumes) { this.volumes = volumes; }
Example #22
Source File: Volumes.java From incubator-heron with Apache License 2.0 | votes |
V1Volume create(Config config);