# 并行执行命令
kubectl mexec -l app.kubernetes.io/name=foo -p 3 -- bash -c "ip a | grep eth0"
footest-2 456: eth0@if142:
mtu 1430 qdisc noqueue state UP group default
footest-2 inet 172.16.1.101/32 scope global eth0
footest-0 460: eth0@if211:
mtu 1430 qdisc noqueue state UP group default
footest-0 inet 172.16.1.103/32 scope global eth0
footest-1 458: eth0@if434:
mtu 1430 qdisc noqueue state UP group default
footest-1 inet 172.16.1.102/32 scope global eth0
# 并行执行本地脚本
kubectl mexec -l app.kubernetes.io/name=foo -p 3 -F ./test.sh
# 批量上传文件
kubectl mexec upload -l app.kubernetes.io/name=myapp --local-file ./local-file --remote-path /tmp/local-file
# 批量下载文件
kubectl mexec download -l app.kubernetes.io/name=myapp --remote-path /tmp/local-file
推荐 krew 安装
kubectl krew update
kubectl krew install mexec