Azure Kubernetes Service (AKS) と Arc 対応 Kubernetes プロジェクト用に Dapr 拡張機能を構成する
Dapr 拡張機能を作成したら、次のようにさまざまな構成オプションを使って、自分と自分のプロジェクトにとって最適な動作になるように Dapr 拡張機能を構成できます。
- Dapr 拡張機能を使うノードを制限する
- CRD の自動更新の設定
- Dapr リリース名前空間の構成
この拡張機能を使用すると、Azure CLI の --configuration-settings
パラメーターまたは Bicep テンプレートの configurationSettings
プロパティを使用して Dapr 構成オプションを設定できます。
高可用性 (HA) を有効にして Dapr をプロビジョニングする
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"
Note
構成設定が機密情報であり、保護する必要がある場合 (証明書関連情報など) は、--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
に .
が含まれる場合は、シェルと拡張機能からエスケープする必要があります。 たとえば、次の構成では、 topology.kubernetes.io/zone: "us-east-1c"
を持つノードにのみ 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-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
を 2 から 3 に更新するには、次のコマンドを使用します。
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 拡張機能で送信プロキシを使用する場合は、次の方法で行うことができます。
dapr.io/env
注釈を使用してプロキシ環境変数を設定します。HTTP_PROXY
HTTPS_PROXY
NO_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
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"
Note
CRD はアップグレードの場合にのみ適用され、ダウングレード時にスキップされます。
ネットワーク要件を満たす
AKS と Arc for Kubernetes の Dapr 拡張機能が機能するには、 https://:443
に次の送信 URL が必要です。
- Dapr アーティファクトをプルするための
https://mcr.microsoft.com/daprio
URL。 - 一部の Dapr 依存関係をプルするための
https://linuxgeneva-microsoft.azurecr.io/
URL。 - AKS または Arc for Kubernetes に必要な送信 URL。
次のステップ
AKS クラスターに Dapr が正常にプロビジョニングされたので、サンプル アプリケーションのデプロイを試します。