导入集群时,您可以导入默认情况下不会导入的自定义资源。

自定义资源不是由 NCP 创建的。可以覆盖文件 nsxt_mp_to_policy_converter.py 中的一些方法(在方法定义中搜索“custom”一词),以实施管理器到策略导入期间的预期行为。默认情况下,NCP 不会对这些资源执行任何操作,因此不会实施任何自定义行为。如果指定任何自定义资源 ID,则将创建一个简单的请求以导入该资源(在这种情况下,将从 display_name 中推断策略 ID,且在阶段 2 和 3 中不会执行任何更新)。您可以使用 custom_resources 标识符在用户规范文件中指定这些资源的 ID(请参见下面的示例)。语法如下所示:

k8s-clusters:
  <k8s cluster name>:
    <NSX Resource Shell Class Name>:
      <NSX Resource - 1 Class Name>:
        custom_resources:
          <NSX Resource - 1A ID>:
            metadata:
              - "key": <metadata key recognized by Migration API>
                "value": <metadata value associated with the key recognized by
                          Migration API>
            linked_ids:
              - "key": <linked_ids key recognized by Migration API>
                "value": <linked_ids value associated with the key recognized by
                          Migration API>
            <NSX Resource - 2 Class Name>: # these resources are imported after NSX Resource - 1A is
              custom_resources:
                <NSX Resource - 2A ID>:
                  metadata:
                    - "key": <metadata key recognized by Migration API>
                      "value": <metadata value associated with the key
                                recognized by Migration API>
                  linked_ids:
                    - "key": <linked_ids key recognized by Migration API>
                      "value": <linked_ids value associated with the key
                                recognized by Migration API>      <NSX Resource - 1 Class Name>:
          <NSX Resource - 1B ID>:
            metadata:
              - "key": <metadata key recognized by Migration API>
                "value": <metadata value associated with the key recognized by
                          Migration API>
            linked_ids:
              - "key": <linked_ids key recognized by Migration API>
                "value": <linked_ids value associated with the key recognized by
                          Migration API>

在 user-spec.yaml 中指定自定义资源的示例

k8s-clusters:
   k8scluster:
    # top-tier-router-id is required for each cluster
    top-tier-router-id: t1-router-id
    top-tier-router-type: TIER1
    # Provide custom resources as follow:
    NamespaceResources:
      Tier1Router:
        custom_resources:
          # Custom resources are specified only with MP ID
          6d93a932-87ea-42de-a30c-b39f397322b0:
            metadata:
              # It should be a list
              - key: 'metadata-key'
                value: 'metadata-value'
            linked_ids:
              # It should be a list
              - key: 'linked_id-key'
                value: 'linked_id-value'
      NATRules:
        custom_resources:
          # Custom resources are specified only with MP ID
          536870924:
            metadata:
              # It should be a list
              - key: 'metadata-key'
                value: 'metadata-value'
            linked_ids:
              # It should be a list
              - key: 'linked_id-key'
                value: 'linked_id-value'

请参阅资源规范顺序以了解应如何在 user-spec.yaml 中指定自定义资源。