Search in sources :

Example 1 with V1StatefulSetBuilder

use of io.kubernetes.client.openapi.models.V1StatefulSetBuilder in project cdap by caskdata.

the class KubeTwillPreparer method buildStatefulSet.

/**
 * Returns a {@link V1StatefulSet} object for the {@link TwillRunnable} represented by the
 * given {@link RuntimeSpecification}
 */
private V1StatefulSet buildStatefulSet(V1ObjectMeta metadata, Map<String, RuntimeSpecification> runtimeSpecs, Location runtimeConfigLocation, StatefulRunnable statefulRunnable) {
    List<StatefulDisk> disks = statefulRunnable.getStatefulDisks();
    int replicas = getMainRuntimeSpecification(runtimeSpecs).getResourceSpecification().getInstances();
    return new V1StatefulSetBuilder().withMetadata(metadata).withNewSpec().withSelector(new V1LabelSelector().matchLabels(metadata.getLabels())).withReplicas(replicas).withPodManagementPolicy(statefulRunnable.isOrderedStart() ? "OrderedReady" : "Parallel").addAllToVolumeClaimTemplates(disks.stream().map(this::createPVC).collect(Collectors.toList())).withNewTemplate().withMetadata(metadata).withSpec(createPodSpec(runtimeConfigLocation, runtimeSpecs, disks.stream().map(this::createDiskMount).toArray(V1VolumeMount[]::new))).endTemplate().endSpec().build();
}
Also used : StatefulDisk(io.cdap.cdap.master.spi.twill.StatefulDisk) V1StatefulSetBuilder(io.kubernetes.client.openapi.models.V1StatefulSetBuilder) V1LabelSelector(io.kubernetes.client.openapi.models.V1LabelSelector) V1VolumeMount(io.kubernetes.client.openapi.models.V1VolumeMount)

Aggregations

StatefulDisk (io.cdap.cdap.master.spi.twill.StatefulDisk)1 V1LabelSelector (io.kubernetes.client.openapi.models.V1LabelSelector)1 V1StatefulSetBuilder (io.kubernetes.client.openapi.models.V1StatefulSetBuilder)1 V1VolumeMount (io.kubernetes.client.openapi.models.V1VolumeMount)1