本文件說明 Azure CLI AOSM 延伸模組如何探索 Helm 圖表中的映像、從容器登錄提取映射,並將其上傳至 AOSM 成品存放區。 Azure CLI AOSM 擴充功能同時支援 Azure Container Registry (ACR) 和任何支援 Docker API 的容器登錄。
影像探索
由 az aosm nfd generate-config --definition-type cnf產生的 Azure CLI AOSM 擴充功能網路函式定義版本 (NFDV) 輸入檔包含一個參數,指定容器映像上線期間 AOSM CLI 查詢的來源登錄(以及選擇性命名空間)。
// List of registries from which to pull the image(s).
// For example ["sourceacr.azurecr.io/test", "myacr2.azurecr.io", "ghcr.io/path"].
// For non Azure Container Registries, ensure you have run a docker login command before running build.
"image_sources": [],
"image_sources" 是字串陣列。 每個字串都是容器登錄的參考,而且選擇性地是該登錄中的命名空間。
Az CLI AOSM 擴充功能:
- 剖析 所產生的
helm templateKubernetes 定義檔案,以探索容器映像參考。 - 在 「image_sources」 陣列包含的登錄和命名空間中搜尋容器映像參考。
- 將映像從來源登錄複製到 AOSM 成品存放區。
重要
AOSM CLI 要求來源登錄中的映像符合在 helm 圖表中寫入的命名空間結構。 例如,包含在 helm 圖表中的映像,必須是 core/contoso-a:1.0.0 在結尾為 core/contoso-a:1.0.0的路徑中的來源登錄中。 任何其他前置詞都必須包含在 "image_sources" 命令所產生的az aosm nfd generate-config --definition-type cnf檔案中的 cnf-input.jsonc 參數中。
有效範例
此範例描述虛構的容器化網路函式 (CNF)。 此 CNF 是由三個映像所建置,可提供核心 CNF 函式,以及一個可部署以針對 CNF 執行測試查詢的測試映像。 映射的來源登錄是稱為 myregistry的 ACR。 在此範例中,我們會將這四個映射上線。
NFDV 輸入檔中的 [image_sources] 欄位設定如下:
// List of registries from which to pull the image(s).
// For example ["sourceacr.azurecr.io/test", "myacr2.azurecr.io", "ghcr.io/path"].
// For non Azure Container Registries, ensure you have run a docker login command before running build.
"image_sources": ["myregistry.azurecr.io"],
針對此 CNF 之 helm 圖表的 輸出 helm template ,會在 Kubernetes 部署定義中提供四個影像線。
image: repository/release/contoso-a:1.0.0
image: repository/release/contoso-b:1.0.0
image: repository/release/contoso-c:1.0.0
image: repository/test-release/contoso-test:1.0.0
Azure CLI AOSM 擴充功能會採用上述映像行,並移除 repository (AOSM 會以新的登錄來覆寫存放庫,並備份 AOSM 成品存放區)。 然後,Azure CLI AOSM 擴充功能會在、 myregistry.azurecr.io/release/contoso-b:1.0.0myregistry.azurecr.io/release/contoso-c:1.0.0和 myregistry.azurecr.io/test-release/contoso-test:1.0.0中myregistry.azurecr.io/release/contoso-a:1.0.0搜尋影像。 這些路徑中必須提供映像。
Namespacing
Azure CLI AOSM 擴充功能也支援來源容器登錄中的映射名稱步調。 例如, contoso-test 映像可以在來源登錄中上傳至 test/test-release/contoso-test:1.0.0 。 在這裡情況下,必須在 NFDV 輸入檔中的 參數中"image_sources"設定額外的前置test詞 。
// List of registries from which to pull the image(s).
// For example ["sourceacr.azurecr.io/test", "myacr2.azurecr.io", "ghcr.io/path"].
// For non Azure Container Registries, ensure you have run a docker login command before running build.
"image_sources": ["myregistry.azurecr.io", "myregistry.azurecr.io/test"],
Azure AOSM CLI 延伸模組會在 中 myregistry.azurecr.io搜尋影像,其中會探索 contoso-a、 contoso-b和 contoso-c。 接著,它會在 中 myregistry.azurecr.io/test搜尋 ,並在其中探索 contoso-test。