当前位置: 首页>>代码示例>>Java>>正文


Java PodStatus类代码示例

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


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

示例1: shouldRemoveServiceAccountSecretsAndKeysUsedByTerminatedPods

import io.fabric8.kubernetes.api.model.PodStatus; //导入依赖的package包/类
@Test
@Parameters({"Failed", "Succeeded"})
public void shouldRemoveServiceAccountSecretsAndKeysUsedByTerminatedPods(String phase) throws Exception {
  final Secret secret = fakeServiceAccountKeySecret(
      SERVICE_ACCOUNT, SECRET_EPOCH, "json-key", "p12-key", EXPIRED_CREATION_TIMESTAMP.toString());

  when(k8sClient.secrets()).thenReturn(secrets);
  when(secrets.list()).thenReturn(secretList);
  when(secretList.getItems()).thenReturn(ImmutableList.of(secret));

  final KubernetesSecretSpec secretSpec = KubernetesSecretSpec.builder()
      .serviceAccountSecret(secret.getMetadata().getName())
      .build();
  final Pod pod = KubernetesDockerRunner.createPod(WORKFLOW_INSTANCE, RUN_SPEC_WITH_SA, secretSpec);

  final PodStatus podStatus = podStatus(phase);
  pod.setStatus(podStatus);

  when(podList.getItems()).thenReturn(ImmutableList.of());
  sut.cleanup();
  verify(serviceAccountKeyManager).deleteKey(keyName(SERVICE_ACCOUNT, "json-key"));
  verify(serviceAccountKeyManager).deleteKey(keyName(SERVICE_ACCOUNT, "p12-key"));
  verify(secrets).delete(secret);
}
 
开发者ID:spotify,项目名称:styx,代码行数:25,代码来源:KubernetesGCPServiceAccountSecretManagerTest.java

示例2: createMissingContainers

import io.fabric8.kubernetes.api.model.PodStatus; //导入依赖的package包/类
/**
 * Creates any missing containers; updating the currentState with the new values.
 */
public static String createMissingContainers(final ProcessManager processManager, final KubernetesModel model, final Pod pod,
                                             final PodStatus currentState, List<Container> containers) throws Exception {
    Map<String, ContainerStatus> currentContainers = KubernetesHelper.getCurrentContainers(currentState);

    for (final Container container : containers) {
        // lets update the pod model if we update the ports
        podTransaction(model, pod, new Callable<Void>() {
            @Override
            public Void call() throws Exception {
                createContainer(processManager, model, container, pod, currentState);
                return null;
            }
        });
    }

    return null;
}
 
开发者ID:fabric8io,项目名称:jube,代码行数:21,代码来源:NodeHelper.java

示例3: ContainerService

import io.fabric8.kubernetes.api.model.PodStatus; //导入依赖的package包/类
public ContainerService(ServicePort servicePort, Pod pod) throws URISyntaxException {
    this.servicePort = servicePort;
    this.pod = pod;
    int serviceContainerPort = KubernetesHelper.intOrStringToInteger(servicePort.getTargetPort(), this.toString());
    int port = NodeHelper.findHostPortForService(pod, serviceContainerPort);

    // lets get host / port of the container
    String host = null;
    PodStatus currentState = pod.getStatus();
    if (currentState != null) {
        host = currentState.getHostIP();
        if (Strings.isBlank(host)) {
            host = currentState.getPodIP();
        }
    }
    if (Strings.isBlank(host)) {
        throw new IllegalArgumentException("No host for pod " + KubernetesHelper.getName(pod) + " so cannot use it with service port: " + servicePort.getName());
    } else {
        uri = new URI("tcp://" + host + ":" + port);
    }
}
 
开发者ID:fabric8io,项目名称:jube,代码行数:22,代码来源:ContainerService.java

示例4: updatePod

import io.fabric8.kubernetes.api.model.PodStatus; //导入依赖的package包/类
public String updatePod(final @NotNull String podId, final Pod pod) throws Exception {
    // TODO needs implementing remotely!

    return NodeHelper.excludeFromProcessMonitor(processMonitor, pod, new Callable<String>() {
        @Override
        public String call() throws Exception {
            System.out.println("Updating pod " + pod);
            PodSpec desiredState = pod.getSpec();
            Objects.notNull(desiredState, "desiredState");

            PodStatus currentState = NodeHelper.getOrCreatetStatus(pod);
            List<Container> containers = KubernetesHelper.getContainers(pod);
            model.updatePod(podId, pod);

            return NodeHelper.createMissingContainers(processManager, model, pod, currentState, containers);
        }
    });
}
 
开发者ID:fabric8io,项目名称:jube,代码行数:19,代码来源:ApiMasterService.java

示例5: getStartedTime

import io.fabric8.kubernetes.api.model.PodStatus; //导入依赖的package包/类
@NotNull
@Override
public Date getStartedTime() {
    final PodStatus podStatus = myApiConnector.getPodStatus(myPod.getMetadata().getName());
    if(podStatus == null) return myCreationTime;
    try {
        final List<PodCondition> podConditions = podStatus.getConditions();
        if (podConditions != null && !podConditions.isEmpty()) {
            for (PodCondition podCondition : podConditions) {
                if (PodConditionType.valueOf(podCondition.getType()) == PodConditionType.Ready)
                    return myPodTransitionTimeFormat.parse(podCondition.getLastTransitionTime());
            }
        }
        String startTime = podStatus.getStartTime();
        return !StringUtil.isEmpty(startTime) ? myPodStartTimeFormat.parse(startTime) : myCreationTime;
    } catch (ParseException e) {
        throw new KubeCloudException("Failed to get instance start date", e);
    }
}
 
开发者ID:JetBrains,项目名称:teamcity-kubernetes-plugin,代码行数:20,代码来源:KubeCloudInstanceImpl.java

示例6: podsAsTable

import io.fabric8.kubernetes.api.model.PodStatus; //导入依赖的package包/类
protected TablePrinter podsAsTable(PodList pods) {
    TablePrinter table = new TablePrinter();
    table.columns("id", "image(s)", "host", "labels", "status");
    List<Pod> items = pods.getItems();
    if (items == null) {
        items = Collections.EMPTY_LIST;
    }
    Filter<Pod> filter = KubernetesHelper.createPodFilter(filterText.getValue());
    for (Pod item : items) {
        if (filter.matches(item)) {
            String id = KubernetesHelper.getName(item);
            PodStatus podStatus = item.getStatus();
            String status = "";
            String host = "";
            if (podStatus != null) {
                status = KubernetesHelper.getStatusText(podStatus);
                host = podStatus.getHostIP();
            }
            Map<String, String> labelMap = item.getMetadata().getLabels();
            String labels = KubernetesHelper.toLabelsString(labelMap);
            PodSpec spec = item.getSpec();
            if (spec != null) {
                List<Container> containerList = spec.getContainers();
                for (Container container : containerList) {
                    String image = container.getImage();
                    table.row(id, image, host, labels, status);

                    id = "";
                    host = "";
                    status = "";
                    labels = "";
                }
            }
        }
    }
    return table;
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:38,代码来源:PodsList.java

示例7: isInErrorState

import io.fabric8.kubernetes.api.model.PodStatus; //导入依赖的package包/类
private static Optional<Event> isInErrorState(WorkflowInstance workflowInstance, Pod pod) {
  final PodStatus status = pod.getStatus();
  final String phase = status.getPhase();

  switch (phase) {
    case "Pending":
      // check if one or more docker contains failed to pull their image, a possible silent error
      return status.getContainerStatuses().stream()
          .filter(IS_STYX_CONTAINER.and(KubernetesPodEventTranslator::hasPullImageError))
          .findAny()
          .map((x) -> Event.runError(workflowInstance, "One or more containers failed to pull their image"));

    case "Succeeded":
    case "Failed":
      final Optional<ContainerStatus> containerStatusOpt =
          pod.getStatus().getContainerStatuses().stream()
              .filter(IS_STYX_CONTAINER)
              .findFirst();

      if (!containerStatusOpt.isPresent()) {
        return Optional.of(Event.runError(workflowInstance, "Could not find our container in pod"));
      }

      final ContainerStatus containerStatus = containerStatusOpt.get();
      final ContainerStateTerminated terminated = containerStatus.getState().getTerminated();
      if (terminated == null) {
        return Optional.of(Event.runError(workflowInstance, "Unexpected null terminated status"));
      }
      return Optional.empty();

    case "Unknown":
      return Optional.of(Event.runError(workflowInstance, "Pod entered Unknown phase"));

    default:
      return Optional.empty();
  }
}
 
开发者ID:spotify,项目名称:styx,代码行数:38,代码来源:KubernetesPodEventTranslator.java

示例8: buildTaskStatus

import io.fabric8.kubernetes.api.model.PodStatus; //导入依赖的package包/类
TaskStatus buildTaskStatus(String id) {
	Pod pod = client.pods().inNamespace(client.getNamespace()).withName(id).get();
	if (pod == null) {
		return new TaskStatus(id, LaunchState.unknown, new HashMap<>());
	}
	PodStatus podStatus = pod.getStatus();
	if (podStatus == null) {
		return new TaskStatus(id, LaunchState.unknown, new HashMap<>());
	}
	if (podStatus.getPhase() != null) {
		if (podStatus.getPhase().equals("Pending")) {
			return new TaskStatus(id, LaunchState.launching, new HashMap<>());
		}
		else if (podStatus.getPhase().equals("Failed")) {
			return new TaskStatus(id, LaunchState.failed, new HashMap<>());
		}
		else if (podStatus.getPhase().equals("Succeeded")) {
			return new TaskStatus(id, LaunchState.complete, new HashMap<>());
		}
		else {
			return new TaskStatus(id, LaunchState.running, new HashMap<>());
		}
	}
	else {
		return new TaskStatus(id, LaunchState.launching, new HashMap<>());
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-deployer-kubernetes,代码行数:28,代码来源:KubernetesTaskLauncher.java

示例9: getOrCreateContainerStatuses

import io.fabric8.kubernetes.api.model.PodStatus; //导入依赖的package包/类
/**
 * Returns the current container map for the current pod state; lazily creating if required
 */
public static List<ContainerStatus> getOrCreateContainerStatuses(Pod pod) {
    PodStatus currentState = getOrCreatetStatus(pod);
    List<ContainerStatus> containerStatuses = currentState.getContainerStatuses();
    if (containerStatuses == null) {
        containerStatuses = new ArrayList<>();
        currentState.setContainerStatuses(containerStatuses);
    }
    return containerStatuses;
}
 
开发者ID:fabric8io,项目名称:jube,代码行数:13,代码来源:NodeHelper.java

示例10: containerAlive

import io.fabric8.kubernetes.api.model.PodStatus; //导入依赖的package包/类
public static void containerAlive(Pod pod, String id, boolean alive) {
    PodStatus currentState = getOrCreatetStatus(pod);
    if (alive) {
        setPodRunning(currentState);
    } else {
        // lets check if we're waiting...
        List<ContainerStatus> containerStatuses = getOrCreateContainerStatuses(pod);
        if (containerStatuses.isEmpty() || isWaiting(containerStatuses)) {
            setPodWaiting(currentState);
        } else {
            setPodTerminated(currentState, "Failed");
        }
    }
    setContainerRunningState(pod, id, alive);
}
 
开发者ID:fabric8io,项目名称:jube,代码行数:16,代码来源:NodeHelper.java

示例11: setPodTerminated

import io.fabric8.kubernetes.api.model.PodStatus; //导入依赖的package包/类
public static void setPodTerminated(PodStatus podStatus, String message) {
    List<ContainerStatus> containerStatuses = podStatus.getContainerStatuses();
    if (containerStatuses == null) {
        containerStatuses = new ArrayList<ContainerStatus>();
        podStatus.setContainerStatuses(containerStatuses);
    }
    containerStatuses.clear();
    ContainerStatus status = new ContainerStatusBuilder().withNewState().
            withNewTermination().withMessage(message).withFinishedAt(createAtString()).endTermination().endState().
            build();
    containerStatuses.add(status);
    podStatus.setContainerStatuses(containerStatuses);
}
 
开发者ID:fabric8io,项目名称:jube,代码行数:14,代码来源:NodeHelper.java

示例12: setPodRunning

import io.fabric8.kubernetes.api.model.PodStatus; //导入依赖的package包/类
public static void setPodRunning(PodStatus podStatus) {
    List<ContainerStatus> containerStatuses = podStatus.getContainerStatuses();
    if (containerStatuses == null) {
        containerStatuses = new ArrayList<ContainerStatus>();
        podStatus.setContainerStatuses(containerStatuses);
    }
    containerStatuses.clear();
    ContainerStatus status = new ContainerStatusBuilder().withNewState().
            withNewRunning().withStartedAt(createAtString()).endRunning().endState().
            build();
    containerStatuses.add(status);
    podStatus.setContainerStatuses(containerStatuses);
}
 
开发者ID:fabric8io,项目名称:jube,代码行数:14,代码来源:NodeHelper.java

示例13: setPodWaiting

import io.fabric8.kubernetes.api.model.PodStatus; //导入依赖的package包/类
public static void setPodWaiting(PodStatus podStatus, String reason) {
    List<ContainerStatus> containerStatuses = podStatus.getContainerStatuses();
    if (containerStatuses == null) {
        containerStatuses = new ArrayList<ContainerStatus>();
        podStatus.setContainerStatuses(containerStatuses);
    }
    containerStatuses.clear();
    ContainerStatus status = new ContainerStatusBuilder().withNewState().
            withNewWaiting().withReason(reason).endWaiting().endState().
            build();
    containerStatuses.add(status);
    podStatus.setContainerStatuses(containerStatuses);
}
 
开发者ID:fabric8io,项目名称:jube,代码行数:14,代码来源:NodeHelper.java

示例14: podHasNotTerminated

import io.fabric8.kubernetes.api.model.PodStatus; //导入依赖的package包/类
/**
     * Returns a filter of all terminated pods
     */
    public static Filter<Pod> podHasNotTerminated() {
        return new Filter<Pod>() {
            @Override
            public String toString() {
                return "PodHasNotTerminatedFilter";
            }

            @Override
            public boolean matches(Pod pod) {
                PodStatus currentState = pod.getStatus();
                if (currentState != null) {
                    PodStatusType podStatus = getPodStatus(pod);
                    switch (podStatus) {
                        case ERROR:
                            return  false;
                    }
/*
                    String status = currentState.getStatus();
                    if (status != null) {
                        String lower = status.toLowerCase();
                        if (lower.startsWith("error") || lower.startsWith("fail") || lower.startsWith("term")) {
                            return false;
                        }
                    }
*/
                }
                return true;
            }
        };
    }
 
开发者ID:fabric8io,项目名称:jube,代码行数:34,代码来源:Replicator.java

示例15: createMissingContainers

import io.fabric8.kubernetes.api.model.PodStatus; //导入依赖的package包/类
protected ImmutableList<Pod> createMissingContainers(ReplicationController replicationController, PodTemplateSpec podTemplateSpec,
                                                           ReplicationControllerSpec replicationControllerSpec, int createCount, List<Pod> pods) throws Exception {
    // TODO this is a hack ;) needs replacing with the real host we're creating on
    String host = ApiMasterService.getHostName();
    List<Pod> list = Lists.newArrayList(pods);
    for (int i = 0; i < createCount; i++) {
        Pod pod = new Pod();
        pod.setKind(NodeHelper.KIND_POD);

        createNewId(replicationController, pod);
        list.add(pod);

        List<Container> containers = KubernetesHelper.getContainers(podTemplateSpec);
        for (Container container : containers) {
            String containerName = getName(pod) + "-" + container.getName();

            ContainerStatus containerInfo = NodeHelper.getOrCreateContainerInfo(pod, containerName);
            PodStatus currentState = pod.getStatus();
            Objects.notNull(currentState, "currentState");
            currentState.setHostIP(host);

            String image = container.getImage();
            if (Strings.isBlank(image)) {
                LOG.warn("Missing image for " + containerName + " so cannot create it!");
                continue;
            }
            NodeHelper.addOrUpdateDesiredContainer(pod, containerName, container);
        }
        PodTemplateSpec podTemplate = replicationControllerSpec.getTemplate();
        if (podTemplate != null) {
            getOrCreateMetadata(pod).setLabels(KubernetesHelper.getLabels(podTemplate.getMetadata()));
        }
        // TODO should we update the pod now we've updated it?
        List<Container> desiredContainers = NodeHelper.getOrCreatePodDesiredContainers(pod);
        model.remoteCreatePod(pod);
    }
    return ImmutableList.copyOf(list);
}
 
开发者ID:fabric8io,项目名称:jube,代码行数:39,代码来源:Replicator.java


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