【问题标题】:run kubernetes containers without minikube or etc在没有 minikube 等的情况下运行 kubernetes 容器
【发布时间】:2020-09-22 12:53:10
【问题描述】:

我想借助

在 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 时,我得到了两个 pod,而我只想要一个,我知道这是可能的,因为我在一些视频教程中看到过。

请帮忙...

【问题讨论】:

    标签: nginx kubernetes orchestration


    【解决方案1】:

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

    kubectl run nginx-image --image nginx
    

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

    【讨论】:

      【解决方案2】:

      我的意思是您需要安装 Kubernetes 才能使用它。这不是魔术。如果你不喜欢 minikube,有很多安装程序,试试 Docker Desktop 或 k3d。

      【讨论】:

      • 好的,我已经安装了 minikube。我可以从终端运行 kubectl 命令。所以我想我可以只使用 kubectl 命令在 k8s 上运行映像,而无需启动 minikube 和 VM。有可能吗?
      • 我不明白你的问题。 Kubernetes 在虚拟机内部运行。如果 VM 未运行,则 Kubernetes 未运行。
      猜你喜欢
      • 1970-01-01
      • 2020-07-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-11
      • 2023-04-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多