格式如下:
kubectl exec -it podName -c containerName -n namespace -- shell comand
1 创建目录
kubectl exec -it spark-master-xksl -c spark-master -n spark -- mkdir -p /usr/local/spark
注意:
shell命令前,要加-- 号,不然shell命令中的参数,不能识别
实例配置:
查看pod 的 日志
[root@k8s-hd-master03 ~]# kubectl exec -it $(kubectl get pod -n zhiyi-system-test|grep "ai-live-dev"|awk '{print $1}') -n zhiyi-system-test -- tail -f /home/ailive-logs/gray/ailive_dao.2019-05-16.log
2019-05-16 11:50:53 DEBUG [c.z.a.d.m.k.U.getUserPage] <== Total: 5
2019-05-16 11:50:53 DEBUG [c.z.a.d.m.k.U.listByExample] ==> Preparing: select a.id, a.user_id, a.team_id, a.streamer_id, a.remark, a.organization, a.created_at, a.updated_at from ( select a.id, a.user_id, a.team_id, a.streamer_id, a.remark, a.organization, a.created_