I want to get events in a namespace, namespace = lcm
In [55]: from kubernetes import client, config
In [56]: config.load_kube_config()
In [57]: api = client.EventsV1beta1Api()
In [58]: api.list_namespaced_event("lcm")
Error:
In [55]: from kubernetes import client, config
In [56]: config.load_kube_config()
In [57]: api = client.EventsV1beta1Api()
In [58]: api.list_namespaced_event("lcm")
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-58-03b1bb5b9b0e> in <module>()
----> 1 api.list_namespaced_event("lcm")
/usr/lib/python2.7/site-packages/kubernetes/client/apis/events_v1beta1_api.pyc in list_namespaced_event(self, namespace, **kwargs)
641 return self.list_namespaced_event_with_http_info(namespace, **kwargs)
642 else:
--> 643 (data) = self.list_namespaced_event_with_http_info(namespace, **kwargs)
644 return data
645
/usr/lib/python2.7/site-packages/kubernetes/client/apis/events_v1beta1_api.pyc in list_namespaced_event_with_http_info(self, namespace, **kwargs)
744 _preload_content=params.get('_preload_content', True),
745 _request_timeout=params.get('_request_timeout'),
--> 746 collection_formats=collection_formats)
747
748 def patch_namespaced_event(self, name, namespace, body, **kwargs):
/usr/lib/python2.7/site-packages/kubernetes/client/api_client.pyc in call_api(self, resource_path, method, path_params, query_params, header_params, body, post_params, files, response_type, auth_settings, async_req, _return_http_data_only, collection_formats, _preload_content, _request_timeout)
319 body, post_params, files,
320 response_type, auth_settings,
--> 321 _return_http_data_only, collection_formats, _preload_content, _request_timeout)
322 else:
323 thread = self.pool.apply_async(self.__call_api, (resource_path, method,
/usr/lib/python2.7/site-packages/kubernetes/client/api_client.pyc in __call_api(self, resource_path, method, path_params, query_params, header_params, body,post_params, files, response_type, auth_settings, _return_http_data_only, collection_formats, _preload_content, _request_timeout)
161 # deserialize response data
162 if response_type:
--> 163 return_data = self.deserialize(response_data, response_type)
164 else:
165 return_data = None
/usr/lib/python2.7/site-packages/kubernetes/client/api_client.pyc in deserialize(self, response, response_type)
234 data = response.data
235
--> 236 return self.__deserialize(data, response_type)
237
238 def __deserialize(self, data, klass):
/usr/lib/python2.7/site-packages/kubernetes/client/api_client.pyc in __deserialize(self, data, klass)
274 return self.__deserialize_datatime(data)
275 else:
--> 276 return self.__deserialize_model(data, klass)
277
278 def call_api(self, resource_path, method,
/usr/lib/python2.7/site-packages/kubernetes/client/api_client.pyc in __deserialize_model(self, data, klass)
618 and isinstance(data, (list, dict)):
619 value = data[klass.attribute_map[attr]]
--> 620 kwargs[attr] = self.__deserialize(value, attr_type)
621
622 instance = klass(**kwargs)
/usr/lib/python2.7/site-packages/kubernetes/client/api_client.pyc in __deserialize(self, data, klass)
252 sub_kls = re.match('list\[(.*)\]', klass).group(1)
253 return [self.__deserialize(sub_data, sub_kls)
--> 254 for sub_data in data]
255
256 if klass.startswith('dict('):
/usr/lib/python2.7/site-packages/kubernetes/client/api_client.pyc in __deserialize(self, data, klass)
274 return self.__deserialize_datatime(data)
275 else:
--> 276 return self.__deserialize_model(data, klass)
277
278 def call_api(self, resource_path, method,
/usr/lib/python2.7/site-packages/kubernetes/client/api_client.pyc in __deserialize_model(self, data, klass)
620 kwargs[attr] = self.__deserialize(value, attr_type)
621
--> 622 instance = klass(**kwargs)
623
624 if hasattr(instance, 'get_real_child_model'):
/usr/lib/python2.7/site-packages/kubernetes/client/models/v1beta1_event.pyc in __init__(self, action, api_version, deprecated_count, deprecated_first_timestamp, deprecated_last_timestamp, deprecated_source, event_time, kind, metadata, note, reason, regarding, related, reporting_controller, reporting_instance, series, type)
107 if deprecated_source is not None:
108 self.deprecated_source = deprecated_source
--> 109 self.event_time = event_time
110 if kind is not None:
111 self.kind = kind
/usr/lib/python2.7/site-packages/kubernetes/client/models/v1beta1_event.pyc in event_time(self, event_time)
288 """
289 if event_time is None:
--> 290 raise ValueError("Invalid value for `event_time`, must not be `None`")
291
292 self._event_time = event_time
ValueError: Invalid value for `event_time`, must not be `None`
event_time ???
What is the event time?
thanks !! Please.
In EventsV1beta1 the event_time is required. If you don鈥檛 want this hassle maybe use EventsV1.
I鈥檓 guessing that you had an event created from a more recent version of the API where the event time can be optional. Event_time is the time when the event is first observed.
In
EventsV1beta1the event_time is required. If you don鈥檛 want this hassle maybe useEventsV1.
I鈥檓 guessing that you had an event created from a more recent version of the API where the event time can be optional. Event_time is the time when the event is first observed.
thanks very much ! CoreV1Api can do that,
In [90]: from kubernetes import client, config
In [91]: config.load_kube_config()
In [92]: api = client.CoreV1Api()
In [93]: api.list_namespaced_event("lcm")
Thanks
Most helpful comment
thanks very much !
CoreV1Apican do that,Thanks