首页 > 解决方案 > 运行没有 minikube 等的 kubernetes 容器

问题描述

我想在 kubernetes 的帮助下运行一个 nginx-server

kubectl run nginx-image --image nginx

但是抛出了错误:

error: Missing or incomplete configuration info.  Please point to an existing, complete config file:

  1. Via the command-line flag --kubeconfig
  2. Via the KUBECONFIG environment variable
  3. In your home directory as ~/.kube/config

然后我跑了

kubectl run nginx-image --kubeconfig ~/.kube/config --image nginx

再次抛出:

error: Missing or incomplete configuration info.  Please point to an existing, complete config file:

  1. Via the command-line flag --kubeconfig
  2. Via the KUBECONFIG environment variable
  3. In your home directory as ~/.kube/config

minikube start 解决了这个问题,但它正在占用资源......

我只想问如何在不启动 minikube(或其他此类解决方案)的情况下运行 kubectl?请告诉我是否不可能

当我跑步时kubectl get pods,我得到了两个豆荚,而我只想要一个,我知道这是可能的,因为我在一些视频教程中看到过。

请帮忙...

标签: nginxkubernetesorchestration

解决方案


Kubectl 是一个命令行工具,它负责与 Minikube 通信。Kubectl 允许您对 Minikube 运行命令。您可以使用 Kubectl 部署应用程序、检查和管理资源以及查看日志。当你执行这个命令

kubectl run nginx-image --image nginx

kubectl 尝试连接到 minikube 并将您的请求(运行 Nginx)发送给它。所以如果你停止 minikube,kubectl 就无法通信。所以 minikube 负责运行 Nginx 而 kubectl 只负责告诉 Minikube 运行 Nginx


推荐阅读