io.fabric8.kubernetes.api.model.EventList Java Examples

The following examples show how to use io.fabric8.kubernetes.api.model.EventList. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Diagnostics.java    From dekorate with Apache License 2.0 7 votes vote down vote up
protected void events(Pod pod) {
  try {
    Map<String, String> fields = new HashMap<>();
    fields.put("involvedObject.uid", pod.getMetadata().getUid());
    fields.put("involvedObject.name", pod.getMetadata().getName());
    fields.put("involvedObject.namespace", pod.getMetadata().getNamespace());

    EventList eventList = client.events().inNamespace(pod.getMetadata().getNamespace()).withFields(fields).list();
    if (eventList == null) {
      return;
    }
    logger.warning("Events of pod: [" + pod.getMetadata().getName() + "]");
    for (Event event : eventList.getItems()) {
      logger.info(String.format("%s\t\t%s", event.getReason(), event.getMessage()));
    }
  } catch (Throwable t) {
    logger.error("Failed to read events, due to:" + t.getMessage());
  } finally {
    logger.warning("\t---");
  }
}
 
Example #2
Source File: WithEvents.java    From dekorate with Apache License 2.0 5 votes vote down vote up
default EventList getEvents(ExtensionContext context, HasMetadata resource) {
  Map<String, String> fields = new HashMap<>();
  fields.put("involvedObject.uid", resource.getMetadata().getUid());
  fields.put("involvedObject.name", resource.getMetadata().getName());
  fields.put("involvedObject.namespace", resource.getMetadata().getNamespace());
  return getKubernetesClient(context).events().inNamespace(resource.getMetadata().getNamespace()).withFields(fields).list();
}
 
Example #3
Source File: KubernetesComputer.java    From kubernetes-plugin with Apache License 2.0 5 votes vote down vote up
@Exported
public List<Event> getPodEvents() throws KubernetesAuthException, IOException {
    if(!Jenkins.get().hasPermission(Jenkins.ADMINISTER)) {
        LOGGER.log(Level.FINE, " Computer {0} getPodEvents, lack of admin permission, returning empty list", this);
        return Collections.emptyList();
    }

    KubernetesSlave slave = getNode();
    if(slave != null) {
        KubernetesCloud cloud = slave.getKubernetesCloud();
        KubernetesClient client = cloud.connect();

        String namespace = StringUtils.defaultIfBlank(slave.getNamespace(), client.getNamespace());

        Pod pod = client.pods().inNamespace(namespace).withName(getName()).get();
        if(pod != null) {
            ObjectMeta podMeta = pod.getMetadata();
            String podNamespace = podMeta.getNamespace();

            Map<String, String> fields = new HashMap<>();
            fields.put("involvedObject.uid", podMeta.getUid());
            fields.put("involvedObject.name", podMeta.getName());
            fields.put("involvedObject.namespace", podNamespace);

            EventList eventList = client.events().inNamespace(podNamespace).withFields(fields).list();
            if(eventList != null) {
                return eventList.getItems();
            }
        }
    }

    return Collections.emptyList();
}
 
Example #4
Source File: AutoAdaptableKubernetesClient.java    From kubernetes-client with Apache License 2.0 4 votes vote down vote up
@Override
public MixedOperation<Event, EventList, DoneableEvent, Resource<Event, DoneableEvent>> events() {
  return delegate.events();
}
 
Example #5
Source File: V1APIGroupClient.java    From kubernetes-client with Apache License 2.0 4 votes vote down vote up
@Override
public MixedOperation<Event, EventList, DoneableEvent, Resource<Event, DoneableEvent>> events() {
  return new EventOperationsImpl(httpClient, getConfiguration());
}
 
Example #6
Source File: DefaultKubernetesClient.java    From kubernetes-client with Apache License 2.0 4 votes vote down vote up
@Override
public MixedOperation<Event, EventList, DoneableEvent, Resource<Event, DoneableEvent>> events() {
  return new EventOperationsImpl(httpClient, getConfiguration());
}
 
Example #7
Source File: ManagedKubernetesClient.java    From kubernetes-client with Apache License 2.0 4 votes vote down vote up
public MixedOperation<Event, EventList, DoneableEvent, Resource<Event, DoneableEvent>> events() {
  return delegate.events();
}
 
Example #8
Source File: ManagedOpenShiftClient.java    From kubernetes-client with Apache License 2.0 4 votes vote down vote up
@Override
public MixedOperation<Event, EventList, DoneableEvent, Resource<Event, DoneableEvent>> events() {
  return delegate.events();
}
 
Example #9
Source File: DefaultOpenShiftClient.java    From kubernetes-client with Apache License 2.0 4 votes vote down vote up
@Override
public MixedOperation<Event, EventList, DoneableEvent, Resource<Event, DoneableEvent>> events() {
  return delegate.events();
}
 
Example #10
Source File: KubernetesClient.java    From kubernetes-client with Apache License 2.0 2 votes vote down vote up
/**
 * API entrypoint for getting events in Kubernetes. Events (core/v1)
 *
 * @deprecated Use KubernetesClient#v1#events instead.
 * @return MixedOperation object for doing operations for Events
 */
MixedOperation<Event, EventList, DoneableEvent, Resource<Event, DoneableEvent>> events();
 
Example #11
Source File: V1APIGroupDSL.java    From kubernetes-client with Apache License 2.0 votes vote down vote up
MixedOperation<Event, EventList, DoneableEvent, Resource<Event, DoneableEvent>> events();