managedClusters
Summary
Details
可用性ゾーン全体に AKS クラスターをデプロイする
Impact: High Category: High Availability PG Verified: Verified
Description:
Azure 可用性ゾーンは、リージョン内に独立した場所を提供することで高可用性を確保し、独自の電源、冷却、ネットワークを備え、アプリケーションとデータをデータセンター レベルの障害から確実に保護します。
Potential Benefits:
Enhanced fault tolerance for AKS
Learn More:
ARG Query:
Click the Azure Resource Graph tab to view the query
// Azure Resource Graph Query
// Returns AKS clusters that do not have any availability zones enabled or only use a single zone
resources
| where type =~ "Microsoft.ContainerService/managedClusters"
| project id, name, tags, location, pools = properties.agentPoolProfiles
| mv-expand pool = pools
| extend
numOfAvailabilityZones = iif(isnull(pool.availabilityZones), 0, array_length(pool.availabilityZones))
| where numOfAvailabilityZones < 2
| project
recommendationId = "4f63619f-5001-439c-bacb-8de891287727",
id,
name,
tags,
param1 = strcat("NodePoolName: ", pool.name),
param2 = strcat("Mode: ", pool.mode),
param3 = strcat("AvailabilityZones: ", iif(numOfAvailabilityZones == 0, "None", strcat("Zone ", strcat_array(pool.availabilityZones, ", ")))),
param4 = strcat("Location: ", location)
システムポッドとアプリケーションポッドを分離する
Impact: High Category: High Availability PG Verified: Preview
Description:
AKS は、システム ノード プール内のノードに kubernetes.azure.com/mode: system ラベルを割り当て、システム ポッドの優先順位をそこにスケジュールする必要があることを示します。 CriticalAddonsOnlyu003dtrue:NoSchedule テイントをシステム ノードに追加して、アプリケーション ポッドのスケジュールを禁止できます。
Potential Benefits:
Enhanced reliability via pod isolation
Learn More:
ARG Query:
Click the Azure Resource Graph tab to view the query
// Azure Resource Graph Query
// Returns each AKS cluster with nodepools that do not have system pods labelled with CriticalAddonsOnly
resources
| where type == "microsoft.containerservice/managedclusters"
| mv-expand agentPoolProfile = properties.agentPoolProfiles
| where agentPoolProfile.mode =~ 'System' // system node pools
| extend taint = tostring(parse_json(agentPoolProfile.nodeTaints))
| extend hasCriticalAddonsTaint = agentPoolProfile.kubeletConfig has 'CriticalAddonsOnly'
| extend hasNodeLabel = agentPoolProfile.customNodeLabels has 'CriticalAddonsOnly'
| extend hasCriticalAddonsOnly = hasCriticalAddonsTaint or hasNodeLabel or isempty(taint)
| extend nodePool = tostring(parse_json(agentPoolProfile.name))
| where hasCriticalAddonsOnly
| project
recommendationId="5ee083cd-6ac3-4a83-8913-9549dd36cf56",
id,
name,
tags,
param1=strcat("nodepoolName: ", nodePool)
ローカルアカウントを無効にする
Impact: High Category: Security PG Verified: Preview
Description:
AKS のローカル Kubernetes アカウントは監査不能でレガシーであるため、推奨されません。 Microsoft Entra の統合により、集中管理、多要素認証、詳細なアクセスのための RBAC、および Azure および外部 ID プロバイダーと互換性のある安全でスケーラブルな認証システムが提供されます。
Potential Benefits:
Enhanced security and access control
Learn More:
ARG Query:
Click the Azure Resource Graph tab to view the 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="ca324d71-54b0-4a3e-b9e4-10e767daa9fc", name, id, tags, param1=strcat("aadProfile: ", aadProfile), param2=strcat("disablelocalAdmin: ",disablelocalAdmin), param3=strcat("RBAC: ", RBAC)
IP を動的に割り当てるために Azure CNI ネットワークを構成する
Impact: Medium Category: Scalability PG Verified: Preview
Description:
Azure CNI は、クラスター IP とネットワーク管理を強化し、動的な IP 割り当て、スケーラブルなサブネット、ポッドと VNET の直接接続を可能にし、Azure ネットワーク ポリシーと Calico を使用してポッドとノードの多様なネットワーク ポリシーをサポートし、ネットワークの効率とセキュリティを最適化します。
Potential Benefits:
Dynamic IP allocation, scalable subnets, direct VNET access
Learn More:
ARG Query:
Click the Azure Resource Graph tab to view the 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="c22db132-399b-4e7c-995d-577a60881be8", name, id, tags, param1=strcat("networkProfile :",networkProfile)
既存のクラスターでクラスター オートスケーラーを有効にする
Impact: High Category: Scalability PG Verified: Verified
Description:
AKS のクラスター オートスケーラーは、ポッド リソースのニーズと利用可能な容量に基づいてノード数を調整し、需要に応じたスケーリングを可能にして、停止を防ぎます。
Potential Benefits:
Optimizes scaling and prevents outages
Learn More:
ARG Query:
Click the Azure Resource Graph tab to view the 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="902c82ff-4910-4b61-942d-0d6ef7f39b67", name, id, tags, param1=strcat("autoScaling :", autoScaling)
Azure Kubernetes サービスをバックアップする
Impact: Low Category: Disaster Recovery PG Verified: Verified
Description:
バックアップが必要なステートフル アプリで人気の AKS は、インストールされたバックアップ拡張機能を通じて Azure Backup を使用してクラスターと接続されたボリュームを保護できるようになり、バックアップ コンテナーを介したバックアップと復元の操作が可能になります。
Potential Benefits:
Ensures data safety for AKS
Learn More:
ARG Query:
Click the Azure Resource Graph tab to view the 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 = "269a9f1a-6675-460a-831e-b05a887a8c4b", name, id, tags, param1
マルチゾーン AKS を実行する場合は永続ボリュームにゾーン冗長ストレージを使用する
Impact: Medium Category: High Availability PG Verified: Verified
Description:
ZRS は 3 つのゾーン間でのデータ レプリケーションを保証し、ゾーンの停止から保護します。ストレージ クラスで SKU を ZRS に設定することで、Azure ディスク、コンテナー ストレージ、ファイル、Blob で利用でき、v1.29 からマルチゾーン AKS クラスターが強化されます。
Potential Benefits:
Increases data durability and availability
Learn More:
ARG Query:
Click the Azure Resource Graph tab to view the query
// cannot-be-validated-with-arg
ツリー内ドライバーを使用して永続ボリュームを Azure CSI ドライバーにアップグレードする
Impact: High Category: Governance PG Verified: Verified
Description:
Kubernetes 1.26 以降、Azure Disk および Azure File のツリー内ドライバーは非推奨になり、CSI ドライバーが優先されます。既存の展開は引き続き動作しますが、テストは行われていません。ユーザーは、新しい機能と SKU を得るには CSI ドライバーに切り替える必要があります。
Potential Benefits:
Ensures future compatibility
Learn More:
ARG Query:
Click the Azure Resource Graph tab to view the query
// cannot-be-validated-with-arg
リソース クォータを実装して、Kubernetes リソースがハード リソース制限を超えないようにする
Impact: Low Category: Scalability PG Verified: Preview
Description:
ResourceQuota オブジェクトは、名前空間ごとにリソースの使用制限を設定し、作成されるオブジェクトの数と種類、および利用可能な合計コンピューティング リソースを制御します。
Potential Benefits:
Limits AKS resource usage per namespace
Learn More:
ARG Query:
Click the Azure Resource Graph tab to view the query
// cannot-be-validated-with-arg
仮想ノード (ACI) を AKS クラスターに接続する
Impact: Low Category: Scalability PG Verified: Preview
Description:
AKS ワークロードを迅速にスケーリングするには、Kubernetes オートスケーラーとは異なり、仮想ノードを利用してポッドを迅速にプロビジョニングします。可用性ゾーンを持つクラスターの場合は、永続ボリュームが AZ 間で機能しないため、AZ ごとに 1 つのノードプールを確保し、アクセスがない場合のオートスケーラー ポッド作成の失敗を防ぎます。
Potential Benefits:
Faster scaling with virtual nodes
Learn More:
ARG Query:
Click the Azure Resource Graph tab to view the query
// cannot-be-validated-with-arg
AKS レベルを Standard に更新します
Impact: High Category: High Availability PG Verified: Verified
Description:
運用 AKS クラスターには、財政的に裏付けられた SLA と強化されたノードのスケーラビリティを実現するための Standard レベルが必要です。これは、無料サービスにはこれらの機能がないためです。
Potential Benefits:
SLA guarantee and better scalability
Learn More:
ARG Query:
Click the Azure Resource Graph tab to view the 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="0611251f-e70f-4243-8ddd-cfe894bec2e7", id, name, tags, param1=strcat("skuName: ", sku.name), param2=strcat("skuTier: ", sku.tier)
AKS 監視を有効にする
Impact: High Category: Monitoring and Alerting PG Verified: Verified
Description:
Azure Monitor は、メトリック API からイベントを収集し、コンテナー ログをキャプチャし、CPU/メモリ データを収集することにより、AKS の正常性とパフォーマンスに関するリアルタイムの洞察を可能にします。 Azure Monitor Container Insights、Prometheus、Grafana などを使用してデータを視覚化できます。
Potential Benefits:
Real-time AKS health/performance insights
Learn More:
ARG Query:
Click the Azure Resource Graph tab to view the 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="dcaf8128-94bd-4d53-9235-3a0371df6b74",id, name, tags, param1=strcat("azureMonitorProfileEnabled: ", iff(isempty(azureMonitor), "false", azureMonitor)), param2=strcat("containerInsightsEnabled: ", iff(isempty(insights), "false", insights))
AKS クラスターでエフェメラル OS ディスクを使用する
Impact: Medium Category: Scalability PG Verified: Verified
Description:
AKS 上のエフェメラル OS ディスクは、ローカル接続により読み取り/書き込みの待機時間を短縮し、マネージド ディスクで見られるレプリケーションの必要性を排除します。これによりパフォーマンスが向上し、再イメージングや起動時間が短縮されるため、スケーリングやアップグレードなどのクラスター操作が高速化されます。
Potential Benefits:
Lower latency, faster re-imaging and booting
Learn More:
ARG Query:
Click the Azure Resource Graph tab to view the query
// Azure Resource Graph Query
// Returns any AKS cluster nodepools that do not have Ephemeral Disks
resources
| where type == "microsoft.containerservice/managedclusters"
| mv-expand agentPoolProfile = properties.agentPoolProfiles
| extend type = tostring(agentPoolProfile.osDiskType)
| where type != 'Ephemeral'
| project recommendationId="a7bfcc18-b0d8-4d37-81f3-8131ed8bead5", name, id, param1=strcat("osDiskType: ", type)
AKS 用に構成された Azure ポリシーを有効にして修復する
Impact: Low Category: Governance PG Verified: Preview
Description:
AKS クラスターの Azure ポリシーは、セキュリティ、認証、プロビジョニング、ネットワーキングなどに関するガバナンスのベスト プラクティスを適用し、堅牢で安全な運用環境を確保するのに役立ちます。
Potential Benefits:
Enhanced AKS governance and security
Learn More:
ARG Query:
Click the Azure Resource Graph tab to view the query
// Azure Resource Graph Query
// Returns a count of non-compliant policy items per AKS cluster
PolicyResources
| where type =~ 'Microsoft.PolicyInsights/PolicyStates'
| extend complianceState = tostring(properties.complianceState)
| where complianceState == 'NonCompliant'
| where properties.resourceType =~ 'Microsoft.ContainerService/managedClusters'
| extend
id = tostring(properties.resourceId)
| summarize count() by id
| join kind=inner (
resources
| where type =~ 'Microsoft.ContainerService/managedClusters'
| project id, name
) on id
| project recommendationId="26ebaf1f-c70d-4ebd-8641-4b60a0ce0094", id, name, param1=strcat("numNonCompliantAlerts: ", count_)
DevOps フレームワークを使用する場合は GitOps を有効にする
Impact: Low Category: Other Best Practices PG Verified: Preview
Description:
クラウド ネイティブ アプリのオペレーティング モデルである GitOps は、Git を使用して、継続的デリバリーのための信頼できる情報源としてアプリケーションとインフラストラクチャのコードを保存します。
Potential Benefits:
Ensures AKS config consistency
Learn More:
ARG Query:
Click the Azure Resource Graph tab to view the 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="5f3cbd68-692a-4121-988c-9770914859a9", id, name, tags, param1=strcat("gitopsEnabled: ", "false")
ポッド トポロジの分散制約を使用して、ポッドが異なるノードまたはゾーンに分散されるようにします。
Impact: High Category: High Availability PG Verified: Verified
Description:
ポッド トポロジの分散制約を使用してノードまたはゾーン トポロジに基づいてポッドの分散を制御し、ポッドがクラスター全体に確実に分散されるようにすることで、可用性と信頼性を強化します。
Potential Benefits:
Ensures high availability and efficient use
Learn More:
ARG Query:
Click the Azure Resource Graph tab to view the query
// cannot-be-validated-with-arg
ポッドの Liveness、Readiness、および Startup Probe を構成します
Impact: High Category: High Availability PG Verified: Verified
Description:
AKS kubelet コントローラーは liveness プローブを使用してコンテナーとアプリケーションの正常性を検証し、システムがその正常性状態に基づいてコンテナーを再起動するタイミングを認識できるようにします。
Potential Benefits:
Enhances container health monitoring
Learn More:
ARG Query:
Click the Azure Resource Graph tab to view the query
// cannot-be-validated-with-arg
実稼働アプリケーションで複数のレプリカを含むデプロイメントを使用して、可用性を保証します
Impact: High Category: High Availability PG Verified: Verified
Description:
ポッドまたはデプロイメント マニフェストで複数のレプリカを構成すると、レプリカ ポッドの数が安定し、指定された数の同一のポッドが常に利用可能になり、その可用性が保証されます。
Potential Benefits:
Ensures stable pod availability
Learn More:
ARG Query:
Click the Azure Resource Graph tab to view the query
// cannot-be-validated-with-arg
システムのノードプール数を構成する
Impact: High Category: High Availability PG Verified: Verified
Description:
重要なシステム ポッドがノード停止に対して確実に回復できるように、システム ノード プールは最小ノード数 2 で構成する必要があります。
Potential Benefits:
Ensures pod resilience
Learn More:
ARG Query:
Click the Azure Resource Graph tab to view the 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="7f7ae535-a5ba-4665-b7e0-c451dbdda01f", id, name, param1=strcat("nodePoolName: ", nodePool), param2=strcat("nodePoolMinNodeCount: ", agentPoolProfile.minCount)
ユーザーのノードプール数を構成する
Impact: High Category: High Availability PG Verified: Verified
Description:
少なくとも 2 つのノードでユーザー ノード プールを構成することは、高可用性を必要とするアプリケーションにとって不可欠であり、中断することなく動作し、アクセスできる状態を維持します。
Potential Benefits:
Ensures high app availability
Learn More:
ARG Query:
Click the Azure Resource Graph tab to view the 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="005ccbbd-aeab-46ef-80bd-9bd4479412ec", id, name, param1=strcat("nodePoolName: ", nodePool), param2=strcat("nodePoolMinNodeCount: ", agentPoolProfile.minCount)
ポッド中断バジェット (PDB) を構成する
Impact: Medium Category: High Availability PG Verified: Verified
Description:
ポッド中断バジェットは、メンテナンスやスケーリングなどの中断中に利用可能な状態を維持する必要があるポッドの最小数または割合を構成する Kubernetes リソースであり、クラスター内で常に最小数のポッドが利用可能であることが保証されます。
Potential Benefits:
Ensures cluster resiliency during disruptions
Learn More:
ARG Query:
Click the Azure Resource Graph tab to view the query
// cannot-be-validated-with-arg
ノードプールのサブネット サイズは、最大の自動スケール設定に対応する必要があります
Impact: High Category: High Availability PG Verified: Preview
Description:
最大の自動スケール設定に合わせてサイズ設定されたノードプールのサブネットにより、AKS はノードを効率的にスケールアウトして、リソースの制約や潜在的なサービス中断を軽減しながら需要の増加に対応できます。
Potential Benefits:
Efficient scaling, reduced disruptions
Learn More:
ARG Query:
Click the Azure Resource Graph tab to view the 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="e620fa98-7a40-41a0-bfc9-b4407297fb58", name=clusterName, id=clusterId, param1, param2
ノード プールの自動スケール設定は、サブスクリプション コア クォータを超えてはなりません
Impact: High Category: High Availability PG Verified: Preview
Description:
AKS がノードを効率的にスケールアウトして、リソースの制約や潜在的なサービス中断を軽減しながら需要の増加に対応できるようにするために、ノード プールの設定はサブスクリプション コア クォータを超えないようにする必要があります。
Potential Benefits:
Reduced disruptions
Learn More:
ARG Query:
Click the Azure Resource Graph tab to view the query
// cannot-be-validated-with-arg
Linux ノードプールには Azure Linux を使用する
Impact: High Category: High Availability PG Verified: Preview
Description:
AKS 上の Azure Linux は、検証済みのソースで構築されたコンポーネントを使用するネイティブ イメージで復元性を高めます。軽量なので、攻撃対象領域とメンテナンスが軽減されます。 Azure 向けに最適化された Microsoft 強化カーネルにより、コンテナー ワークロードの安定性とセキュリティが強化されます。
Potential Benefits:
Reduced disruptions
Learn More:
ARG Query:
Click the Azure Resource Graph tab to view the query
// Azure Resource Graph Query
// Returns each AKS cluster with nodepools that have Linux nodepools not using Azure Linux
resources
| where type == "microsoft.containerservice/managedclusters"
| mv-expand agentPoolProfile = properties.agentPoolProfiles
| where agentPoolProfile.osType == 'Linux' and agentPoolProfile.osSKU != 'AzureLinux'
| project recommendationid="f46b0d1d-56ef-4795-b98a-f6ee00cb341a", name, id, param1=strcat("nodePoolName: ", agentPoolProfile.name)
アプリケーションの少なくとも 2 つのレプリカをデプロイします
Impact: High Category: High Availability PG Verified: Preview
Description:
アプリケーションの少なくとも 2 つのレプリカをデプロイすると、アプリケーションの可用性が高く、ノード障害に耐えることができます。
Potential Benefits:
Ensures high app availability
Learn More:
ARG Query:
Click the Azure Resource Graph tab to view the query
// cannot-be-validated-with-arg