@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); } } }
@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 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 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); } } }
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); } }
n.put("hostIp", ps.getHostIP()); n.put("message", ps.getMessage()); n.put("phase", ps.getPhase());
result.put("pod.startTime", pod.getStatus().getStartTime()); result.put("pod.ip", pod.getStatus().getPodIP()); result.put("host.ip", pod.getStatus().getHostIP()); result.put("phase", pod.getStatus().getPhase()); result.put(AbstractKubernetesDeployer.SPRING_APP_KEY.replace('-', '.'),
public PodStatusBuilder( PodStatusFluent<?> fluent , PodStatus instance ){ this.fluent = fluent; fluent.withConditions(instance.getConditions()); fluent.withContainerStatuses(instance.getContainerStatuses()); fluent.withHostIP(instance.getHostIP()); fluent.withMessage(instance.getMessage()); fluent.withPhase(instance.getPhase()); fluent.withPodIP(instance.getPodIP()); fluent.withStartTime(instance.getStartTime()); } public PodStatusBuilder( PodStatus instance ){
public PodStatusBuilder( PodStatusFluent<?> fluent , PodStatus instance ){ this.fluent = fluent; fluent.withCondition(instance.getCondition()); fluent.withContainerStatuses(instance.getContainerStatuses()); fluent.withHostIP(instance.getHostIP()); fluent.withMessage(instance.getMessage()); fluent.withPhase(instance.getPhase()); fluent.withPodIP(instance.getPodIP()); fluent.withStartTime(instance.getStartTime()); } public PodStatusBuilder( PodStatus instance ){
public PodStatusBuilder( PodStatus instance ){ this.fluent = this; this.withCondition(instance.getCondition()); this.withContainerStatuses(instance.getContainerStatuses()); this.withHostIP(instance.getHostIP()); this.withMessage(instance.getMessage()); this.withPhase(instance.getPhase()); this.withPodIP(instance.getPodIP()); this.withStartTime(instance.getStartTime()); }
public PodStatusBuilder( PodStatus instance ){ this.fluent = this; this.withConditions(instance.getConditions()); this.withContainerStatuses(instance.getContainerStatuses()); this.withHostIP(instance.getHostIP()); this.withMessage(instance.getMessage()); this.withPhase(instance.getPhase()); this.withPodIP(instance.getPodIP()); this.withStartTime(instance.getStartTime()); }
public PodStatusBuilder(PodStatusFluent<?> fluent,PodStatus instance,Boolean validationEnabled){ this.fluent = fluent; fluent.withConditions(instance.getConditions()); fluent.withContainerStatuses(instance.getContainerStatuses()); fluent.withHostIP(instance.getHostIP()); fluent.withMessage(instance.getMessage()); fluent.withPhase(instance.getPhase()); fluent.withPodIP(instance.getPodIP()); fluent.withReason(instance.getReason()); fluent.withStartTime(instance.getStartTime()); this.validationEnabled = validationEnabled; } public PodStatusBuilder(PodStatus instance){
public PodStatusFluentImpl(PodStatus instance){ this.withConditions(instance.getConditions()); this.withContainerStatuses(instance.getContainerStatuses()); this.withHostIP(instance.getHostIP()); this.withMessage(instance.getMessage()); this.withPhase(instance.getPhase()); this.withPodIP(instance.getPodIP()); this.withReason(instance.getReason()); this.withStartTime(instance.getStartTime()); }
public PodStatusBuilder(PodStatus instance,Boolean validationEnabled){ this.fluent = this; this.withConditions(instance.getConditions()); this.withContainerStatuses(instance.getContainerStatuses()); this.withHostIP(instance.getHostIP()); this.withMessage(instance.getMessage()); this.withPhase(instance.getPhase()); this.withPodIP(instance.getPodIP()); this.withReason(instance.getReason()); this.withStartTime(instance.getStartTime()); this.validationEnabled = validationEnabled; }
private PodStatus getPodStatus(String podName) { io.fabric8.kubernetes.api.model.PodStatus kubernetesPodStatus = kubernetesClient .pods() .inNamespace(environment.getKubernetesNamespace()) .withName(podName) .get() .getStatus(); PodStatus podStatus = new PodStatus(); podStatus.setName(podName); podStatus.setHostIp(kubernetesPodStatus.getHostIP()); podStatus.setPodIp(kubernetesPodStatus.getPodIP()); podStatus.setPhase(kubernetesPodStatus.getPhase()); podStatus.setReason(kubernetesPodStatus.getReason()); podStatus.setStartTime(kubernetesPodStatus.getStartTime()); podStatus.setHasJolokia(getPodJolokiaPort(podName).isPresent()); podStatus.setContainers(getPodContainerNames(podName)); return podStatus; }
@Override protected void doHealthCheck(Health.Builder builder) throws Exception { try { Pod current = utils.currentPod().get(); if (current != null) { builder.up() .withDetail("inside", true) .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 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 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); } } }