Timescale Cloud:性能、规模、企业级

自托管产品

MST

您可以使用 Azure 上的 VPC 为您的 TimescaleDB 托管服务项目配置 VPC 对等连接。

  • 已安装 Aiven 客户端
  • 已登录到您的 TimescaleDB 托管服务控制台。
  • 在 MST 中为您的项目设置 VPC 对等连接。
  1. 使用 Azure CLI,使用 Azure 管理账户登录

    az account clear
    az login

    这应该会在您的浏览器中打开一个窗口,提示您选择一个 Azure 账户进行登录。您需要至少具有“应用程序管理员”角色权限的账户才能创建 VPC 对等连接。如果您管理多个 Azure 订阅,请使用以下命令配置 Azure CLI 默认使用正确的订阅:

    az account set --subscription <subscription name or id>
  2. 使用 Azure CLI 在您的 AD 租户中创建应用程序对象

    az ad app create --display-name "<NAME>" --sign-in-audience AzureADMultipleOrgs --key-type Password

    这会在您的 AD 中创建一个实体,可用于登录多个 AD 租户 (--sign-in-audience AzureADMultipleOrgs),但只有主租户(创建该应用程序的租户)拥有认证该应用程序的凭据。保存输出中的 appId 字段 - 这被称为 $user_app_id

  3. 为您的应用程序对象创建服务主体。确保服务主体被创建到包含您希望对等连接的 VNet 的 Azure 订阅中

    az ad sp create --id $user_app_id

    这会在您的订阅中创建一个服务主体,该服务主体可能具有对等连接您的 VNet 的权限。保存输出中的 objectId 字段 - 这被称为 $user_sp_id

  4. 为您的应用程序对象设置密码

    az ad app credential reset --id $user_app_id

    保存输出中的 password 字段 - 这被称为 $user_app_secret

  5. 查找您的虚拟网络的 ID 属性

    az network vnet list

    请记下这些

    • id 字段,它被称为 $user_vnet_id

    • Azure 订阅 ID,它是 resource ID/subscriptions/ 之后的部分。这被称为 $user_subscription_id

    • 资源组名称或输出中的 resourceGroup 字段。这被称为 $user_resource_group

    • Vnet 名称或输出中的 name 字段,作为 $user_vnet_name$user_vnet_id 应具有以下格式:

      /subscriptions/$user_subscription_id/resourceGroups/$user_resource_group/providers/Microsoft.Network/virtualNetworks/$user_vnet_name.

  6. 授予您的服务主体对等连接权限。您创建的服务主体需要被分配一个角色,该角色对您的 VNet 范围具有 Microsoft.Network/virtualNetworks/virtualNetworkPeerings/write 操作的权限。为了限制授予应用程序对象和服务主体的权限,您可以创建一个只包含该权限的自定义角色。内置的 Network Contributor 角色包含该权限,可以使用 az role definition list --name "Network Contributor" 找到。输出中的 id 字段用作 $network_contributor_role_id 来为服务主体分配该角色

    az role assignment create --role $network_contributor_role_id --assignee-object-id $user_sp_id --scope $user_vnet_id

    这允许应用程序对象在 --scope 中管理网络。由于您控制该应用程序对象,它也可以被授予整个资源组或整个订阅的权限,以便以后无需为每个 VNet 单独分配角色即可创建其他对等连接。

  7. 为 TimescaleDB 托管服务应用程序对象创建服务主体

    TimescaleDB 托管服务的 AD 租户包含一个类似于您创建的应用程序对象,Timescale 平台使用它在 Timescale 订阅中的项目 VPC VNet 与您的 Azure 订阅中的 VNet 之间创建对等连接。为此,Timescale 应用程序对象需要在您的订阅中拥有一个服务主体

    az ad sp create --id <ID_OF_THE_TIMESCALE_APPLICATION_OBJECT>

    保存输出中的 objectId 字段 - 它被称为 $aiven_sp_id

    如果此操作失败并出现错误“When using this permission, the backing application of the service principal being created must in the local tenant”(使用此权限时,正在创建的服务主体的支持应用程序必须位于本地租户中),则您的账户没有正确的权限。请使用至少分配了“应用程序管理员”角色的账户。

  8. 为 TimescaleDB 托管服务应用程序对象创建自定义角色

    Timescale 应用程序现在拥有一个可以被授予权限的服务主体。为了只允许对等连接您订阅中的特定网络,您可以创建自定义角色定义,其中只包含允许执行此操作的单个权限

    az role definition create --role-definition '{"Name": "<name of your choosing>",
    "Description": "Allows creating a peering to vnets in scope (but not from)",
    "Actions": ["Microsoft.Network/virtualNetworks/peer/action"],
    "AssignableScopes": ["/subscriptions/'$user_subscription_id'"]}'

    创建自定义角色时必须在 AssignableScopes 中包含您的订阅 ID。这本身并不会授予您的订阅权限 - 它只是限制角色分配可以包含的范围。保存输出中的 id 字段 - 这被称为 $aiven_role_id

  9. 将自定义角色分配给 Timescale 服务主体以与您的 VNet 进行对等连接,将您在上一步中创建的角色分配给 Timescale 服务主体,其范围为您的 VNet

    az role assignment create --role $aiven_role_id --assignee-object-id $aiven_sp_id --scope $user_vnet_id
  10. 获取您的 Azure Active Directory (AD) 租户 ID

    az account list

    记下输出中的 tenantId 字段。它被称为 $user_tenant_id

  11. 使用 Aiven CLI 从 Timescale 项目 VPC 创建对等连接

    avn vpc peering-connection create --project-vpc-id $aiven_project_vpc_id --peer-cloud-account $user_subscription_id --peer-resource-group $user_resource_group --peer-vpc $user_vnet_name --peer-azure-app-id $user_app_id --peer-azure-tenant-id $user_tenant_id

    $aiven_project_vpc_id 是 Timescale 项目 VPC 的 ID,可以使用 avn vpc list 命令找到。

    Timescale 平台会从 Timescale 项目 VPC 中的 VNet 创建一个到您订阅中 VNet 的对等连接。此外,它还会在您的租户中为应用程序对象创建一个服务主体 --peer-azure-app-id $user_app_id,授予其权限以对等连接到 Timescale 订阅 VNet。您的 AD 租户 ID 也是必需的,以便 Timescale 应用程序对象可以与您的租户进行身份验证,从而访问您创建的服务主体 --peer-azure-tenant-id $user_tenant_id

    确保以 $user_ 开头的参数为小写。Azure 资源名称不区分大小写,但 Aiven API 目前只接受小写名称。如果未显示错误,则对等连接正在由 Timescale 平台设置。

  12. 运行以下命令,直到状态不再是 APPROVED,而是 PENDING_PEER

    avn vpc peering-connection get -v --project-vpc-id $aiven_project_vpc_id --peer-cloud-account $user_subscription_id --peer-resource-group $user_resource_group --peer-vpc $user_vnet_name

    如果指定的 VNet 不存在,或者 Timescale 应用程序对象没有被授予对等连接的权限,可能会显示 INVALID_SPECIFICATIONREJECTED_BY_PEER 等状态。如果发生这种情况,请检查您的配置,然后重新创建对等连接。如果一切按预期进行,状态将在几分钟内变为 PENDING_PEER,并显示从您的 VNet 到 Timescale 订阅中项目 VPC VNet 设置对等连接的详细信息。

    保存输出中的 to-tenant-id 字段。它被称为 aiven_tenant_id。输出中的 to-network-id 字段被称为 $aiven_vnet_id

  13. 登出您用于登录的 Azure 用户

    az account clear
  14. 使用以下方式登录您创建的应用程序对象到您的 AD 租户

    az login --service-principal -u $user_app_id -p $user_app_secret --tenant $user_tenant_id
  15. 将相同的应用程序对象登录到 Timescale AD 租户

    az login --service-principal -u $user_app_id -p $user_app_secret --tenant
    $aiven_tenant_id

    现在您的应用程序对象与两个 AD 租户都有会话

  16. 从您的 VNet 创建一个到 Timescale 订阅中 VNet 的对等连接

    az network vnet peering create --name <peering name of your choosing> --remote-vnet $aiven_vnet_id --vnet-name $user_vnet_name --resource-group $user_resource_group --subscription $user_subscription_id --allow-vnet-access

    如果您未指定 --allow-vnet-access,则不允许任何流量从对等连接的 VNet 流出,并且 Timescale 服务无法通过对等连接访问。对等连接创建后,其状态应为 connected

    如果您收到以下错误,可能是角色分配尚未生效。如果是这种情况,请稍候片刻,然后重复此步骤中的命令,再次尝试登录并创建对等连接。如果错误消息仍然存在,请检查角色分配是否正确。

    The client `<random uuid>` with object id `<another random uuid>` does not have
    authorization to perform action
    `Microsoft.Network/virtualNetworks/virtualNetworkPeerings/write` over scope
    '$user_vnet_id' If access was recently granted, refresh your credentials.
  17. 在 Aiven CLI 中,检查对等连接是否为 ACTIVE

    avn vpc peering-connection get -v --project-vpc-id $aiven_project_vpc_id --peer-cl

    Timescale 平台会定期轮询处于 PENDING_PEER 状态的对等连接,以查看您的订阅是否已创建到 Timescale 项目 VPC 的 VNet 的对等连接。检测到此情况后,状态将从 PENDING_PEER 变为 ACTIVE。此后,项目 VPC 中的服务可以通过对等连接访问。

关键词

在此页面上发现问题?报告问题 或在 GitHub 上编辑此页面