【问题标题】:kubectl is not installed on GCE by defaultGCE 上默认不安装 kubectl
【发布时间】:2015-05-04 12:04:55
【问题描述】:

按照guide,我正在尝试从 Google Compute Engine 上的另一台机器管理 Google Container Engine 集群。这是我的 GCE 实例的输出:

oleksandr_berezianskyi_gmail_com@docker-managed-jenkins:~$ sudo gcloud components update preview
All components are up to date.
oleksandr_berezianskyi_gmail_com@docker-managed-jenkins:~$ sudo gcloud components update alpha
All components are up to date.
oleksandr_berezianskyi_gmail_com@docker-managed-jenkins:~$ gcloud alpha container kubectl create -f cassandra.yaml
ERROR: (gcloud.alpha.container.kubectl) This command requires the kubernetes client (kubectl), which is installed with the gcloud preview component. Run 'gcloud components update preview', or make sure kubectl is installed somewhere on your
 path.

如您所见,我的 Google Cloud SDK 似乎是最新的,但仍无法在 GCE 上正常运行。我有什么遗漏吗?

【问题讨论】:

    标签: google-compute-engine google-kubernetes-engine


    【解决方案1】:

    现在安装kubectl的正确方法是gcloud components install kubectl

    【讨论】:

    • 这会在哪里安装kubectl 二进制文件?
    • @Jatin 在您安装 sdk 的 bin 文件夹中
    【解决方案2】:

    如果您运行了gcloud components update,它将在您的系统上安装 kubectl 二进制文件,它就不会在您的路径中。它将位于 cloud-sdk 安装目录中。您可以通过运行手动将其添加到路径中

    export PATH=$PATH:/usr/local/share/google/google-cloud-sdk/bin/

    或者您可以从路径中已经存在的目录创建符号链接,例如 /usr/local/bin 通过运行

    sudo ln -s /usr/local/share/google/google-cloud-sdk/bin/kubectl /usr/local/bin/kubectl

    【讨论】:

    • 罗伯特,您能否安排更改gcloud alpha container kubectl create 的输出,因为Run 'gcloud components update preview' 有点误导?
    • 您运行的是什么版本的 gcloud?当前版本 (0.9.61) 现在显示 Run 'gcloud components update', or make sure kubectl is installed somewhere on your path.
    • 我也有同样的信息。问题是它有点误导。对我来说,消息中的or 意味着运行更新就足够了。所以我什至没有尝试将 kubectl 添加到路径中。所以我建议用also替换or
    • 在我的情况下,在 Linux Mint 18 上,我安装了 gcloud,并使用“gcloud components update kubectl”安装了 kubectl,但它在终端上仍然不可用。我创建了一个指向 /usr/bin/ 的符号链接,它起作用了
    • 在MacOS上,如果你使用brew cask install google-cloud-sdk安装google-cloud-sdk,sdk的bin目录将位于/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/bin/
    【解决方案3】:

    您可以从以下 Google Cloud Storage URL 下载 kubectl 二进制文件的当前版本:https://storage.googleapis.com/kubernetes-release/release/v0.18.2/bin/linux/amd64/kubectl

    【讨论】:

      【解决方案4】:

      截至(至少)138.0.0(2016 年 11 月)

      现在是gcloud components install kubectl

      这是在运行时:

      Your current Cloud SDK version is: 138.0.0

      以下是相关说明:

      To install or remove components at your current SDK version [138.0.0], run:
        $ gcloud components install COMPONENT_ID
        $ gcloud components remove COMPONENT_ID
      
      To update your SDK installation to the latest version [141.0.0], run:
        $ gcloud components update
      

      【讨论】:

      • 丹尼尔感谢您的回答。您能否包含有关您引用的 GCE 版本的文档,以便此答案会持续一段时间并在更晚的日期被理解?
      猜你喜欢
      • 2015-10-04
      • 2020-01-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-15
      • 2014-08-09
      • 2014-04-13
      • 2011-06-18
      相关资源
      最近更新 更多