def ctl_each(obj, command, arguments):
'''Invoke any kubectl command directly for each pod matched and collate the output.'''
width, height = click.get_terminal_size()
kubectl = obj.kubey.kubectl
collector = tabular.RowCollector()
ns_pods = defaultdict(list)
for pod in obj.kubey.each_pod(obj.maximum):
ns_pods[pod.namespace].append(pod)
for ns, pods in ns_pods.items():
args = ['-n', ns] + list(arguments) + [p.name for p in pods]
kubectl.call_table_rows(collector.handler_for(ns), command, *args)
kubectl.wait()
if collector.rows:
click.echo(tabular.tabulate(obj, sorted(collector.rows), collector.headers))
if kubectl.final_rc != 0:
click.get_current_context().exit(kubectl.final_rc)
评论列表
文章目录