在Minikube启动时运行命令

编程入门 行业动态 更新时间:2024-10-26 20:32:05
本文介绍了在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启动时运行命令

本文发布于:2023-11-05 06:21:10,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1560133.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:启动时   命令   Minikube

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!