A tool for observing Kubernetes pods' statuses in real time.
Often times it's very hard to translate a Kubernetes event to a concrete state, and that's the gap that ocular tries fill, i.e. return one of the following statuses:
created
building
unschedulable
scheduled
running
succeeded
failed
stopped
unknown
ocular returns as well a condensed information about the reason of that status.
$ pip install -U ocular
import ocular
from kubernetes import client
api_client = client.api_client.ApiClient(configuration=...)
for pod_state in ocular.monitor(api_client,
namespace='polyaxon',
container_names=('polyaxon-experiment-job',),
label_selector='app in (workers,dashboard),type=runner'):
print(pod_state)
Results
...
>> {'status': 'unknown', 'message': 'Unknown pod conditions', 'details': {'event_type': 'ADDED', 'labels': ...
>> {'status': 'building', 'message': None, 'details': {'event_type': 'MODIFIED', 'labels': ...
>> {'status': 'building', 'message': 'PodInitializing', 'details': {'event_type': 'MODIFIED', 'labels': ...
>> {'status': 'building', 'message': 'PodInitializing', 'details': {'event_type': 'MODIFIED', 'labels': ...
>> {'status': 'running', 'message': None, 'details': {'event_type': 'MODIFIED', 'labels': ...
>> {'status': 'running', 'message': None, 'details': {'event_type': 'MODIFIED', 'labels': ...
>> {'status': 'succeeded', 'message': None, 'details': {'event_type': 'MODIFIED', 'labels': ...
...