• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java PodBuilder类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中io.fabric8.kubernetes.api.model.PodBuilder的典型用法代码示例。如果您正苦于以下问题:Java PodBuilder类的具体用法?Java PodBuilder怎么用?Java PodBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PodBuilder类属于io.fabric8.kubernetes.api.model包,在下文中一共展示了PodBuilder类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: newPod

import io.fabric8.kubernetes.api.model.PodBuilder; //导入依赖的package包/类
/** Returns new instance of {@link Pod} with given name and command. */
private Pod newPod(String podName, String[] command) {
  final Container container =
      new ContainerBuilder()
          .withName(podName)
          .withImage(jobImage)
          .withImagePullPolicy(IMAGE_PULL_POLICY)
          .withCommand(command)
          .withVolumeMounts(newVolumeMount(pvcName, JOB_MOUNT_PATH, null))
          .withNewResources()
          .withLimits(singletonMap("memory", new Quantity(jobMemoryLimit)))
          .endResources()
          .build();
  return new PodBuilder()
      .withNewMetadata()
      .withName(podName)
      .endMetadata()
      .withNewSpec()
      .withContainers(container)
      .withVolumes(newVolume(pvcName, pvcName))
      .withRestartPolicy(POD_RESTART_POLICY)
      .endSpec()
      .build();
}
 
开发者ID:eclipse,项目名称:che,代码行数:25,代码来源:PVCSubPathHelper.java


示例2: setUp

import io.fabric8.kubernetes.api.model.PodBuilder; //导入依赖的package包/类
@BeforeMethod
public void setUp() throws Exception {
  container = new ContainerBuilder().withName("main").build();
  Pod pod =
      new PodBuilder()
          .withNewMetadata()
          .withName("pod")
          .endMetadata()
          .withNewSpec()
          .withContainers(container)
          .endSpec()
          .build();

  openShiftEnvironment =
      OpenShiftEnvironment.builder().setPods(ImmutableMap.of("pod", pod)).build();
  this.serverExposer = new ServerExposer(MACHINE_NAME, pod, container, openShiftEnvironment);
}
 
开发者ID:eclipse,项目名称:che,代码行数:18,代码来源:ServerExposerTest.java


示例3: setup

import io.fabric8.kubernetes.api.model.PodBuilder; //导入依赖的package包/类
@BeforeMethod
public void setup() throws Exception {
  converter = new DockerImageEnvironmentConverter();
  when(recipe.getContent()).thenReturn(RECIPE_CONTENT);
  when(recipe.getType()).thenReturn(RECIPE_TYPE);
  machines = ImmutableMap.of(MACHINE_NAME, mock(InternalMachineConfig.class));
  final Map<String, String> annotations = new HashMap<>();
  annotations.put(format(MACHINE_NAME_ANNOTATION_FMT, CONTAINER_NAME), MACHINE_NAME);
  pod =
      new PodBuilder()
          .withNewMetadata()
          .withName(POD_NAME)
          .withAnnotations(annotations)
          .endMetadata()
          .withNewSpec()
          .withContainers(
              new ContainerBuilder().withImage(RECIPE_CONTENT).withName(CONTAINER_NAME).build())
          .endSpec()
          .build();
}
 
开发者ID:eclipse,项目名称:che,代码行数:21,代码来源:DockerImageEnvironmentConverterTest.java


示例4: configureCloud

import io.fabric8.kubernetes.api.model.PodBuilder; //导入依赖的package包/类
@Before
public void configureCloud() throws Exception {
    client = setupCloud(this).connect();
    deletePods(client, getLabels(this), false);

    String image = "busybox";
    Container c = new ContainerBuilder().withName(image).withImagePullPolicy("IfNotPresent").withImage(image)
            .withCommand("cat").withTty(true).build();
    String podName = "test-command-execution-" + RandomStringUtils.random(5, "bcdfghjklmnpqrstvwxz0123456789");
    pod = client.pods().create(new PodBuilder().withNewMetadata().withName(podName).withLabels(getLabels(this))
            .endMetadata().withNewSpec().withContainers(c).endSpec().build());

    System.out.println("Created pod: " + pod.getMetadata().getName());

    decorator = new ContainerExecDecorator(client, pod.getMetadata().getName(), image, client.getNamespace());
}
 
开发者ID:carlossg,项目名称:jenkins-kubernetes-plugin,代码行数:17,代码来源:ContainerExecDecoratorTest.java


示例5: doCreatePod

import io.fabric8.kubernetes.api.model.PodBuilder; //导入依赖的package包/类
protected void doCreatePod(Exchange exchange, String operation)
        throws Exception {
    Pod pod = null;
    String podName = exchange.getIn().getHeader(
            KubernetesConstants.KUBERNETES_POD_NAME, String.class);
    String namespaceName = exchange.getIn().getHeader(
            KubernetesConstants.KUBERNETES_NAMESPACE_NAME, String.class);
    PodSpec podSpec = exchange.getIn().getHeader(
            KubernetesConstants.KUBERNETES_POD_SPEC, PodSpec.class);
    if (ObjectHelper.isEmpty(podName)) {
        LOG.error("Create a specific pod require specify a pod name");
        throw new IllegalArgumentException(
                "Create a specific pod require specify a pod name");
    }
    if (ObjectHelper.isEmpty(namespaceName)) {
        LOG.error("Create a specific pod require specify a namespace name");
        throw new IllegalArgumentException(
                "Create a specific pod require specify a namespace name");
    }
    if (ObjectHelper.isEmpty(podSpec)) {
        LOG.error("Create a specific pod require specify a pod spec bean");
        throw new IllegalArgumentException(
                "Create a specific pod require specify a pod spec bean");
    }
    Map<String, String> labels = exchange.getIn().getHeader(
            KubernetesConstants.KUBERNETES_PODS_LABELS, Map.class);
    EditablePod podCreating = new PodBuilder().withNewMetadata()
            .withName(podName).withLabels(labels).endMetadata()
            .withSpec(podSpec).build();
    pod = getEndpoint().getKubernetesClient().pods()
            .inNamespace(namespaceName).create(podCreating);
    exchange.getOut().setBody(pod);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:34,代码来源:KubernetesPodsProducer.java


示例6: convert

import io.fabric8.kubernetes.api.model.PodBuilder; //导入依赖的package包/类
public OpenShiftEnvironment convert(DockerImageEnvironment environment)
    throws InfrastructureException {
  final Iterator<String> iterator = environment.getMachines().keySet().iterator();
  if (!iterator.hasNext()) {
    throw new InternalInfrastructureException(
        "DockerImage environment must contain at least one machine configuration");
  }
  final String machineName = iterator.next();
  final String dockerImage = environment.getRecipe().getContent();
  final Map<String, String> annotations = new HashMap<>();
  annotations.put(format(MACHINE_NAME_ANNOTATION_FMT, CONTAINER_NAME), machineName);

  final Pod pod =
      new PodBuilder()
          .withNewMetadata()
          .withName(POD_NAME)
          .withAnnotations(annotations)
          .endMetadata()
          .withNewSpec()
          .withContainers(
              new ContainerBuilder().withImage(dockerImage).withName(CONTAINER_NAME).build())
          .endSpec()
          .build();
  return OpenShiftEnvironment.builder()
      .setMachines(environment.getMachines())
      .setInternalRecipe(environment.getRecipe())
      .setWarnings(environment.getWarnings())
      .setPods(ImmutableMap.of(POD_NAME, pod))
      .build();
}
 
开发者ID:eclipse,项目名称:che,代码行数:31,代码来源:DockerImageEnvironmentConverter.java


示例7: createPod

import io.fabric8.kubernetes.api.model.PodBuilder; //导入依赖的package包/类
private Pod createPod(String name, String... containers) {
  return new PodBuilder()
      .withNewMetadata()
      .withName(name)
      .endMetadata()
      .withNewSpec()
      .withContainers(
          Arrays.stream(containers).map(this::createContainer).collect(Collectors.toList()))
      .endSpec()
      .build();
}
 
开发者ID:eclipse,项目名称:che,代码行数:12,代码来源:OpenShiftEnvironmentValidatorTest.java


示例8: getPodTemplate

import io.fabric8.kubernetes.api.model.PodBuilder; //导入依赖的package包/类
@NotNull
@Override
public Pod getPodTemplate(@NotNull CloudInstanceUserData cloudInstanceUserData, @NotNull KubeCloudImage kubeCloudImage, @NotNull KubeCloudClientParameters clientParameters) {
    String agentNameProvided = cloudInstanceUserData.getAgentName();
    final String agentName = StringUtil.isEmpty(agentNameProvided) ? UUID.randomUUID().toString() : agentNameProvided;

    ImagePullPolicy imagePullPolicy = kubeCloudImage.getImagePullPolicy();
    String serverAddress = cloudInstanceUserData.getServerAddress();
    String serverUUID = myServerSettings.getServerUUID();
    String cloudProfileId = cloudInstanceUserData.getProfileId();

    ContainerBuilder containerBuilder = new ContainerBuilder()
            .withName(agentName)
            .withImage(kubeCloudImage.getDockerImage())
            .withImagePullPolicy(imagePullPolicy == null ? ImagePullPolicy.IfNotPresent.getName() : imagePullPolicy.getName())
            .withEnv(new EnvVar(KubeContainerEnvironment.AGENT_NAME, agentName, null),
                     new EnvVar(KubeContainerEnvironment.SERVER_URL, serverAddress, null),
                     new EnvVar(KubeContainerEnvironment.SERVER_UUID, serverUUID, null),
                     new EnvVar(KubeContainerEnvironment.OFFICIAL_IMAGE_SERVER_URL, serverAddress, null),
                     new EnvVar(KubeContainerEnvironment.IMAGE_ID, kubeCloudImage.getId(), null),
                     new EnvVar(KubeContainerEnvironment.PROFILE_ID, cloudProfileId, null),
                     new EnvVar(KubeContainerEnvironment.INSTANCE_NAME, agentName, null));
    String dockerCommand = kubeCloudImage.getDockerCommand();
    if(!StringUtil.isEmpty(dockerCommand)) containerBuilder = containerBuilder.withCommand(dockerCommand);
    String dockerArguments = kubeCloudImage.getDockerArguments();
    if(!StringUtil.isEmpty(dockerArguments)) containerBuilder = containerBuilder.withArgs(dockerArguments);

    return new PodBuilder()
            .withNewMetadata()
            .withName(agentName)
            .withNamespace(clientParameters.getNamespace())
            .withLabels(CollectionsUtil.asMap(
                    KubeTeamCityLabels.TEAMCITY_AGENT_LABEL, "",
                    KubeTeamCityLabels.TEAMCITY_SERVER_UUID, serverUUID,
                    KubeTeamCityLabels.TEAMCITY_CLOUD_PROFILE, cloudProfileId,
                    KubeTeamCityLabels.TEAMCITY_CLOUD_IMAGE, kubeCloudImage.getId()))
            .endMetadata()
            .withNewSpec()
            .withContainers(Collections.singletonList(containerBuilder.build()))
            .withRestartPolicy(KubeApiConnector.NEVER_RESTART_POLICY)
            .endSpec()
            .build();
}
 
开发者ID:JetBrains,项目名称:teamcity-kubernetes-plugin,代码行数:44,代码来源:SimpleRunContainerBuildAgentPodTemplateProvider.java


示例9: createPod

import io.fabric8.kubernetes.api.model.PodBuilder; //导入依赖的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


示例10: newPod

import io.fabric8.kubernetes.api.model.PodBuilder; //导入依赖的package包/类
private static Pod newPod(String podName, String restartPolicy, Container... containers) {
  final ObjectMeta podMetadata = new ObjectMetaBuilder().withName(podName).build();
  final PodSpec podSpec =
      new PodSpecBuilder().withRestartPolicy(restartPolicy).withContainers(containers).build();
  return new PodBuilder().withMetadata(podMetadata).withSpec(podSpec).build();
}
 
开发者ID:eclipse,项目名称:che,代码行数:7,代码来源:RestartPolicyRewriterTest.java


示例11: newPod

import io.fabric8.kubernetes.api.model.PodBuilder; //导入依赖的package包/类
private static Pod newPod() {
  return new PodBuilder()
      .withMetadata(new ObjectMetaBuilder().withName(POD_NAME).build())
      .build();
}
 
开发者ID:eclipse,项目名称:che,代码行数:6,代码来源:UniqueNamesProvisionerTest.java



注:本文中的io.fabric8.kubernetes.api.model.PodBuilder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ComponentEx类代码示例发布时间:2022-05-23
下一篇:
Java SimpleErrorReporter类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap