本文整理汇总了Java中io.fabric8.kubernetes.api.model.VolumeMountBuilder类的典型用法代码示例。如果您正苦于以下问题:Java VolumeMountBuilder类的具体用法?Java VolumeMountBuilder怎么用?Java VolumeMountBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VolumeMountBuilder类属于io.fabric8.kubernetes.api.model包,在下文中一共展示了VolumeMountBuilder类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: volumeMountInfo
import io.fabric8.kubernetes.api.model.VolumeMountBuilder; //导入依赖的package包/类
private VolumeMountInfo volumeMountInfo(PersistentVolumeClaim claim, VolumeMount volumeMount) {
final String claimName = claim.getMetadata().getName();
final Volume volume = new VolumeBuilder()
.withName(claimName)
.withNewPersistentVolumeClaim(claimName, volumeMount.readOnly())
.build();
final io.fabric8.kubernetes.api.model.VolumeMount mount = new VolumeMountBuilder()
.withName(claimName)
.withMountPath(volumeMount.mountPath())
.withReadOnly(volumeMount.readOnly())
.build();
final String ro = volumeMount.readOnly() ? "readOnly" : "readWrite";
LOG.info("Mounting {} {} at {}", claimName, ro, volumeMount.mountPath());
return new VolumeMountInfoBuilder()
.persistentVolumeClaim(claim)
.volume(volume)
.volumeMount(mount)
.build();
}
开发者ID:spotify,项目名称:hype,代码行数:24,代码来源:KubernetesDockerRunner.java
示例2: mountsSecretVolumeWhenLoadedFromYaml
import io.fabric8.kubernetes.api.model.VolumeMountBuilder; //导入依赖的package包/类
@Test
public void mountsSecretVolumeWhenLoadedFromYaml() throws Exception {
RunEnvironment env = fromYaml("/minimal-pod.yaml")
.withSecret(SECRET);
Pod pod = createPod(env);
final PodSpec spec = pod.getSpec();
assertThat(spec.getVolumes(), hasItems(new VolumeBuilder()
.withName(SECRET.name())
.withNewSecret()
.withSecretName(SECRET.name())
.endSecret()
.build()));
Container container = findHypeRunContainer(pod);
assertThat(container.getVolumeMounts(), hasItems(new VolumeMountBuilder()
.withName(SECRET.name())
.withMountPath(SECRET.mountPath())
.withReadOnly(true)
.build()));
}
开发者ID:spotify,项目名称:hype,代码行数:22,代码来源:KubernetesDockerRunnerTest.java
示例3: createInitContainer
import io.fabric8.kubernetes.api.model.VolumeMountBuilder; //导入依赖的package包/类
/**
* For StatefulSets, create an init container to parse ${HOSTNAME} to get the `instance.index` and write it to
* config/application.properties on a shared volume so the main container has it. Using the legacy annotation
* configuration since the current client version does not directly support InitContainers.
*
* Since 1.8 the annotation method has been removed, and the initContainer API is supported since 1.6
*
* @return a container definition with the above mentioned configuration
*/
private Container createInitContainer() {
List<String> command = new LinkedList<>();
String commandString = String
.format("%s && %s", setIndexProperty("INSTANCE_INDEX"), setIndexProperty("spring.application.index"));
command.add("sh");
command.add("-c");
command.add(commandString);
return new ContainerBuilder().withName("index-provider")
.withImage("busybox")
.withImagePullPolicy("IfNotPresent")
.withCommand(command)
.withVolumeMounts(new VolumeMountBuilder().withName("config").withMountPath("/config").build())
.build();
}
开发者ID:spring-cloud,项目名称:spring-cloud-deployer-kubernetes,代码行数:26,代码来源:KubernetesAppDeployer.java
示例4: mountsSecretVolume
import io.fabric8.kubernetes.api.model.VolumeMountBuilder; //导入依赖的package包/类
@Test
public void mountsSecretVolume() throws Exception {
RunEnvironment env = environment()
.withSecret(SECRET);
Pod pod = createPod(env);
final PodSpec spec = pod.getSpec();
assertThat(spec.getVolumes(), hasItems(new VolumeBuilder()
.withName(SECRET.name())
.withNewSecret()
.withSecretName(SECRET.name())
.endSecret()
.build()));
Container container = findHypeRunContainer(pod);
assertThat(container.getVolumeMounts(), hasItems(new VolumeMountBuilder()
.withName(SECRET.name())
.withMountPath(SECRET.mountPath())
.withReadOnly(true)
.build()));
}
开发者ID:spotify,项目名称:hype,代码行数:22,代码来源:KubernetesDockerRunnerTest.java
示例5: newVolumeMount
import io.fabric8.kubernetes.api.model.VolumeMountBuilder; //导入依赖的package包/类
/** Returns new instance of {@link VolumeMount} with specified name, mountPath and subPath. */
public static VolumeMount newVolumeMount(String name, String mountPath, String subPath) {
return new VolumeMountBuilder()
.withMountPath(mountPath)
.withName(name)
.withSubPath(subPath)
.build();
}
开发者ID:eclipse,项目名称:che,代码行数:9,代码来源:OpenShiftObjectUtil.java
示例6: createPod
import io.fabric8.kubernetes.api.model.VolumeMountBuilder; //导入依赖的package包/类
@VisibleForTesting
Pod createPod(RunSpec runSpec) {
final String podName = HYPE_RUN + "-" + randomAlphaNumeric(8);
final RunEnvironment env = runSpec.runEnvironment();
final List<Secret> secrets = env.secretMounts();
final StagedContinuation stagedContinuation = runSpec.stagedContinuation();
final List<VolumeMountInfo> volumeMountInfos = volumeMountInfos(env.volumeMounts());
final Pod basePod = getBasePod(env, runSpec.image());
// add metadata name
final ObjectMeta metadata = basePod.getMetadata() != null
? basePod.getMetadata()
: new ObjectMeta();
metadata.setName(podName);
basePod.setMetadata(metadata);
final PodSpec spec = basePod.getSpec();
// add volumes
secrets.forEach(s ->
spec.getVolumes()
.add(new VolumeBuilder()
.withName(s.name())
.withNewSecret()
.withSecretName(s.name())
.endSecret()
.build()));
volumeMountInfos.stream()
.map(VolumeMountInfo::volume)
.forEach(spec.getVolumes()::add);
final Container container = findHypeRunContainer(basePod);
// add volume mounts
secrets.forEach(s ->
container.getVolumeMounts()
.add(new VolumeMountBuilder()
.withName(s.name())
.withMountPath(s.mountPath())
.withReadOnly(true)
.build()));
volumeMountInfos.stream()
.map(VolumeMountInfo::volumeMount)
.forEach(container.getVolumeMounts()::add);
// set args
if (container.getArgs().size() > 0) {
LOG.warn("Overriding " + HYPE_RUN + " container args");
}
container.setArgs(singletonList(stagedContinuation.manifestPath().toUri().toString()));
// add env var
container.getEnv()
.add(new EnvVarBuilder()
.withName(EXECUTION_ID)
.withValue(podName)
.build());
// add resource requests
final ResourceRequirementsBuilder resourceReqsBuilder = container.getResources() != null
? new ResourceRequirementsBuilder(
container.getResources())
: new ResourceRequirementsBuilder();
for (Map.Entry<String, String> request : env.resourceRequests().entrySet()) {
resourceReqsBuilder.addToRequests(request.getKey(), new Quantity(request.getValue()));
}
container.setResources(resourceReqsBuilder.build());
return basePod;
}
开发者ID:spotify,项目名称:hype,代码行数:72,代码来源:KubernetesDockerRunner.java
示例7: build
import io.fabric8.kubernetes.api.model.VolumeMountBuilder; //导入依赖的package包/类
public Container build() {
io.fabric8.kubernetes.api.model.ContainerBuilder builder = new io.fabric8.kubernetes.api.model.ContainerBuilder();
Stream<EnvVar> definedVars = envVars.entrySet().stream().map(entry -> new EnvVar(entry.getKey(), entry.getValue(), null));
Stream<EnvVar> referredVars = referredEnvVars.entrySet().stream().map(entry -> new EnvVar(entry.getKey(), null, new EnvVarSource(new ConfigMapKeySelectorBuilder().withKey(entry.getValue().getSecond()).withName(entry.getValue().getFirst()).build(), null, null, null)));
builder.withEnv(Stream.concat(definedVars, referredVars).collect(Collectors.toList()));
builder.withImage(imageName);
builder.withImagePullPolicy("Always");
if (command != null) {
builder.withCommand(command);
}
if (livenessProbe != null) {
builder.withLivenessProbe(livenessProbe.build());
}
builder.withName(name);
builder.withPorts(ports.stream().map(port -> {
ContainerPortBuilder portBuilder = new ContainerPortBuilder();
portBuilder.withContainerPort(port.getContainerPort());
if (port.getProtocol() != null) {
portBuilder.withProtocol(port.getProtocol().uppercase());
}
if (port.getName() != null) {
portBuilder.withName(port.getName());
}
return portBuilder.build();
}).collect(Collectors.toList()));
if (preStopHandler != null) {
builder.withNewLifecycle()
.withPreStop(preStopHandler.build())
.endLifecycle();
}
if (privileged) {
builder.withNewSecurityContext().withPrivileged(true).endSecurityContext();
}
if (readinessProbe != null) {
builder.withReadinessProbe(readinessProbe.build());
}
builder.withVolumeMounts(volumeMounts.stream().map(item -> new VolumeMountBuilder()
.withName(item.getName())
.withMountPath(item.getMountPath())
.withReadOnly(item.isReadOnly())
.build()).collect(Collectors.toList()));
final List<ComputingResource> requests = computingResources.values().stream().filter(x -> x.getRequests() != null).collect(Collectors.toList());
final List<ComputingResource> limits = computingResources.values().stream().filter(x -> x.getLimits() != null).collect(Collectors.toList());
if (!requests.isEmpty() || !limits.isEmpty())
{
ResourcesNested<io.fabric8.kubernetes.api.model.ContainerBuilder> resources = builder.withNewResources();
if (!requests.isEmpty()) {
resources.withRequests(
requests.stream().collect(Collectors.toMap(
ComputingResource::resourceIdentifier, x -> new Quantity(x.getRequests())
)));
}
if (!limits.isEmpty()) {
resources.withLimits(
limits.stream().collect(Collectors.toMap(
ComputingResource::resourceIdentifier, x -> new Quantity(x.getLimits())
)));
}
resources.endResources();
}
// args
// capabilities
// command
// lifecycle
// resources
// securityContext
// terminationMessagePath
// workingDir
return builder.build();
}
开发者ID:xtf-cz,项目名称:xtf,代码行数:82,代码来源:ContainerBuilder.java
示例8: createPod
import io.fabric8.kubernetes.api.model.VolumeMountBuilder; //导入依赖的package包/类
@VisibleForTesting
static Pod createPod(WorkflowInstance workflowInstance, RunSpec runSpec, KubernetesSecretSpec secretSpec) {
final String imageWithTag = runSpec.imageName().contains(":")
? runSpec.imageName()
: runSpec.imageName() + ":latest";
final PodBuilder podBuilder = new PodBuilder()
.withNewMetadata()
.withName(runSpec.executionId())
.addToAnnotations(STYX_WORKFLOW_INSTANCE_ANNOTATION, workflowInstance.toKey())
.addToAnnotations(DOCKER_TERMINATION_LOGGING_ANNOTATION,
String.valueOf(runSpec.terminationLogging()))
.endMetadata();
final PodSpecBuilder specBuilder = new PodSpecBuilder()
.withRestartPolicy("Never");
final ResourceRequirementsBuilder resourceRequirements = new ResourceRequirementsBuilder();
runSpec.memRequest().ifPresent(s -> resourceRequirements.addToRequests("memory", new Quantity(s)));
runSpec.memLimit().ifPresent(s -> resourceRequirements.addToLimits("memory", new Quantity(s)));
final ContainerBuilder containerBuilder = new ContainerBuilder()
.withName(STYX_RUN)
.withImage(imageWithTag)
.withArgs(runSpec.args())
.withEnv(buildEnv(workflowInstance, runSpec))
.withResources(resourceRequirements.build());
secretSpec.serviceAccountSecret().ifPresent(serviceAccountSecret -> {
final SecretVolumeSource saVolumeSource = new SecretVolumeSourceBuilder()
.withSecretName(serviceAccountSecret)
.build();
final Volume saVolume = new VolumeBuilder()
.withName(STYX_WORKFLOW_SA_SECRET_NAME)
.withSecret(saVolumeSource)
.build();
specBuilder.addToVolumes(saVolume);
final VolumeMount saMount = new VolumeMountBuilder()
.withMountPath(STYX_WORKFLOW_SA_SECRET_MOUNT_PATH)
.withName(saVolume.getName())
.withReadOnly(true)
.build();
containerBuilder.addToVolumeMounts(saMount);
containerBuilder.addToEnv(envVar(STYX_WORKFLOW_SA_ENV_VARIABLE,
saMount.getMountPath() + STYX_WORKFLOW_SA_JSON_KEY));
});
secretSpec.customSecret().ifPresent(secret -> {
final SecretVolumeSource secretVolumeSource = new SecretVolumeSourceBuilder()
.withSecretName(secret.name())
.build();
final Volume secretVolume = new VolumeBuilder()
.withName(secret.name())
.withSecret(secretVolumeSource)
.build();
specBuilder.addToVolumes(secretVolume);
final VolumeMount secretMount = new VolumeMountBuilder()
.withMountPath(secret.mountPath())
.withName(secretVolume.getName())
.withReadOnly(true)
.build();
containerBuilder.addToVolumeMounts(secretMount);
});
specBuilder.addToContainers(containerBuilder.build());
podBuilder.withSpec(specBuilder.build());
return podBuilder.build();
}
开发者ID:spotify,项目名称:styx,代码行数:72,代码来源:KubernetesDockerRunner.java
注:本文中的io.fabric8.kubernetes.api.model.VolumeMountBuilder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论