@Override public void contribute(Builder builder) { try { Pod current = utils.currentPod().get(); Map<String, Object> details = new HashMap<>(); if (current != null) { details.put("inside", true); details.put("namespace", current.getMetadata().getNamespace()); details.put("podName", current.getMetadata().getName()); details.put("podIp", current.getStatus().getPodIP()); details.put("serviceAccount", current.getSpec().getServiceAccountName()); details.put("nodeName", current.getSpec().getNodeName()); details.put("hostIp", current.getStatus().getHostIP()); } else { details.put("inside", false); } builder.withDetail("kubernetes", details); } catch (Exception e) { LOG.warn("Failed to get pod details", e); } } }
String appName = zaleniumPod.getMetadata().getLabels().get("app");
String containerName = createdPod.getMetadata() == null ? containerIdPrefix : createdPod.getMetadata().getName(); return new ContainerCreationStatus(true, containerName, containerName, nodePort);
containerId = pod.getMetadata().getName(); currentPod = pod; break;
@Override protected void doHealthCheck(Health.Builder builder) throws Exception { try { Pod current = utils.currentPod().get(); if (current != null) { builder.up().withDetail("inside", true) .withDetail("namespace", current.getMetadata().getNamespace()) .withDetail("podName", current.getMetadata().getName()) .withDetail("podIp", current.getStatus().getPodIP()) .withDetail("serviceAccount", current.getSpec().getServiceAccountName()) .withDetail("nodeName", current.getSpec().getNodeName()) .withDetail("hostIp", current.getStatus().getHostIP()); } else { builder.up().withDetail("inside", false); } } catch (Exception e) { builder.down(e); } } }
@Override public void eventReceived(Action action, Pod aPod) { log(aPod.getMetadata().getName(), aPod.getStatus().getPhase()); if(aPod.getStatus().getPhase().equals("Succeeded")) { log("Logs -> ", client.pods().inNamespace(namespace).withName(aPod.getMetadata().getName()).getLog()); watchLatch.countDown(); } }
NonNamespaceOperation<Pod, PodList, DoneablePod, PodResource<Pod, DoneablePod>> pods = client.pods().inNamespace(namespace); Pod result = pods.create(pod); System.out.println("Created pod " + result.getMetadata().getName()); } else { System.err.println("Loaded resource is not a Pod! " + resource);
podList.getItems().forEach((obj) -> { System.out.println(obj.getMetadata().getName()); }); podList.getItems().forEach((obj) -> { System.out.println(obj.getMetadata().getName()); });
@Override protected void doHealthCheck(Health.Builder builder) throws Exception { try { Pod current = utils.currentPod().get(); if (current != null) { builder.up() .withDetail("inside", true) .withDetail("namespace", current.getMetadata().getNamespace()) .withDetail("podName", current.getMetadata().getName()) .withDetail("podIp", current.getStatus().getPodIP()) .withDetail("serviceAccount", current.getSpec().getServiceAccountName()) .withDetail("nodeName", current.getSpec().getNodeName()) .withDetail("hostIp", current.getStatus().getHostIP()); } else { builder.up() .withDetail("inside", false); } } catch (Exception e) { builder.down(e); } } }
private static String getPodUid(Pod resource) { if (resource == null || resource.getMetadata() == null) { return NO_UID; } return resource.getMetadata().getUid(); } }
public PodLogHandler(LogsController logsController, Pod pod) { this.logsController = logsController; this.podName = pod.getMetadata().getName(); Map<String, String> annotations = pod.getMetadata().getAnnotations(); this.integrationId = annotations.get(OpenShiftService.INTEGRATION_ID_LABEL); Map<String, String> labels = pod.getMetadata().getLabels(); this.deploymentId = labels.get(OpenShiftService.DEPLOYMENT_ID_LABEL); }
public Collection<String> getIntegrationPods() { return client.pods().list().getItems().stream() .filter(pod -> pod.getMetadata().getLabels().containsKey("integration")) .map(pod -> pod.getMetadata().getLabels().get("integration")) .collect(Collectors.toList()); }
client.settings().podPresets().inNamespace(namespace).create(podPreset); pod = client.pods().inNamespace(namespace).withName(pod.getMetadata().getName()).get(); log("Updated pod: "); log(SerializationUtils.dumpAsYaml(pod));
@VisibleForTesting void cleanupWithoutRunState(WorkflowInstance workflowInstance, Pod pod) { // Precondition: The run states were fetched after the pods if (isTerminated(pod)) { deletePodIfNonDeletePeriodExpired(workflowInstance, pod); } else { // Only pass in the pod name and not the potentially stale pod information refreshAndDeleteNonTerminatedPodWithoutRunState(workflowInstance, pod.getMetadata().getName()); } }
private Set<String> pullClusterMembers() { List<Pod> pods = kubernetesClient.pods() .inNamespace(this.lockConfiguration.getKubernetesResourcesNamespaceOrDefault(kubernetesClient)) .withLabels(this.lockConfiguration.getClusterLabels()) .list().getItems(); return pods.stream().map(pod -> pod.getMetadata().getName()).collect(Collectors.toSet()); }
public Future<ReconcileResult<Pod>> deletePod(String namespace, String name) { Labels labels = Labels.fromMap(null).withName(name); String podName = podOperations.list(namespace, labels).get(0).getMetadata().getName(); return podOperations.reconcile(namespace, podName, null); }
pods().inNamespace(namespace).withName(pod.getMetadata().getName()) .edit() .editMetadata().addToLabels(DEPLOYMENT_KEY, oldDeploymentHash)
private boolean isPodUpToDate(StatefulSet ss, Pod pod) { final int ssGeneration = StatefulSetOperator.getSsGeneration(ss); final int podGeneration = StatefulSetOperator.getPodGeneration(pod); log.debug("Rolling update of {}/{}: pod {} has {}={}; ss has {}={}", ss.getMetadata().getNamespace(), ss.getMetadata().getName(), pod.getMetadata().getName(), StatefulSetOperator.ANNO_STRIMZI_IO_GENERATION, podGeneration, StatefulSetOperator.ANNO_STRIMZI_IO_GENERATION, ssGeneration); return ssGeneration == podGeneration; }
@After public void removeBuildPod() { final List<String> pods = kubernetesClient.pods().inNamespace(namespace).list().getItems().stream() .filter(pod -> pod.getMetadata().getName().startsWith("spring-boot-rest-http-s2i")) .map(pod -> pod.getMetadata().getName()) .collect(Collectors.toList()); for (String pod : pods) { kubernetesClient.pods().inNamespace(namespace).withName(pod).delete(); } } }
public PodFluentImpl(Pod instance){ this.withApiVersion(instance.getApiVersion()); this.withKind(instance.getKind()); this.withMetadata(instance.getMetadata()); this.withSpec(instance.getSpec()); this.withStatus(instance.getStatus()); }