AKS


The presented resiliency recommendations in this guidance include Aks and associated settings.

Summary of Recommendations

Recommendations Details

AKS-1 - 可用性ゾーン間で AKS クラスターをデプロイします

Category: Availability

Impact: High

Guidance

Azure Availability Zones は、データセンター レベルの障害からアプリケーションとデータを保護する高可用性オファリングです。Availability Zones は、独立した電源、冷却装置、ネットワークを備えた Azure リージョン内の一意の物理的な場所です。各アベイラビリティーゾーンは 1 つ以上のデータセンターで構成され、高可用性とフォールトトレラントを実現するように設計されています。

aks クラスター、仮想マシン、ストレージ、データベースなどのリソースを同じリージョン内の複数の Availability Zones にデプロイすることで、データセンター レベルの障害からアプリケーションとデータを保護できます。1 つのアベイラビリティーゾーンがダウンしても、リージョン内の他のアベイラビリティーゾーンは引き続きサービスを提供できます。

Resources

Resource Graph Query

// Azure Resource Graph Query
// Returns AKS clusters that do not have any availability zones enabled
resources
| where type == 'microsoft.containerservice/managedclusters'
| project id, name, location, properties.agentPoolProfiles
| mv-expand properties_agentPoolProfiles
| where isempty(array_length(properties_agentPoolProfiles.availabilityZones))
| project recommendationId="aks-1", id, name, tags, param1=strcat("nodePoolName: ", properties_agentPoolProfiles.name), param2=strcat("orchestratorVersion: ", properties_agentPoolProfiles.orchestratorVersion), param3=strcat("currentOrchestratorVersion: ", properties_agentPoolProfiles.currentOrchestratorVersion), param4=strcat("numberOfZones: ", iff(isempty(array_length(properties_agentPoolProfiles.availabilityZones)), 0, array_length(properties_agentPoolProfiles.availabilityZones)))



AKS-2 - システム ポッドとアプリケーション ポッドを分離します

Category: Governance

Impact: High

Guidance

AKS では、システム ノード プール内のノードに kubernetes.azure.com/mode: system というラベルが自動的に割り当てられます。このラベルは、このプール内のノードでシステム ポッドをスケジュールする必要があることを AKS に通知します。ただし、選択した場合は、これらのノードでアプリケーション Pod をスケジュールできます。

誤って構成されたアプリケーション Pod や不正なアプリケーション Pod が誤ってシステム Pod を強制終了するのを防ぐために、重要なシステム Pod をアプリケーション Pod から分離することをお勧めします。これは、専用ノード プールでシステム ポッドをスケジュールするか、ノード セレクターを使用して、システム ポッドが kubernetes.azure.com/mode: system ラベルを持つノードでのみスケジュールされるようにすることで実現できます。

Resources

Resource Graph Query

// Azure Resource Graph Query
// Returns each AKS cluster with nodepools that do not have taints set
resources
| where type == "microsoft.containerservice/managedclusters"
| mv-expand agentPoolProfile = properties.agentPoolProfiles
| extend taint = tostring(parse_json(agentPoolProfile.nodeTaints))
| extend nodePool = tostring(parse_json(agentPoolProfile.name))
| where isempty(taint)
| project recommendationid="aks-2", id, name, tags, param1=strcat("nodepoolName: ", nodePool), param2=strcat("taint: ", iff(isempty(taint), "None", taint))



AKS-3 - ローカル アカウントを無効化します

Category: Access & Security

Impact: High

Guidance

ローカル Kubernetes アカウントは、AKS クラスターにアクセスするための従来の監査不可能な手段であり、使用は推奨されません。AKS クラスターで Microsoft Entra 統合を有効にすると、クラスターへのアクセスを管理する上でいくつかの利点があります。Microsoft Entra を使用すると、ユーザーとグループの管理を一元化し、多要素認証を適用し、ロールベースのアクセス制御 (RBAC) を有効にして、クラスター リソースへのきめ細かなアクセス制御を行うことができます。さらに、Microsoft Entra は、他の Azure サービスやサードパーティの ID プロバイダーと統合できる安全でスケーラブルな認証メカニズムを提供します。

Resources

Resource Graph Query

// Azure Resource Graph Query
// Returns a list of AKS clusters not using AAD enabled
resources
| where type == "microsoft.containerservice/managedclusters"
| extend aadProfile = tostring (parse_json(properties.aadProfile))
| extend disablelocalAdmin = tostring(parse_json(properties.disableLocalAccounts))
| extend RBAC = tostring(parse_json(properties.enableRBAC))
| where RBAC == "false"
| project recommendationId="aks-3", name, id, tags, param1=strcat("aadProfile: ", aadProfile), param2=strcat("disablelocalAdmin: ",disablelocalAdmin), param3=strcat("RBAC: ", RBAC)



AKS-4 - IP の動的割り当て用に Azure CNI ネットワークを構成します

Category: Networking

Impact: Medium

Guidance

Azure CNI ネットワーク ソリューションには、ポッドへの IP の動的割り当て、ノードとポッドのサブネットの個別にスケーリング、VNET 内のポッドとリソース間の直接ネットワーク接続、ポッドとノードに異なるネットワーク ポリシーを許可するなど、クラスター ポッドの IP アドレスとネットワーク接続を管理するためのいくつかの利点があります。また、Azure ネットワーク ポリシーや Calico など、さまざまなネットワーク ポリシーもサポートしています。

Resources

Resource Graph Query

// Azure Resource Graph Query
// Check AKS Clusters using kubenet network profile
resources
| where type == "microsoft.containerservice/managedclusters"
| extend networkProfile = tostring (parse_json(properties.networkProfile.networkPlugin))
| where networkProfile =="kubenet"
| project recommendationId="aks-4", name, id, tags, param1=strcat("networkProfile :",networkProfile)



AKS-5 - 既存のクラスターでクラスター オートスケーラーを有効にします

Category: System Efficiency

Impact: High

Guidance

クラスター オートスケーラーは、ポッド リソース要求とクラスター内の使用可能な容量に基づいて、ノード プール内のノード数を自動的にスケーリングします。これにより、クラスターを需要に応じてスケーリングし、停止を防ぐことができます。

クラスターでアベイラビリティーゾーンが有効になっている場合は、次の構成変更を検証または確立する必要があります。

  • 永続ボリューム - クラスターで Azure Storage によってサポートされる永続ボリュームを使用している場合は、可用性ゾーンごとに 1 つのノードプールがあることを確認します。永続ボリュームは AZ 間では機能せず、ノードプールが永続ボリュームにアクセスできない場合、オートスケーラーは新しいポッドの作成に失敗する可能性があります。
  • ゾーンごとに複数のノードプール - クラスターに AZ ごとに複数のノードプールがある場合は、自動スケーラー プロファイルを使用して ‘–balance-similar-node-groups’ プロパティを有効にします。この機能は、類似したノードプールを検出し、それらの間でノードの数のバランスを取ります。

Resources

Resource Graph Query

// Azure Resource Graph Query
// Find AKS clusters with auto-scaling disabled
Resources
| where type == "microsoft.containerservice/managedclusters"
| extend autoScaling = tostring (parse_json(properties.agentPoolProfiles.[0].enableAutoScaling))
| where autoScaling == "false"
| project recommendationId="aks-5", name, id, tags, param1=strcat("autoScaling :", autoScaling)



AKS-6 - Azure Kubernetes Service をバックアップします

Category: Disaster Recovery

Impact: Low

Guidance

AKS は、バックアップ戦略を必要とするステートフル アプリケーションに使用されることが増えています。Azure Backup では、クラスターにインストールする必要があるバックアップ拡張機能を使用して、AKS クラスター (クラスターに接続されているクラスター リソースと永続ボリューム) をバックアップできるようになりました。バックアップ コンテナーは、このバックアップ拡張機能を介してクラスターと通信し、バックアップと復元の操作を実行します。

Resources

Resource Graph Query

// Azure Resource Graph Query
// Find AKS clusters that do not have backup enabled

resources
| where type =~ 'Microsoft.ContainerService/managedClusters'
| extend lname = tolower(name)
| join kind=leftouter(recoveryservicesresources
    | where type =~ 'microsoft.dataprotection/backupvaults/backupinstances'
    | extend lname = tolower(tostring(split(properties.dataSourceInfo.resourceID, '/')[8]))
    | extend protectionState = properties.currentProtectionState
    | project lname, protectionState) on lname
| where protectionState != 'ProtectionConfigured'
| extend param1 = iif(isnull(protectionState), 'Protection Not Configured', strcat('Protection State: ', protectionState))
| project recommendationID = "aks-6", name, id, tags, param1



AKS-7 - AKS バージョンのアップグレードを計画します

Category: Compliance

Impact: High

Guidance

マイナーバージョンのリリースには、新機能と改善が含まれています。パッチリリースはより頻繁(場合によっては毎週)で、マイナーバージョン内の重大なバグ修正を目的としています。パッチリリースには、セキュリティの脆弱性や重大なバグの修正が含まれています。 サポートされていない Kubernetes バージョンを実行している場合は、クラスターのサポートを要求するときにアップグレードするように求められます。サポートされていない Kubernetes リリースを実行しているクラスターは、AKS サポート ポリシーの対象外です。

Resources

Resource Graph Query

// cannot-be-validated-with-arg



AKS-8 - マルチゾーン AKS の実行時に永続ボリュームにゾーン冗長ストレージを使用します

Category: Availability

Impact: Low

Guidance

ゾーンの停止から保護するために可用性ゾーン間でデータをレプリケーションする必要があるアプリケーションの場合、お客様はマルチゾーン AKS クラスターでゾーン冗長ストレージ (ZRS) を活用する必要があります。ZRS は、プライマリ リージョン内の 3 つの Azure 可用性ゾーン間でデータを同期的にレプリケートします。

  • Azure ディスク: ストレージ クラスでディスク SKU を StandardSSD_ZRS または Premium_ZRS に設定して、ZRS ディスクを使用します。また、AKS v1.29 以降、マルチゾーン AKS クラスターには、ZRS ディスクを使用する既定のストレージ クラスがあります。
  • Azure Container Storage: お客様は、ストレージ プールを作成し、SKU として StandardSSD_ZRS または Premium_ZRSを指定することで、Azure Container Storage で ZRS ディスクを活用できます。また、マルチゾーンストレージプールを作成して、合計ストレージ容量をゾーンに分散させることもできます。
  • Azure Files: ストレージ クラスで SKU を Standard_ZRS または Premium_ZRS に設定して、ZRS ファイルを使用します。
  • Azure BLOB: ストレージ クラスで SKU を Standard_ZRS または Premium_ZRS に設定して、ZRS BLOB を使用します。

Resources

Resource Graph Query

// cannot-be-validated-with-arg



AKS-9 - ツリー内ドライバーを使用した永続ボリュームを Azure CSI ドライバーにアップグレードします

Category: Storage

Impact: High

Guidance

Kubernetes バージョン 1.26 以降では、Kubernetes コミュニティによるツリー内ストレージ ドライバーの非推奨化により、Azure ディスクと Azure File のツリー内ドライバー (プロビジョナーが kubernetes.io/azure-disk と kubernetes.io/azure-file の永続ボリュームの種類) はサポートされなくなりました。Azure Storage は、Azure ディスクおよびファイル CSI ドライバーによって提供されるようになりました。ツリー内ドライバーを使用する既存の展開が中断されることは予想されていませんが、これらはテストされなくなったため、CSI ドライバーを使用するように更新する必要があります。また、新しいストレージ機能 (新しい SKU、機能など) を活用するには、CSI ドライバーを使用する必要があります。

Resources

Resource Graph Query

// cannot-be-validated-with-arg



AKS-10 - Kubernetes リソースがハード リソース制限を超えないようにリソース クォータを実装します

Category: System Efficiency

Impact: Low

Guidance

リソース クォータは、ResourceQuota オブジェクトによって定義され、名前空間ごとのリソース消費量の総量を制限する制約を提供します。これにより、名前空間で作成できるオブジェクトの数を種類別に制限したり、その名前空間のリソースによって消費される可能性のあるコンピューティング リソースの合計量を制限したりできます。

Resources

Resource Graph Query

// cannot-be-validated-with-arg



AKS-11 - AKS クラスターに仮想ノード (ACI) をアタッチします

Category: System Efficiency

Impact: Low

Guidance

AKS クラスター内のアプリケーション ワークロードを迅速にスケーリングするには、仮想ノードを使用できます。仮想ノードを使用すると、ポッドは Kubernetes クラスター オートスケーラーを使用するよりもはるかに高速にプロビジョニングされます。

クラスターでアベイラビリティーゾーンが有効になっている場合は、次の構成変更を検証または確立する必要があります。

  • 永続ボリューム - クラスターで Azure Storage によってサポートされる永続ボリュームを使用している場合は、可用性ゾーンごとに 1 つのノードプールがあることを確認します。永続ボリュームは AZ 間では機能せず、ノードプールが永続ボリュームにアクセスできない場合、オートスケーラーは新しいポッドの作成に失敗する可能性があります。

Resources

Resource Graph Query

// cannot-be-validated-with-arg



AKS-12 - AKS レベルを Standard に更新します

Category: Availability

Impact: High

Guidance

運用 AKS クラスターは、Standard レベルで構成する必要があります。AKS 無料サービスでは、返金制度のある SLA は提供されず、ノードのスケーラビリティは制限されます。その SLA を取得するには、Standard レベルを選択する必要があります。

Resources

Resource Graph Query

// Azure Resource Graph Query
// Returns all AKS clusters not running on the Standard tier
resources
| where type == "microsoft.containerservice/managedclusters"
| where sku.tier != "Standard"
| project recommendationId="aks-12", id, name, tags, param1=strcat("skuName: ", sku.name), param2=strcat("skuTier: ", sku.tier)



AKS-13 - AKS 監視を有効にします

Category: Monitoring

Impact: High

Guidance

Azure Monitor は、イベントを収集し、コンテナー ログをキャプチャし、メトリック API から CPU/メモリ情報を収集し、データの視覚化を可能にして、AKS 環境のほぼリアルタイムの正常性とパフォーマンスを検証します。視覚化ツールには、Azure Monitor Container Insights、Prometheus、Grafana などがあります。

Resources

Resource Graph Query

// Azure Resource Graph Query
// Returns AKS clusters where either Azure Monitor is not enabled and/or Container Insights is not enabled
resources
|  where type == "microsoft.containerservice/managedclusters"
|  extend azureMonitor = tostring(parse_json(properties.azureMonitorProfile.metrics.enabled))
|  extend insights = tostring(parse_json(properties.addonProfiles.omsagent.enabled))
|  where isempty(azureMonitor) or isempty(insights)
|  project recommendationId="aks-13",id, name, tags, param1=strcat("azureMonitorProfileEnabled: ", iff(isempty(azureMonitor), "false", azureMonitor)), param2=strcat("containerInsightsEnabled: ", iff(isempty(insights), "false", insights))



AKS-14 - AKS クラスターでエフェメラル OS ディスクを使用します

Category: System Efficiency

Impact: Medium

Guidance

エフェメラル ディスクは、IO インシデントを減らすことでパフォーマンスと信頼性を向上させるため、ステートレス アプリケーションの OS ディスクとして理想的です。さらに、お客様は OS の追加ストレージ コストを負担することはなく、再イメージ化と起動時間の短縮により、スケーリングやアップグレードなどのクラスター操作を高速化できます。AKS では、お客様が OS の Azure マネージド ディスクを明示的に要求しない場合、ノード プール用に選択された VM SKU でエフェメラル ディスクが使用可能な場合、既定でエフェメラル ディスクが OS ディスクとして使用されます。

Resources

Resource Graph Query

// cannot-be-validated-with-arg



AKS-15 - AKS 用に構成された Azure ポリシーを有効にして修復します

Category: Governance

Impact: Low

Guidance

Azure ポリシーを使用すると、企業は、セキュリティ、認証、プロビジョニング、ネットワークなどに関するガバナンスのベスト プラクティスを AKS クラスターに適用できます。

Resources

Resource Graph Query

// cannot-be-validated-with-arg



AKS-16 - DevOps フレームワークの使用時に GitOps を有効にします

Category: Automation

Impact: Low

Guidance

GitOps は、アプリケーションと宣言型インフラストラクチャ コードを Git に格納し、自動化された継続的デリバリーの信頼できる情報源として使用するクラウドネイティブ アプリケーションの運用モデルです。GitOps では、システム全体の望ましい状態を git リポジトリに記述し、GitOps オペレーターがそれを環境 (多くの場合は Kubernetes クラスター) にデプロイします。潜在的な停止やフェールオーバーの失敗のシナリオを防ぐために、GitOps は、すべての AKS クラスターの構成を意図した構成に維持するのに役立ちます。

Resources

Resource Graph Query

// Azure Resource Graph Query
// Returns AKS clusters where GitOps is not enabled
resources
|  where type == "microsoft.containerservice/managedclusters"
|  extend gitops = tostring (parse_json(properties.addOnProfiles.gitops.enabled))
|  where isempty(gitops)
|  project recommendationId="aks-16", id, name, tags, param1=strcat("gitopsEnabled: ", "false")



AKS-17 - アプリケーション要件に基づいてアフィニティまたは非アフィニティのルールを構成します

Category: Availability

Impact: High

Guidance

Topology Spread Constraintsを設定して、リージョン、ゾーン、ノード、その他のユーザー定義のトポロジードメインなどの障害ドメイン間でPodをクラスター全体に分散する方法を制御します。これにより、高可用性と効率的なリソース使用率を実現できます。

Resources

Resource Graph Query

// cannot-be-validated-with-arg



AKS-18 - ポッドの Liveness、Readiness、Startup プローブを構成します

Category: Availability

Impact: High

Guidance

AKS kubelet コントローラーでは、Liveness Probe を使用してコンテナーとアプリケーションの正常性を検証します。コンテナの健全性に基づいて、kubeletはコンテナを再起動するタイミングを認識します。

Resources

Resource Graph Query

// cannot-be-validated-with-arg



AKS-19 - 可用性を保証するために運用アプリケーションでポッド レプリカ セットを構成します

Category: Availability

Impact: High

Guidance

PodまたはDeploymentマニフェストでReplicaSetを設定して、安定したレプリカPodのセットをいつでも実行し続けるようにします。この機能は、指定された数の同一のPodの可用性を保証します。

Resources

Resource Graph Query

// cannot-be-validated-with-arg



AKS-20 - システム ノードプール数を構成します

Category: Availability

Impact: High

Guidance

システム ノード プールは、重要なシステム ポッドがノードの停止に対して回復性があることを確認するために、最小ノード数を 2 に設定して構成する必要があります。

Resources

Resource Graph Query

// Azure Resource Graph Query
// Returns each AKS cluster with nodepools that have system nodepools with less than 2 nodes
resources
| where type == "microsoft.containerservice/managedclusters"
| mv-expand agentPoolProfile = properties.agentPoolProfiles
| extend taints = tostring(parse_json(agentPoolProfile.nodeTaints))
| extend nodePool = tostring(parse_json(agentPoolProfile.name))
| where taints has "CriticalAddonsOnly=true:NoSchedule" and  agentPoolProfile.minCount < 2
| project recommendationid="aks-20", id, name, param1=strcat("nodePoolName: ", nodePool), param2=strcat("nodePoolMinNodeCount: ", agentPoolProfile.minCount)



AKS-21 - ユーザー ノードプール数を構成します

Category: Availability

Impact: High

Guidance

アプリケーションで高可用性が必要な場合は、ユーザー ノード プールを 2 以上のノード数で構成する必要があります。

Resources

Resource Graph Query

// Azure Resource Graph Query
// Returns each AKS cluster with nodepools that have user nodepools with less than 2 nodes
resources
| where type == "microsoft.containerservice/managedclusters"
| mv-expand agentPoolProfile = properties.agentPoolProfiles
| extend taints = tostring(parse_json(agentPoolProfile.nodeTaints))
| extend nodePool = tostring(parse_json(agentPoolProfile.name))
| where taints !has "CriticalAddonsOnly=true:NoSchedule" and  agentPoolProfile.minCount < 2
| project recommendationid="aks-21", id, name, param1=strcat("nodePoolName: ", nodePool), param2=strcat("nodePoolMinNodeCount: ", agentPoolProfile.minCount)



AKS-22 - ポッド中断バジェット (PDB) を構成します

Category: Availability

Impact: Medium

Guidance

Pod Disruption Budget (PDB) は、メンテナンスやスケーリング イベントなどの自発的な中断時に使用可能なポッドの最小数または割合を構成できる Kubernetes リソースです。アプリケーションの可用性を維持するには、Pod Disruption Budgets (PDB)を定義して、クラスタで使用可能なポッドの最小数を確保します。

Resources

Resource Graph Query

// cannot-be-validated-with-arg



AKS-23 - ノードプールのサブネット サイズは、最大自動スケール設定に対応する必要があります

Category: Availability

Impact: High

Guidance

ノードプール サブネットのサイズは、最大自動スケール設定に対応する必要があります。サブネットのサイズを適切に設定することで、AKS はノードを効率的にスケールアウトして需要の増加に対応し、リソースの制約や潜在的なサービス中断のリスクを軽減できます。

Resources

Resource Graph Query

// Azure Resource Graph Query
// Returns each AKS cluster with nodepools that have user nodepools with a subnetmask that does not match autoscale configured max-nodes
// Subtracting the network address, broadcast address, and default 3 addresses Azure reserves within each subnet

resources
| where type == "microsoft.containerservice/managedclusters"
| extend nodePools = properties['agentPoolProfiles']
| mv-expand nodePools = properties.agentPoolProfiles
| where nodePools.enableAutoScaling == true
| extend nodePoolName=nodePools.name, maxNodes = nodePools.maxCount, subnetId = tostring(nodePools.vnetSubnetID)
| project clusterId = id, clusterName=name, nodePoolName=nodePools.name, toint(maxNodes), subnetId
| join kind = leftouter (
    resources
    | where type == 'microsoft.network/virtualnetworks'
    | extend subnets = properties.subnets
    | mv-expand subnets
    | project id = tostring(subnets.id), addressPrefix = tostring(subnets.properties['addressPrefix'])
    | extend subnetmask = toint(substring(addressPrefix, indexof(addressPrefix, '/')+1, string_size(addressPrefix)))
    | extend possibleMaxNodeCount = toint(exp2(32-subnetmask) - 5)
) on $left.subnetId == $right.id
| project-away id, subnetmask
| where possibleMaxNodeCount <= maxNodes
| extend param1 = strcat(nodePoolName, " autoscaler upper limit: ", maxNodes)
| extend param2 = strcat("ip addresses on subnet: ", possibleMaxNodeCount)
| project recommendationId="aks-23", name=clusterName, id=clusterId, param1, param2



AKS-24 - 名前空間レベルでリソース クォータを適用します

Category: Availability

Impact: High

Guidance

名前空間レベルのリソース クォータを適用することは、リソースの枯渇を防ぎ、クラスターの安定性を維持することで信頼性を確保するために重要です。これにより、個々のアプリケーションやユーザーがリソースを独占し、パフォーマンスの低下やクラスタ内の他のアプリケーションの停止につながるのを防ぐことができます。

Resources

Resource Graph Query

// cannot-be-validated-with-arg