启用 GKE Enterprise


本页面介绍了如何启用 Google Kubernetes Engine (GKE) Enterprise 版本并访问企业层级功能。GKE Enterprise 是 GKE 的企业层级。如需详细了解 GKE Enterprise,请参阅 GKE 版本GKE Enterprise 技术概览

如需了解将产生的费用,请参阅 GKE 价格

如何启用 GKE Enterprise?

如需在给定集群中使用 GKE Enterprise 功能,请执行以下操作:

  • 必须在集群的项目中启用 GKE Enterprise。
  • 集群本身必须在企业层级中注册。

对于 Google Cloud上的 GKE 集群,您可以选择是否要按集群添加额外的功能层级并为其付费。集群在 GKE Enterprise 层级中注册后,您有权在该集群中使用所有可用的企业层级功能。

然后,您可以选择让集群加入舰队,以使用全套 GKE Enterprise 功能。或者,如果您尚未准备好创建舰队,则可以将一部分独立的企业层级功能用于集群。这些功能包括高级安全性和合规性分析洞见、Binary Authorization 以及更丰富的网络功能。

Google Cloud 外部的 GKE 集群默认都是企业层级集群和舰队成员,无法更改层级。其舰队宿主项目必须已启用 GKE Enterprise。如需详细了解如何设置这些选项,请参阅其文档

如需详细了解 GKE Enterprise 功能(包括在没有舰队成员资格的情况下 Google Cloud 上可用的功能),请参阅 GKE Enterprise 部署选项

准备工作

本页面中的说明假定您已在所选 Google Cloud 项目中启用 GKE。如果没有,请执行以下操作:

  1. Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  3. Verify that billing is enabled for your Google Cloud project.

  4. Enable the Google Kubernetes Engine API.

    Enable the API

  5. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  6. Verify that billing is enabled for your Google Cloud project.

  7. Enable the Google Kubernetes Engine API.

    Enable the API

  8. 通过命令行启用 GKE Enterprise

    如需通过命令行在项目中启用 GKE Enterprise,请按如下所示在项目中启用 Anthos API(如果您尚未为 Google Cloud CLI 设置默认项目,请指定您的项目 ID)。这也会自动启用 Fleet (GKE Hub) API。

    gcloud services enable --project=PROJECT_ID \
       anthos.googleapis.com
    

    您还可以使用 Terraform 以声明方式为项目启用此 API:

    resource "google_project_service" "default" {
      for_each = toset([
        "anthos.googleapis.com",
        "gkehub.googleapis.com"
      ])
    
      service            = each.value
      disable_on_destroy = false
    }

    如需详细了解如何使用 Terraform,请参阅针对 GKE 的 Terraform 支持

    您可能需要为项目启用其他 API 才能使用 Cloud Service Mesh 等企业层级功能。如需了解详情,请参阅相关的功能指南。

    在 GKE Enterprise 中注册 Google Cloud 上的集群

    除了少数例外情况, Google Cloud 上的 GKE 集群必须在创建集群时或通过更新现有集群明确在企业层级中注册,才能使用 GKE Enterprise 功能。

    虽然这是可选操作,但我们建议您也将集群注册到项目的舰队。将集群添加到舰队后,您可以使用全套 GKE Enterprise 功能。如果您选择不注册集群,仍然可以使用 GKE Enterprise,但功能会更有限。

    注册新集群

    如果您想在新集群中使用舰队支持的功能,我们建议您在创建集群时将集群注册到舰队。在集群创建期间注册到舰队的企业层级集群在创建时会使用您为多个企业层级功能所选择的舰队级默认设置,并且会启用推荐的日志和指标。如需了解详情,请参阅注册新集群设置舰队级功能

    如需在创建集群期间在 GKE Enterprise 中注册集群,请执行以下操作:

    控制台

    1. 按照说明在 Google Cloud 控制台中创建 Autopilot 集群、Standard 区域级集群或 Standard 可用区级集群,然后在集群基本信息下选择 Enterprise 层级。如果您选择 Enterprise 层级,并且您的项目中未启用 GKE Enterprise API,系统会提示您启用该 API。

    2. (可选但建议执行)在舰队管理下,将集群注册到项目的舰队

    3. 指定您需要用于集群的任何其他配置,然后点击创建

    gcloud

    按照说明,通过命令行创建 Autopilot 集群、Standard 区域级集群或 Standard 可用区级集群,并指定以下标志:

    • --tier enterprise:在企业层级中注册集群
    • (可选但建议执行)--enable-fleet:将您的集群添加到其项目的舰队

    以下代码段展示了如何在创建 Autopilot 集群时使用这些标志:

    gcloud container clusters create-auto CLUSTER NAME \
        --tier enterprise \
        --enable-fleet
    

    升级现有集群的层级

    如需更新现有集群以使用 GKE Enterprise,请执行以下操作:

    控制台

    1. 进入 GKE 集群页面。此页面会显示您的所有集群。

    进入 GKE 集群页面

    1. 在列表中,点击要更新的集群旁边的 操作
    2. 在“操作”菜单中,选择更改层级
    3. 在随即显示的对话框中,选择 Enterprise 层级,然后点击保存更改以确认操作。

    gcloud

    运行以下命令以升级集群:

    gcloud container clusters update CLUSTER NAME --tier enterprise
    

    CLUSTER NAME 替换为您的集群名称。

    默认行为的例外情况

    在少数情况下, Google Cloud 上的集群会在加入舰队时自动升级到 GKE Enterprise。如果您打算将集群注册到舰队,请仔细阅读本部分。

    如果 Google Cloud 上的标准层级集群满足以下所有条件,则在加入舰队时会自动升级到 GKE Enterprise:

    • 舰队宿主项目(以及用于跨项目注册的集群项目)已启用 GKE Enterprise。
    • 集群之前从未注册到舰队。
    • 集群从未明确指定层级,无论是在创建集群时还是在之后通过集群更新。其中包括:
      • 在引入集群层级之前使用 Google Cloud 控制台创建的集群。
      • 使用 Google Cloud CLI 创建但未使用 --tier 标志的集群。
      • 使用 Terraform 创建但未填充 desired_tier 字段的集群。

    Google Cloud 上已使用 GKE Enterprise 的所有集群都会自动成为企业层级集群。

    停用 GKE Enterprise

    如需为项目或集群停用 GKE Enterprise,请按照停用 GKE Enterprise 中的说明操作。