本文整理汇总了Java中io.fabric8.kubernetes.api.model.PodStatus类的典型用法代码示例。如果您正苦于以下问题:Java PodStatus类的具体用法?Java PodStatus怎么用?Java PodStatus使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PodStatus类属于io.fabric8.kubernetes.api.model包,在下文中一共展示了PodStatus类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: updateLocalPod
import io.fabric8.kubernetes.api.model.PodStatus; //导入依赖的package包/类
public String updateLocalPod(@NotNull final String podId, final Pod pod) throws Exception {
System.out.println("Updating pod " + pod);
PodSpec desiredState = pod.getSpec();
Objects.notNull(desiredState, "desiredState");
// lets ensure there's a default namespace set
String namespace = KubernetesHelper.getNamespace(pod);
if (Strings.isBlank(namespace)) {
getOrCreateMetadata(pod).setNamespace(DEFAULT_NAMESPACE);
}
final PodStatus currentState = NodeHelper.getOrCreatetStatus(pod);
final List<Container> containers = KubernetesHelper.getContainers(pod);
NodeHelper.setPodWaiting(pod);
NodeHelper.setContainerRunningState(pod, podId, false);
model.updatePod(podId, pod);
localCreateThreadPool.submit(new Runnable() {
@Override
public void run() {
Runnable task = new Runnable() {
@Override
public void run() {
try {
NodeHelper.createMissingContainers(processManager, model, pod, currentState, containers);
} catch (Exception e) {
LOG.error("Failed to create container " + podId + ". " + e, e);
}
}
};
NodeHelper.excludeFromProcessMonitor(processMonitor, pod, task);
}
});
return getName(pod);
}
开发者ID:fabric8io,项目名称:jube,代码行数:38,代码来源:ApiMasterService.java
示例17: blockUntilComplete
import io.fabric8.kubernetes.api.model.PodStatus; //导入依赖的package包/类
private Optional<URI> blockUntilComplete(final String podName) throws InterruptedException {
LOG.debug("Checking running statuses");
boolean nodeAssigned = false;
while (true) {
final PodResource<Pod, DoneablePod> pod = client.pods().withName(podName);
final PodStatus status = pod.get().getStatus();
if (!nodeAssigned && pod.get().getSpec().getNodeName() != null) {
LOG.info("Pod {} assigned to node {}", podName, pod.get().getSpec().getNodeName());
nodeAssigned = true;
}
switch (status.getPhase()) {
case "Succeeded":
LOG.info("Kubernetes pod {} exited with status {}", podName, status.getPhase());
final Optional<ContainerStatus> containerStatus = status.getContainerStatuses().stream()
.filter(c -> HYPE_RUN.equals(c.getName()))
.findFirst();
final Optional<String> terminated = containerStatus
.flatMap(s -> Optional.ofNullable(s.getState().getTerminated()))
.flatMap(t -> Optional.ofNullable(t.getMessage()));
if (terminated.isPresent()) {
String message = terminated.get();
LOG.info("Got termination message: {}", message);
return Optional.of(URI.create(message));
}
break;
case "Failed":
LOG.info("Kubernetes pod {} failed with status {}", podName, status);
return Optional.empty();
default:
break;
}
Thread.sleep(TimeUnit.SECONDS.toMillis(POLL_PODS_INTERVAL_SECONDS));
}
}
开发者ID:spotify,项目名称:hype,代码行数:44,代码来源:KubernetesDockerRunner.java
示例18: getPodStatus
import io.fabric8.kubernetes.api.model.PodStatus; //导入依赖的package包/类
@Nullable
PodStatus getPodStatus(@NotNull String podName);
开发者ID:JetBrains,项目名称:teamcity-kubernetes-plugin,代码行数:3,代码来源:KubeApiConnector.java
示例19: getPodStatus
import io.fabric8.kubernetes.api.model.PodStatus; //导入依赖的package包/类
@Nullable
@Override
public PodStatus getPodStatus(@NotNull String podName) {
final Pod podNow = myKubernetesClient.pods().withName(podName).get();
return podNow == null ? null : podNow.getStatus();
}
开发者ID:JetBrains,项目名称:teamcity-kubernetes-plugin,代码行数:7,代码来源:KubeApiConnectorImpl.java
示例20: executePod
import io.fabric8.kubernetes.api.model.PodStatus; //导入依赖的package包/类
@Override
protected void executePod(Pod podInfo, String podId) {
System.out.println("Created: " + podInfo.getMetadata().getCreationTimestamp());
System.out.println("Labels: ");
Map<String, String> labels = podInfo.getMetadata().getLabels();
for (Map.Entry<String, String> entry : labels.entrySet()) {
System.out.println(indent + entry.getKey() + " = " + entry.getValue());
}
PodStatus currentState = podInfo.getStatus();
if (currentState != null) {
printValue("Host", currentState.getHostIP());
printValue("IP", currentState.getPodIP());
printValue("Status", getStatusText(currentState));
}
PodSpec spec = podInfo.getSpec();
if (spec != null) {
List<Container> containers = spec.getContainers();
if (notEmpty(containers)) {
System.out.println("Containers:");
indentCount++;
for (Container container : containers) {
printValue("Name", container.getName());
printValue("Image", container.getImage());
printValue("Working Dir", container.getWorkingDir());
printValue("Command", container.getCommand());
List<ContainerPort> ports = container.getPorts();
if (notEmpty(ports)) {
println("Ports:");
indentCount++;
for (ContainerPort port : ports) {
printValue("Name", port.getName());
printValue("Protocol", port.getProtocol());
printValue("Host Port", port.getHostPort());
printValue("Container Port", port.getContainerPort());
}
indentCount--;
}
List<EnvVar> envList = container.getEnv();
if (notEmpty(envList)) {
println("Environment:");
indentCount++;
for (EnvVar env : envList) {
printValue(env.getName(), env.getValue());
}
indentCount--;
}
List<VolumeMount> volumeMounts = container.getVolumeMounts();
if (notEmpty(volumeMounts)) {
println("Volume Mounts:");
indentCount++;
for (VolumeMount volumeMount : volumeMounts) {
printValue("Name", volumeMount.getName());
printValue("Mount Path", volumeMount.getMountPath());
printValue("Read Only", volumeMount.getReadOnly());
}
indentCount--;
}
}
}
List<Volume> volumes = spec.getVolumes();
if (volumes != null) {
System.out.println("Volumes: ");
for (Volume volume : volumes) {
System.out.println(indent + volume.getName());
}
}
}
}
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:72,代码来源:PodInfo.java
注:本文中的io.fabric8.kubernetes.api.model.PodStatus类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论