自訂資源

匯入叢集時,您可以將依預設為不匯入的自訂資源匯入。
NCP 不會建立自訂資源。
nsxt_mp_to_policy_converter.py
檔案中有方法 (在方法定義中搜尋單詞「
custom
」) 可加以覆寫,從而在管理程式匯入原則期間實作預期的行為。依預設,NCP 不會對這些資源採取任何動作,因此不會實作任何自訂行為。如果您指定任何自訂資源識別碼,將會建立一個簡單的匯入要求 (在此情況下,會從 display_name 推斷原則識別碼,而不會在第 2 和 3 階段中執行任何更新)。您可以使用
custom_resources
識別碼,在使用者規格檔案中指定這些資源的識別碼 (請參閱以下範例)。語法如下:
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
中指定自訂資源。