設定適用於 Azure Kubernetes Service (AKS) 和已啟用 Arc 的 Kubernetes 專案的 Dapr 延伸模組
一旦 建立 Dapr 延伸模組,您就可以使用各種設定選項來設定最適合您的專案的 Dapr 延伸模組,例如:
- 限制您的節點使用 Dapr 擴充功能
- 設定 CRD 的自動更新
- 設定 Dapr 版本命名空間
擴充功能可讓您使用 --configuration-settings
Azure CLI 中的 參數或 configurationSettings
Bicep 範本中的 屬性來設定 Dapr 組態選項。
布建已啟用高可用性的 Dapr (HA)
將 參數設定 global.ha.enabled
為 true
,以啟用高可用性 (HA) 布建 Dapr。
az k8s-extension create --cluster-type managedClusters \
--cluster-name myAKSCluster \
--resource-group myResourceGroup \
--name dapr \
--extension-type Microsoft.Dapr \
--auto-upgrade-minor-version true \
--configuration-settings "global.ha.enabled=true" \
--configuration-settings "dapr_operator.replicaCount=2"
注意
如果組態設定很敏感,而且必須受到保護(例如憑證相關信息),請傳遞 --configuration-protected-settings
參數,且值將受到保護,以免被讀取。
如果未傳遞任何組態設定,Dapr 設定預設為:
ha:
enabled: true
replicaCount: 3
disruption:
minimumAvailable: ""
maximumUnavailable: "25%"
prometheus:
enabled: true
port: 9090
mtls:
enabled: true
workloadCertTTL: 24h
allowedClockSkew: 15m
如需可用選項的清單,請參閱 Dapr 設定。
將延伸模組限制為特定節點
在某些設定中,您可能只想在特定節點上執行 Dapr。 您可以在延伸模組組態中傳遞 nodeSelector
來限制延伸模組。 如果所需的 nodeSelector
包含 .
,您必須從殼層和延伸模組逸出它們。 例如,下列組態只會將 Dapr 安裝到具有 topology.kubernetes.io/zone: "us-east-1c"
的節點:
az k8s-extension create --cluster-type managedClusters \
--cluster-name myAKSCluster \
--resource-group myResourceGroup \
--name dapr \
--extension-type Microsoft.Dapr \
--auto-upgrade-minor-version true \
--configuration-settings "global.ha.enabled=true" \
--configuration-settings "dapr_operator.replicaCount=2" \
--configuration-settings "global.nodeSelector.kubernetes\.io/zone=us-east-1c"
若要管理 OS 和架構,請使用 global.daprControlPlaneOs
和 global.daprControlPlaneArch
設定的支援版本:
az k8s-extension create --cluster-type managedClusters \
--cluster-name myAKSCluster \
--resource-group myResourceGroup \
--name dapr \
--extension-type Microsoft.Dapr \
--auto-upgrade-minor-version true \
--configuration-settings "global.ha.enabled=true" \
--configuration-settings "dapr_operator.replicaCount=2" \
--configuration-settings "global.daprControlPlaneOs=linux” \
--configuration-settings "global.daprControlPlaneArch=amd64”
在 HA 模式中,在多個可用性區域中安裝 Dapr
根據預設,放置服務會使用類型為 standard_LRS
的儲存類別。 建議您在跨多個可用性區域以 HA 模式安裝 Dapr 時,建立 區域備援記憶體類別 。 例如,若要建立 zrs
類型記憶體類別,請新增 storageaccounttype
參數:
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: custom-zone-redundant-storage
provisioner: disk.csi.azure.com
reclaimPolicy: Delete
allowVolumeExpansion: true
volumeBindingMode: WaitForFirstConsumer
parameters:
storageaccounttype: Premium_ZRS
安裝 Dapr 時,請使用您在 YAML 檔案中使用的記憶體類別:
az k8s-extension create --cluster-type managedClusters
--cluster-name XXX
--resource-group XXX
--name XXX
--extension-type Microsoft.Dapr
--auto-upgrade-minor-version XXX
--version XXX
--configuration-settings "dapr_placement.volumeclaims.storageClassName=custom-zone-redundant-storage"
設定 Dapr 版本命名空間
您可以設定版本命名空間。
根據預設,Dapr 延伸模組會安裝在 dapr-system
命名空間中。 若要將其覆寫,請使用 --release-namespace
。 包括叢集 --scope
以重新定義命名空間。
az k8s-extension create \
--cluster-type managedClusters \
--cluster-name dapr-aks \
--resource-group dapr-rg \
--name my-dapr-ext \
--extension-type microsoft.dapr \
--release-train stable \
--auto-upgrade false \
--version 1.9.2 \
--scope cluster \
--release-namespace dapr-custom
如果您已安裝 Dapr,瞭解如何設定 Dapr 版本命名空間。
顯示目前的組態設定
使用 az k8s-extension show
命令來顯示目前的 Dapr 組態設定:
az k8s-extension show --cluster-type managedClusters \
--cluster-name myAKSCluster \
--resource-group myResourceGroup \
--name dapr
更新組態設定
重要
某些設定選項建立完畢後,就無法修改。 若要調整這些選項,需要刪除和重新建立適用於下列設定的延伸模組:
global.ha.*
dapr_placement.*
HA 預設為啟用。 如要停用,需要刪除和重新建立延伸模組。
若要更新 Dapr 組態設定,請重新建立具有所需狀態的延伸模組即可。 例如,假設我們先前已使用下列設定建立並安裝延伸模組:
az k8s-extension create --cluster-type managedClusters \
--cluster-name myAKSCluster \
--resource-group myResourceGroup \
--name dapr \
--extension-type Microsoft.Dapr \
--auto-upgrade-minor-version true \
--configuration-settings "global.ha.enabled=true" \
--configuration-settings "dapr_operator.replicaCount=2"
若要將 dapr_operator.replicaCount
從兩個更新為三個,請使用下列命令:
az k8s-extension create --cluster-type managedClusters \
--cluster-name myAKSCluster \
--resource-group myResourceGroup \
--name dapr \
--extension-type Microsoft.Dapr \
--auto-upgrade-minor-version true \
--configuration-settings "global.ha.enabled=true" \
--configuration-settings "dapr_operator.replicaCount=3"
為適用於 Azure Arc 的 Dapr 延伸模組內部部署設定輸出
如果您想要搭配適用於 AKS 的 Dapr 延伸模組使用輸出 Proxy,您可以透過下列方式執行此動作:
- 使用
dapr.io/env
註釋 \(英文\) 設定 Proxy 環境變數:HTTP_PROXY
HTTPS_PROXY
NO_PROXY
- 在側車中安裝 Proxy 憑證 \(英文\)。
更新 Dapr 安裝版本
如果您使用的是特定的 Dapr 版本,而且沒有 --auto-upgrade-minor-version
可用,您可以使用下列命令來升級或降級 Dapr:
az k8s-extension update --cluster-type managedClusters \
--cluster-name myAKSCluster \
--resource-group myResourceGroup \
--name dapr \
--version 1.12.0 # Version to upgrade or downgrade to
上述命令儘更新 Dapr 控制平面。若要更新 Dapr 側車,請重新啟動您的應用程式部署:
kubectl rollout restart deploy/<DEPLOYMENT-NAME>
使用以 Azure Linux 為基礎的映像
從 Dapr 1.8.0 版,您可以搭配 Dapr 延伸模組使用 Azure Linux 映像。 若要使用它們,請設定 global.tag
旗標:
az k8s-extension update --cluster-type managedClusters \
--cluster-name myAKSCluster \
--resource-group myResourceGroup \
--name dapr \
--set global.tag=1.10.0-mariner
- 深入了解如何搭配 Dapr 使用以 Mariner 為基礎的映像。
- 深入瞭解如何在 AKS 上部署 Azure Linux。
停用 CRD 的自動更新
從 Dapr 1.9.2 版,擴充功能升級時會自動升級 CRD。 若要停用這項設定,你可以將 hooks.applyCrds
設定為 false
。
az k8s-extension update --cluster-type managedClusters \
--cluster-name myAKSCluster \
--resource-group myResourceGroup \
--name dapr \
--configuration-settings "hooks.applyCrds=false"
注意
只有在升級時才會套用 CRD,並在降級期間跳過。
符合網路需求
適用於 AKS 和適用於 Kubernetes 之 Arc 的 Dapr 延伸模組需要在 https://:443
上開啟下列輸出 URL 才能運作:
https://mcr.microsoft.com/daprio
提取 Dapr 成品的 URL。https://linuxgeneva-microsoft.azurecr.io/
提取部分 Dapr 相依性的 URL。- AKS 或 Arc for Kubernetes 所需的輸出 URL。
後續步驟
成功在 AKS 叢集中佈建 Dapr 之後,請嘗試部署一個 範例應用程式。
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應