在Minikube启动时运行命令 [英] Run command on Minikube startup

查看:137
本文介绍了在Minikube启动时运行命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用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启动时运行命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆