删除环境

本主题介绍如何删除 Apigee Hybrid 中的环境。请参阅环境和环境组简介

如何删除环境

假设您有两个环境,即 testprod。在您的替换文件中,定义可能如下所示:

...
envs:
  - name: test
    serviceAccountPaths:
      synchronizer: "your_keypath/synchronizer-manager-service-account.json
      udca: "your_keypath/analytic-agent-service-account.json
  - name: prod
    serviceAccountPaths:
      synchronizer: "your_keypath/synchronizer-manager-service-account.json
      udca: "your_keypath/analytic-agent-service-account.json
...

要删除 prod 环境,请执行以下步骤:

  1. 获取 gcloud 身份验证凭据:
    TOKEN=$(gcloud auth print-access-token)
  2. 从任何关联的环境组中删除环境(一次删除一个环境)::

    无数据驻留

    curl -X DELETE -H "Authorization: Bearer $TOKEN" \
      "https://apigee.googleapis.com/v1/organizations/$ORG_NAME/envgroups/$ENV_GROUP/attachments/prod"

    数据驻留

    curl -X DELETE -H "Authorization: Bearer $TOKEN" \
      "https://$CONTROL_PLANE_LOCATION-apigee.googleapis.com/v1/organizations/$ORG_NAME/envgroups/$ENV_GROUP/attachments/prod"
  3. 执行试运行以测试移除运行时组件的操作:
    helm delete $ENV_NAME -n APIGEE_NAMESPACE --dry-run=server
    

    --dry-run 命令会返回与没有 --dry-run 选项的命令相同的结果。例如:

    helm -n apigee delete example-env
    release "example-env" uninstalled
  4. 如果试运行无错误,请移除运行时组件:
    helm delete $ENV_NAME -n APIGEE_NAMESPACE
    
  5. 打开替换文件并从 envsvirtualhosts 中移除 prod 环境定义,从而只保留 test 定义。例如:
    ...
    envs:
      - name: test
        serviceAccountPaths:
          synchronizer: "your_keypath/synchronizer-manager-service-account.json
          udca: "your_keypath/analytic-agent-service-account.json
    ...
  6. 保存文件。