本文整理汇总了Java中io.fabric8.kubernetes.api.model.Pod.getMetadata方法的典型用法代码示例。如果您正苦于以下问题:Java Pod.getMetadata方法的具体用法?Java Pod.getMetadata怎么用?Java Pod.getMetadata使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.fabric8.kubernetes.api.model.Pod
的用法示例。
在下文中一共展示了Pod.getMetadata方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createPod
import io.fabric8.kubernetes.api.model.Pod; //导入方法依赖的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;
}