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();
}
Aggregations