删除环境

本主题介绍如何删除 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
  3. 执行试运行以测试移除运行时组件的操作:
    apigeectl delete -f overrides.yaml --env=prod --dry-run=true
  4. 如果试运行无错误,请移除运行时组件:
    apigeectl delete -f overrides.yaml --env=prod
  5. 从管理平面中删除环境:
    curl -X DELETE -H "Authorization: Bearer $TOKEN" \
      "https://apigee.googleapis.com/v1/organizations/$ORG_NAME/environments/prod
  6. 打开替换文件并从 envsvirtualhosts 中移除 test 环境定义,从而只保留 prod 定义。例如:
    ...
    envs:
      - name: prod
        serviceAccountPaths:
          synchronizer: "your_keypath/synchronizer-manager-service-account.json
          udca: "your_keypath/analytic-agent-service-account.json
    ...
  7. 保存文件。