修改前:
ssh root@192.168.31.167 'kubectl apply -f /root/jenkinsexcute/saas.demo.api.k8s.yml --record'
echo "export KUBECONFIG=/etc/kubernetes/admin.conf" >> /root/.bashrc
修改后 添加一段:export KUBECONFIG=/etc/kubernetes/admin.conf
ssh root@192.168.31.167 'export KUBECONFIG=/etc/kubernetes/admin.conf && kubectl apply -f /root/jenkinsexcute/saas.demo.api.k8s.yml --record'
再执行命令就成功了: