当前位置: > 其它学习 > Kubernetes >

kubectl exec 执行 容器命令

时间:2023-03-06 10:46来源:未知 作者:IT
格式如下:
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_at, a.updated_at from ks_user_remark a WHERE a.team_id = ? and a.streamer_id in ( ? , ? , ? , ? , ? ) order by a.updated_at desc, a.id ) a group by a.streamer_id
2019-05-16 11:50:53 DEBUG [c.z.a.d.m.k.U.listByExample] ==> Parameters: 251810(Integer), 50204684(Long), 6646803(Long), 156587032(Long), 188888880(Long), 228158199(Long)
2019-05-16 11:50:53 DEBUG [c.z.a.d.m.k.U.listByExample] <==      Total: 0
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.`status`, a.created_at, a.updated_at from ks_user_collect a WHERE a.user_id = ? and a.streamer_id in ( ? , ? , ? , ? , ? ) and a.`status` = ? order by a.updated_at desc
2019-05-16 11:50:53 DEBUG [c.z.a.d.m.k.U.listByExample] ==> Parameters: 151810(Integer), 50204684(Long), 6646803(Long), 156587032(Long), 188888880(Long), 228158199(Long), 1(Integer)
2019-05-16 11:50:53 DEBUG [c.z.a.d.m.k.U.listByExample] <==      Total: 5
2019-05-16 11:50:53 DEBUG [c.z.a.d.m.t.T.listByCategoryIdList] ==>  Preparing: select id, category_id, category_name, parent_cid, parent_category_name, `desc`, `level`, is_leaf, created_at, updated_at from taobao_category_map WHERE category_id in ( ? , ? , ? , ? , ? )
2019-05-16 11:50:53 DEBUG [c.z.a.d.m.t.T.listByCategoryIdList] ==> Parameters: 50013099(Integer), 50010535(Integer), 50016845(Integer), 50018977(Integer), 50010817(Integer)



(责任编辑:IT)
------分隔线----------------------------