class_docstr: An orchestrator implmentation which uses Kubernetes to deploy the components such as training and rollout workers
  and Redis Pub/Sub in Coach when used in the distributed mode.
class_docstr_tok: ["An","orchestrator","implmentation","which","uses","Kubernetes","to","deploy","the","components","such","as","training","and","rollout","workers","and","Redis","Pub\/Sub","in","Coach","when","used","in","the","distributed","mode","."]
code: def tail_log(self, pod_name, corev1_api):
      while True:
          time.sleep(10)
          # Try to tail the pod logs
          try:
              for line in corev1_api.read_namespaced_pod_log(
                  pod_name,
                  self.params.namespace,
                  follow=True,
                  _preload_content=False,
              ):
                  screen.print(line.decode("utf-8"), flush=True, end="")
          except k8sclient.rest.ApiException as e:
              pass
  
          # This part will get executed if the pod is one of the following phases: not ready, failed or terminated.
          # Check if the pod has errored out, else just try again.
          # Get the pod
          try:
              pod = corev1_api.read_namespaced_pod(
                  pod_name, self.params.namespace
              )
          except k8sclient.rest.ApiException as e:
              continue
  
          if not hasattr(pod, "status") or not pod.status:
              continue
          if (
              not hasattr(pod.status, "container_statuses")
              or not pod.status.container_statuses
          ):
              continue
  
          for container_status in pod.status.container_statuses:
              if container_status.state.waiting is not None:
                  if (
                      container_status.state.waiting.reason == "Error"
                      or container_status.state.waiting.reason
                      == "CrashLoopBackOff"
                      or container_status.state.waiting.reason
                      == "ImagePullBackOff"
                      or container_status.state.waiting.reason
                      == "ErrImagePull"
                  ):
                      return 1
              if container_status.state.terminated is not None:
                  return container_status.state.terminated.exit_code
  
imports: import os
  import uuid
  import json
  import time
  import sys
  from enum import Enum
  from typing import List
  from configparser import ConfigParser, Error
  from multiprocessing import Process
  from rl_coach.base_parameters import RunType
  from rl_coach.orchestrators.deploy import Deploy, DeployParameters
  from kubernetes import client, config
  from rl_coach.memories.backend.memory import MemoryBackendParameters
  from rl_coach.memories.backend.memory_impl import get_memory_backend
  from rl_coach.data_stores.data_store import DataStoreParameters
  from rl_coach.data_stores.data_store_impl import get_data_store
  from rl_coach.logger import screen
label_desc: Use image node_id 8 for calling the Kubernetes obj's underlying member method code with example usage: obj.tail_log(pod_name, corev1_api) and returns: container_status, int