我正在使用Minikube在本地计算机上使用Kubernetes,并且想在启动后(最好在Pods启动之前)在VM上运行命令.我可以使用minikube ssh手动运行它,但是每次重新启动后都很难做,而且很难包装在脚本中.
I'm using Minikube for working with Kubernetes on my local machine, and would like to run a command on the VM just after startup (preferably before the Pods start). I can run it manually with minikube ssh, but that's a bit of a pain to do after every restart, and is difficult to wrap in a script.
有一种简单的方法吗?
在我的情况下,命令是这样的,以便VM上的路径与主机上的路径匹配:
The command in my case is this, so that paths on the VM match paths on my host machine:
sudo mount --bind /hosthome/<user> /home/<user>推荐答案
也许可以传递给minikube start的标志在您的情况下会很有用:
Maybe flags which can you pass to minikube start would be useful in your case:
--mount This will start the mount daemon and automatically mount files into minikube --mount-string string The argument to pass the minikube mount command on start (default "/home/user:/minikube-host")也许您可以编写启动minikube的脚本,例如:
Maybe you could write script for starting your minikube like:
minikube start && ssh -t -i ~/.minikube/machines/minikube/id_rsa docker@$(minikube ip) "sudo mount --bind /hosthome/<user> /home/<user>"将在启动后启动minikube并使用SSH发出bind命令
that will start minikube and issue bind command using SSH after start
更多推荐
在Minikube启动时运行命令
发布评论