use of io.kubernetes.client.openapi.models.V1Volume in project twister2 by DSC-SPIDAL.
the class RequestObjectBuilder method createVolatileVolume.
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;
}
use of io.kubernetes.client.openapi.models.V1Volume in project twister2 by DSC-SPIDAL.
the class RequestObjectBuilder method createPersistentVolume.
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;
}
use of io.kubernetes.client.openapi.models.V1Volume in project twister2 by DSC-SPIDAL.
the class RequestObjectBuilder method createSecretVolume.
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;
}
use of io.kubernetes.client.openapi.models.V1Volume in project heron by twitter.
the class V1Controller method createVolumeAndMountsHostPathCLI.
/**
* Generates the <code>Volume</code>s and <code>Volume Mounts</code> for <code>Host Path</code>s to be
* placed in the <code>Executor</code> and <code>Manager</code> from options on the CLI.
* @param mapOfOpts Mapping of <code>Volume</code> option <code>key-value</code> configuration pairs.
* @param volumes A list of <code>Volume</code> to append to.
* @param volumeMounts A list of <code>Volume Mounts</code> to append to.
*/
@VisibleForTesting
protected void createVolumeAndMountsHostPathCLI(final Map<String, Map<KubernetesConstants.VolumeConfigKeys, String>> mapOfOpts, final List<V1Volume> volumes, final List<V1VolumeMount> volumeMounts) {
for (Map.Entry<String, Map<KubernetesConstants.VolumeConfigKeys, String>> configs : mapOfOpts.entrySet()) {
final String volumeName = configs.getKey();
final V1Volume volume = new V1VolumeBuilder().withName(volumeName).withNewHostPath().endHostPath().build();
for (Map.Entry<KubernetesConstants.VolumeConfigKeys, String> config : configs.getValue().entrySet()) {
switch(config.getKey()) {
case type:
volume.getHostPath().setType(config.getValue());
break;
case pathOnHost:
volume.getHostPath().setPath(config.getValue());
break;
default:
break;
}
}
volumes.add(volume);
volumeMounts.add(createVolumeMountsCLI(volumeName, configs.getValue()));
}
}
use of io.kubernetes.client.openapi.models.V1Volume in project heron by twitter.
the class VolumesTests method testAwsEbsVolume.
@Test
public void testAwsEbsVolume() {
final String volumeId = "aws-ebs-1";
final String fsType = "ext4";
final Config config = Config.newBuilder().put(KubernetesContext.KUBERNETES_VOLUME_TYPE, "awsElasticBlockStore").put(KubernetesContext.KUBERNETES_VOLUME_AWS_EBS_VOLUME_ID, volumeId).put(KubernetesContext.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);
}
Aggregations