设置您的环境

如需在 Google Kubernetes Engine 上进行安装,您可以使用 Cloud Shell、Google Cloud 资源的浏览器内置命令行界面或您自己运行 Linux 或 macOS 的计算机,按照安装指南操作。

选项 A:使用 Cloud Shell

Cloud Shell 预配一个运行基于 Debian 的 Linux 操作系统的 g1-small Compute Engine 虚拟机 (VM)。使用 Cloud Shell 的优势如下:

  • Cloud Shell 包含您需要的 gcloudkubectlhelm 命令行工具。

  • 您的 Cloud Shell $HOME 目录具有 5GB 永久性存储空间。

  • 您可以选择文本编辑器

    • 代码编辑器,可通过点击 Cloud Shell 窗口顶部的 来访问。

    • Emac、Vim 或 Nano,可从 Cloud Shell 中的命令行访问。

如需使用 Cloud Shell,请执行以下操作:

  1. 前往 Google Cloud 控制台
  2. 选择您的 Google Cloud 项目。
  3. 点击 Google Cloud 控制台窗口顶部的激活 Cloud Shell 按钮。

    Google Cloud Platform 控制台

    一个 Cloud Shell 会话随即会在 Google Cloud 控制台底部的新框内打开,并显示命令行提示符。

    Cloud Shell 会话

  4. 更新组件:

    gcloud components update
    

    该命令会以如下所示的输出作为响应:

    ERROR: (gcloud.components.update)
    You cannot perform this action because the gcloud CLI component manager
    is disabled for this installation. You can run the following command
    to achieve the same result for this installation:
    
    sudo apt-get update && sudo apt-get --only-upgrade install ...
  5. 复制并粘贴长命令以更新组件。

  6. 安装 kubectl

    sudo apt-get install kubectl
    
  7. 安装 kpt

    sudo apt-get install google-cloud-sdk-kpt
    

选项 B:在本地使用命令行工具

在本地机器上,安装并初始化 gcloud CLI

  1. 使用 Google Cloud CLI 进行身份验证:

    gcloud auth login
    
  2. 更新组件:

    gcloud components update
    
  3. 安装 kubectl

    gcloud components install kubectl
    
  4. 安装 kpt

    gcloud components install kpt