创建 VPN 网关和对等网关

本页面介绍如何创建 VPN 网关或对等网关资源。

VPN 网关可在多个站点之间提供安全连接,例如在本地数据中心与云环境之间提供安全连接。需要为 Google Distributed Cloud (GDC) 气隙 VPN 配置以下两个网关组件:

  • GDC 中的 VPN 网关。
  • 您的对等 VPN 网关。这是 VPN 网关所连接的对等网络中的物理 VPN 网关设备或软件应用。对等网关可以是本地 VPN 网关,也可以是由其他云服务提供商托管的网关。

准备工作

如需在 GDC 控制台中管理或查看 VPN 资源,您必须拥有必要的身份和访问权限角色:

  • VPN 管理员:拥有对所有 VPN 相关资源的读写权限。请让您的组织 IAM 管理员向您授予 VPN 管理员 (vpn-admin) 角色。
  • VPN Viewer:拥有对所有 VPN 相关资源的读取权限。请让您的组织 IAM 管理员向您授予 VPN Viewer (vpn-viewer) 角色。
  • 如需了解详情,请参阅角色定义

创建 VPN 网关

如需创建 VPN 网关,请按以下步骤操作:

  1. 在网关上指定一个接口名称来表示 IP 地址。创建网关后,系统会自动分配一个外部 IPv4 地址。在平台命名空间中创建 VPN 网关对象:

    kubectl --kubeconfig MANAGEMENT_API_SERVER create -n platform -f - <<EOF
    apiVersion: networking.gdc.goog/v1
    kind: VPNGateway
    metadata:
      name: VPN_GW_NAME
    spec:
      interfaces:
      - name: VPN_INTERFACE_NAME
    EOF
    

    替换以下内容:

    • MANAGEMENT_API_SERVER:区域 API 服务器的 kubeconfig 路径。如果您尚未为目标地区中的 API 服务器生成 kubeconfig 文件,请参阅登录了解详情。
    • VPN_GW_NAME:VPN 网关对象的名称。例如 vpngateway
    • VPN_INTERFACE_NAME:VPN 接口的名称。例如 interface0
  2. 通过检查 Status 字段,验证 VPN_GW_NAME 对象是否已正确协调。获取 VPN 网关对象的详细信息:

    kubectl --kubeconfig MANAGEMENT_API_SERVER describe -n platform vpngateway VPN_GW_NAME
    

    检查输出,它必须类似于以下示例:

    
    status:
      conditions:
      - lastTransitionTime: "2024-05-10T00:12:58Z"
        message: All interfaces are assigned an IP.
        observedGeneration: 1
        reason: Ready
        status: "True"
        type: IPsAssigned
      - lastTransitionTime: "2024-05-10T00:12:36Z"
        message: Condition "TunnelsAttached" is not ready.
        observedGeneration: 1
        reason: NotReady
        status: "False"
        type: Ready
      - lastTransitionTime: "2024-05-10T00:12:36Z"
        message: 'At least one interface is not attached to any VPNTunnel: ["interface0"]'
        observedGeneration: 1
        reason: NoTunnelAttached
        status: "False"
        type: TunnelsAttached
      interfaces:
      - ip: 10.252.218.240
        name: interface0
    

VPNGateway 对象必须附加到 VPNTunnel。我们会在创建 VPN 隧道中处理此步骤。

创建对等 VPN 网关

通过在 Management API 服务器中创建 PeerGateway 对象来创建对等 VPN 网关。PeerGateway 对象表示远程 VPN 端点。PeerGateway 对象上的接口由 VPN 隧道用于建立与远程站点的加密隧道。如需创建对等 VPN 网关,请按以下步骤操作:

  1. 指定接口名称和对等 VPN 网关的静态外部 IPv4 地址。必须在平台命名空间中创建 PeerGateway 对象:

    kubectl --kubeconfig MANAGEMENT_API_SERVER create -n platform -f - <<EOF
    apiVersion: networking.gdc.goog/v1
    kind: PeerGateway
    metadata:
      name: PEER_GW_NAME
    spec:
      interfaces:
      - name: PEER_INTERFACE_NAME
        ip: PEER_INTERFACE_IP
    EOF
    

    替换以下内容:

    • PEER_GW_NAME:对等 VPN 网关的名称。例如 peergateway
    • PEER_INTERFACE_NAME:对等接口的名称。例如 interface0
    • PEER_INTERFACE_IP:对等 VPN 网关的静态外部 IPv4 地址。
  2. 通过检查 Status 字段,验证 PEER_GW_NAME 对象是否已正确协调。

    获取对等 VPN 网关对象的详细信息:

    kubectl --kubeconfig MANAGEMENT_API_SERVER describe -n platform peergateway PEER_GW_NAME
    

    检查输出,它必须类似于以下示例:

    Status:
      Conditions:
        Last Transition Time:  2024-05-10T00:15:25Z
        Message:               Condition "TunnelsAttached" is not ready.
        Observed Generation:   1
        Reason:                NotReady
        Status:                False
        Type:                  Ready
        Last Transition Time:  2024-05-10T00:20:45Z
        Message:               Ready
        Observed Generation:   1
        Reason:                Ready
        Status:                True
        Type:                  ValidGatewayIPs
        Last Transition Time:  2024-05-10T00:15:25Z
        Message:               At least one interface is not attached to any VPNTunnel: ["interface0"]
        Observed Generation:   1
        Reason:                NoTunnelAttached
        Status:                False
        Type:                  TunnelsAttached
    

    PeerGateway 对象必须由 VPNTunnel 引用。我们会在创建 VPN 隧道中处理此步骤。

后续步骤