Search in sources :

Example 11 with V1Volume

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;
}
Also used : V1Volume(io.kubernetes.client.openapi.models.V1Volume) V1EmptyDirVolumeSource(io.kubernetes.client.openapi.models.V1EmptyDirVolumeSource) Quantity(io.kubernetes.client.custom.Quantity)

Example 12 with V1Volume

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;
}
Also used : V1Volume(io.kubernetes.client.openapi.models.V1Volume) V1PersistentVolumeClaimVolumeSource(io.kubernetes.client.openapi.models.V1PersistentVolumeClaimVolumeSource)

Example 13 with V1Volume

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;
}
Also used : V1Volume(io.kubernetes.client.openapi.models.V1Volume) V1SecretVolumeSource(io.kubernetes.client.openapi.models.V1SecretVolumeSource)

Example 14 with V1Volume

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()));
    }
}
Also used : V1VolumeBuilder(io.kubernetes.client.openapi.models.V1VolumeBuilder) V1Volume(io.kubernetes.client.openapi.models.V1Volume) Map(java.util.Map) HashMap(java.util.HashMap) V1ConfigMap(io.kubernetes.client.openapi.models.V1ConfigMap) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 15 with V1Volume

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);
}
Also used : V1Volume(io.kubernetes.client.openapi.models.V1Volume) Config(org.apache.heron.spi.common.Config) Test(org.junit.Test)

Aggregations

V1Volume (io.kubernetes.client.openapi.models.V1Volume)21 Test (org.junit.Test)10 V1ConfigMap (io.kubernetes.client.openapi.models.V1ConfigMap)9 V1VolumeBuilder (io.kubernetes.client.openapi.models.V1VolumeBuilder)9 HashMap (java.util.HashMap)9 Map (java.util.Map)9 Config (org.apache.heron.spi.common.Config)8 V1VolumeMount (io.kubernetes.client.openapi.models.V1VolumeMount)7 LinkedList (java.util.LinkedList)7 Matchers.anyString (org.mockito.Matchers.anyString)6 V1VolumeMountBuilder (io.kubernetes.client.openapi.models.V1VolumeMountBuilder)5 VisibleForTesting (com.google.common.annotations.VisibleForTesting)4 ImmutableMap (com.google.common.collect.ImmutableMap)4 V1Container (io.kubernetes.client.openapi.models.V1Container)4 V1PodSpec (io.kubernetes.client.openapi.models.V1PodSpec)4 VolumeConfigKeys (org.apache.heron.scheduler.kubernetes.KubernetesConstants.VolumeConfigKeys)4 V1EmptyDirVolumeSource (io.kubernetes.client.openapi.models.V1EmptyDirVolumeSource)3 V1ObjectMeta (io.kubernetes.client.openapi.models.V1ObjectMeta)3 V1PodTemplateSpec (io.kubernetes.client.openapi.models.V1PodTemplateSpec)3 Quantity (io.kubernetes.client.custom.Quantity)2