def pod_logs(**payload): """ Get logs for a given pod """ pod_name = re.search(payload["regex"], payload["data"]["text"]).group(1) pod = next( (pod for pod in k.list_pod_for_all_namespaces(watch=False).items if pod_name in pod.metadata.name), None, ) logging.debug(f"found this pod: {pod}") if not pod: send_message( f"Could not find pod named {pod_name}. Did you type it correctly?", payload) else: message = (f"Here are the logs from `{pod_name}`", ) file = k.read_namespaced_pod_log(pod_name, pod.metadata.namespace) send_file(message, file, payload)
def describe_pod(**payload): """ Get details about a pod include env vars and other useful info """ pod_name = re.search(payload["regex"], payload["data"]["text"]).group(1) pod = next( (pod for pod in k.list_pod_for_all_namespaces(watch=False).items if pod_name in pod.metadata.name), None, ) logging.debug(f"found this pod: {pod}") if not pod: send_message( f"Could not find pod named {pod_name}. Did you type it correctly?", payload) else: message = (f"Here is the description for pod {pod_name}", ) file = k.read_namespaced_pod(pod_name, pod.metadata.namespace, pretty="true") send_file(message, file, payload)