我正在使用 minikube 运行 kubernets bootcamp 教程,其中一个教程要求通过运行命令来注册 POD_NAME:
export POD_NAME="$(kubectl get pods -o go-template --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}')"
当我尝试运行它时,出现以下错误:
error: error parsing template {{range .items}}{{.metadata.name}}{{\n}}{{end}}, template: output:1: unexpected "\\" in command
export : The term 'export' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the
name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ export POD_NAME="$(kubectl get pods -o go-template --template '{{rang ...
+ ~~~~~~
+ CategoryInfo : ObjectNotFound: (export:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
我在 Windows 操作系统中运行 minikube,并使用 Docker Desktop 作为 Docker 容器驱动程序。
我不知道从这里该去哪里。
您不应在 Windows cmd 中运行导出命令,因为 cmd 中没有存储终端路径 如果您在 Windows 中使用 wsl,使用其终端来访问集群并导出 pod 如果您使用 Windows 作为 K8s 集群主端点,您可以使用
windows powershell
并且应该可以正常工作