ネットワーク構成など、AKS クラスターの作成エラーが発生する可能性がある環境関連の問題を特定することは困難な場合があります。 診断チェッカーは、環境内の潜在的な問題による AKS クラスターの作成エラーを特定するのに役立つ PowerShell ツールです。
注
診断チェッカー ツールは、AKS クラスターが作成されたが失敗状態の場合にのみ使用できます。 Azure Portal に AKS クラスターが表示されない場合は、このツールを使用できません。 Azure Resource Manager リソースが作成される前に AKS クラスターの作成が失敗した場合は、サポート要求をに登録します。
はじめに
開始する前に、以下の前提条件を確認してください。 診断チェッカー ツールを実行するための要件を満たしていない場合は、サポート要求をします:
- AKS クラスターを作成した Azure ローカル クラスターに直接アクセスします。 このアクセスは、リモート デスクトップ (RDP) 経由で行うことも、Azure ローカル物理ノードのいずれかにサインインすることもできます。
- AKS クラスターを作成するためのネットワーク概念とAKS クライアント アーキテクチャを確認します。
- AKS クラスターに接続されている論理ネットワークの名前。
- AKS クラスターの SSH 秘密キー、AKS クラスター コントロール プレーン ノード VM にサインインするために使用。
AKS クラスターのコントロール プレーン ノード VM IP を取得する
Azure ローカル クラスター内の任意の物理ノードから次のコマンドを実行します。 AKS クラスターの Azure Resource Manager ID ではなく、名前を渡していることを確認します。
invoke-command -computername (get-clusternode) -script {get-vmnetworkadapter -vmname *} | Where-Object {$_.Name -like "$cluster_name*control-plane-*"} | select vmname, ipaddresses
予想される出力:
VMName IPAddresses
------ -----------
<cluster-name>-XXXXXX-control-plane-XXXXXX {172.16.0.10, 172.16.0.4, fe80::ec:d3ff:fea0:1}
前の出力に示すようにコントロール プレーン VM が表示されない場合は、サポート要求を登録します。
コントロール プレーン VM が表示され、次が含まれています。
- 0 個の IPv4 アドレス: サポート要求を登録します。
- 1 つの IP アドレス:
vmIPパラメーターの入力として IPv4 アドレスを使用します。 - 2 つの IP アドレス: 診断チェッカーの
vmIPパラメーターの入力として、IPv4 アドレスのいずれかを使用します。
診断チェッカー スクリプトを実行する
run_diagnostic.ps1という名前の次の PowerShell スクリプトを、Azure ローカル クラスターの任意のノードにコピーします。
<#
.SYNOPSIS
Runs diagnostic checker tool in target cluster control plane VM and returns the result.
This script runs the following tests from target cluster control plane VM:
1. cloud-agent-connectivity-test: Checks whether the DNS server can resolve the Moc cloud agent FQDN and that the cloud agent is reachable from the control plane node VM. Cloud agent is created using one of the IP addresses from the [management IP pool](hci/plan/cloud-deployment-network-considerations.md#management-ip-pool), on port 55000. The control plane node VM is given an IP address from the Arc VM logical network.
2. gateway-icmp-ping-test: Checks whether the gateway specified in the logical network attached to the AKS cluster is reachable from the AKS cluster control plane node VM.
3. http-connectivity-required-url-test: Checks whether the required URLs are reachable from the AKS cluster control plane node VM.
.DESCRIPTION
This script transfers a file from the local machine to a remote server using the SCP (Secure Copy Protocol) command.
.PARAMETER lnetName
The name of the LNET used for the cluster.
.PARAMETER sshPath
The path to the private SSH key for the target cluster.
.PARAMETER vmIP
IP of the target cluster control plane VM.
.EXAMPLE
.\run_diagnostic.ps1 -lnetName lnet1 -sshPath C:\Users\test\.ssh\test-ssh.pem -vmIP "172.16.0.10"
This example runs diagnostic checker tool in the VM with IP 172.16.0.10 using ssh key C:\Users\test\.ssh\test-ssh.pem and outputs the result.
#>
param (
[Parameter(Mandatory=$true)]
[string]$lnetName,
[Parameter(Mandatory=$true)]
[string]$sshPath,
[Parameter(Mandatory=$true)]
[string]$vmIP
)
$urlArray = @(
"https://management.azure.com",
"https://eastus.dp.kubernetesconfiguration.azure.com",
"https://login.microsoftonline.com",
"https://eastus.login.microsoft.com",
"https://login.windows.net",
"https://mcr.microsoft.com",
"https://gbl.his.arc.azure.com",
"https://k8connecthelm.download.prss.microsoft.com",
"https://guestnotificationservice.azure.com",
"https://sts.windows.net",
"https://graph.microsoft.com"
)
$urlList=$urlArray -join ","
# check vm is reachable
try {
$pingResult = Test-Connection -ComputerName $vmIP -Count 1 -ErrorAction Stop
if ($pingResult.StatusCode -eq 0) {
Write-Host "Connection to $vmIP succeeded."
} else {
Write-Host "Connection to AKS cluster control plane VM $vmIP failed with status code: $($pingResult.StatusCode). Please make sure AKS cluster control plane VM $vmIP is reachable from the host"
exit
}
} catch {
Write-Host "Connection to AKS cluster control plane VM $vmIP failed. Please make sure AKS cluster control plane VM $vmIP is reachable from the host"
Write-Host "Exception message: $_"
exit
}
# retreiving LNET
$lnet=get-mocvirtualnetwork -group Default_Group -name $lnetName
# getting gateway address from LNET
$gateway=$lnet.properties.subnets[0].properties.routeTable.properties.routes[0].properties.nextHopIpAddress
if (-not $gateway) {
Write-Error "Check Gateway address in the AKS logical network $lnetName"
exit
}
# getting cloudfqdn from archciconfig
$arcHCIConfig=get-archciconfig
$cloudFqdn="http://"+$arcHCIConfig.Item('cloudFQDN')+":55000"
$configContent = @"
checks:
- metadata:
creationTimestamp: null
name: cloud-agent-connectivity-test
parameters:
hostnames: <CLOUD_FQDN>
skipeof: "true"
type: HTTPConnectivity
- metadata:
annotations:
skip-error-on-failure: "true"
creationTimestamp: null
name: gateway-icmp-ping-test
parameters:
ips: <GATEWAY>
packetLossThreshold: "20"
type: ICMPPing
- metadata:
creationTimestamp: null
name: http-connectivity-required-url-test
parameters:
hostnames: <URL_LIST>
type: HTTPConnectivity
exports:
- metadata:
creationTimestamp: null
parameters:
filelocation: /home/clouduser/results.yaml
type: FileSystem
metadata:
creationTimestamp: null
"@
# update config file with the values of cloud fqdn, gateway and dns servers
$configContent = $configContent.replace("<CLOUD_FQDN>", $cloudFqdn)
$configContent = $configContent.replace("<GATEWAY>", $gateway)
$configContent = $configContent.replace("<URL_LIST>", $urlList)
$filePath = "config.yaml"
# Write to config.yaml
Set-Content -Path $filePath -Value $configContent
$dest = 'clouduser@' + $vmIP + ":config.yaml"
# Copy the config file to target cluster VM
Write-Host "Copying test config file to target cluster VM...."
$command = "scp -i $sshPath -o StrictHostKeyChecking=no -o BatchMode=yes config.yaml $dest"
try {
$output=invoke-expression $command
if ($LASTEXITCODE -ne 0) {
Write-Error "Couldn't ssh to AKS cluster control plane VM $vmIP. Please check the ssh key"
exit
}
} catch {
Write-Host "Couldn't ssh to AKS cluster control plane VM $vmIP. Please check the ssh key"
Write-Host "Exception message: $_"
exit
}
Write-Output "Copied config.yaml successfully."
$runScriptContent = @"
sudo su - root -c "/usr/bin/diagnostics-checker -c /home/clouduser/config.yaml"
"@
$filePath = "run_diag.sh"
Set-Content -Path $filePath -Value $runScriptContent
$dest = 'clouduser@' + $vmIP + ":run_diag.sh"
scp -i $sshPath -o StrictHostKeyChecking=no -o BatchMode=yes run_diag.sh $dest
$dest = 'clouduser@' + $vmIP
ssh -i $sshPath $dest -o StrictHostKeyChecking=no -o BatchMode=yes 'chmod +x run_diag.sh'
$sedCommand="sed -i -e 's/\r$//' run_diag.sh"
ssh -i $sshPath -o StrictHostKeyChecking=no -o BatchMode=yes $dest $sedCommand
if (Test-Path -Path "results.yaml") {
Remove-Item results.yaml
}
ssh -i $sshPath -o StrictHostKeyChecking=no -o BatchMode=yes $dest './run_diag.sh'
ssh -i $sshPath -o StrictHostKeyChecking=no -o BatchMode=yes $dest "sudo su - root -c 'chmod a+r /home/clouduser/results.yaml'"
$src= 'clouduser@' + $vmIP + ":results.yaml"
scp -i $sshPath -o StrictHostKeyChecking=no -o BatchMode=yes $src results.yaml
if (-Not (Test-Path -Path "results.yaml")) {
write-host "Test failed to perform"
exit
}
Install-Module powershell-yaml
$resultContent = Get-Content -path results.yaml | ConvertFrom-Yaml
$testResults = @()
$cloudAgentRecommendation = @"
Make sure that the logical network IP addresses can connect to all the management IP pool addresses on the required ports. Check AKS network port and cross vlan requirements for detailed list of ports that need to be opened.
"@
$gatewayRecommendation = @"
- Ensure gateway is operational
- Verify routing configurations
- Adjust firewall rules to allow ICMP traffic
"@
$urlRecommendation = @"
Ensure that the logical network IP addresses have outbound internet access. If there's a firewall, ensure that AKS required URLs are accessible from Arc VM logical network.
"@
foreach ($check in $resultContent.spec.checks) {
if ($check.result.outcome -like "Success") {
$recommendation=""
}elseif ($check.metadata.name -like "cloud-agent-connectivity-test") {
$recommendation=$cloudAgentRecommendation
}elseif ($check.metadata.name -like "gateway-icmp-ping-test") {
$recommendation=$gatewayRecommendation
}elseif ($check.metadata.name -like "http-connectivity-required-url-test") {
$recommendation=$urlRecommendation
}
$testResults += [PSCustomObject]@{
TestName=$check.metadata.name
Outcome= $check.result.outcome
Recommendation = $recommendation
}
}
$testResults | Format-Table -Wrap -AutoSize
サンプル出力:
TestName Outcome Recommendation
-------- ------- --------------
cloud-agent-connectivity-test Success
gateway-icmp-ping-test Success
http-connectivity-required-url-test Failure Ensure that the logical network IP addresses have outbound internet access. If there's a firewall, ensure that AKS required URLs are accessible from Arc VM logical network.
診断チェッカーの出力を分析する
次の表は、スクリプトによって実行される各テストの概要を示しています。これには、エラーの考えられる原因と軽減策の推奨事項を示します。
| テスト名 | 説明 | エラーの原因 | 移行の推奨事項 |
|---|---|---|---|
| クラウドエージェント接続テスト | DNS サーバーが MOC クラウド エージェントの FQDN を解決できるかどうか、およびクラウド エージェントがコントロール プレーン ノード VM から到達可能かどうかを確認します。 クラウド エージェントは、ポート 55000 の管理 IP プールの IP アドレスのいずれかを使用して作成されます。 コントロール プレーン ノード VM には、Arc VM 論理ネットワークからの IP アドレスが与えられます。 | 論理ネットワーク IP アドレスは、次の理由により管理 IP プール アドレスに接続できません。 - DNS サーバーの解決が正しくありません。 - ファイアウォール規則。 - 論理ネットワークは管理 IP プールとは異なる VLAN にあり、クロス VLAN 接続はありません。 |
論理ネットワーク IP アドレスが、必要なポート上のすべての管理 IP プール アドレスに接続できることを確認します。 AKS ネットワーク ポートとクロス VLAN の要件を確認し、解放する必要があるポートの詳細な一覧を確認します。 |
| ゲートウェイICMPピンテスト | AKS クラスターに接続されている論理ネットワークで指定されたゲートウェイが、AKS クラスターコントロール プレーン ノード VM から到達可能かどうかを確認します。 | - ゲートウェイが停止しているか、到達不能です。 - AKS クラスター コントロール プレーン ノード VM とゲートウェイの間のネットワーク ルーティングの問題。 - ICMP トラフィックをブロックするファイアウォール。 |
- ゲートウェイが動作していることを確認します。 - ルーティング構成を確認します。 - ICMP トラフィックを許可するようにファイアウォール規則を調整します。 |
| http-connectivity-required-url-test | AKS クラスター コントロール プレーン ノード VM から必要な URL に到達できるかどうかを確認します。 | - コントロール プレーン ノード VM にアウトバウンド インターネット アクセスがありません。 - 必要な URL はファイアウォール経由では許可されません。 |
論理ネットワーク IP アドレスにアウトバウンド インターネット アクセスがあることを確認します。 ファイアウォールがある場合は、AKS で必要な URL に Arc VM 論理ネットワークからアクセスできることを確認します。 |
次のステップ
問題が解決しない場合は、サポート要求 を作成する前に、AKS クラスター ログ を収集してください。