疑難排解 Azure 容器儲存體
Azure 容器儲存體是雲端式磁碟區管理、部署和協調流程服務,專為容器原生建置。 使用本文針對 Azure 容器儲存體的常見問題進行疑難排解,並找出問題的解決方式。
針對安裝問題進行疑難排解
由於設定遺失,Azure Container Storage 無法安裝
執行 az aks create
之後,您可能會看到 Azure Container Storage 無法安裝訊息 。AKS 叢集已建立。執行 az aks update
並 --enable-azure-container-storage
執行 以啟用 Azure Container Storage。
此訊息表示未安裝 Azure 容器記憶體,但已正確建立您的 AKS (Azure Kubernetes Service) 叢集。
若要安裝 Azure 容器儲存體及建立存放集區,請執行下列命令。 將<cluster-name>
和 <resource-group>
取代為您自己的值。 以 azureDisk
、ephemeraldisk
或 elasticSan
取代 <storage-pool-type>
。
az aks update -n <cluster-name> -g <resource-group> --enable-azure-container-storage <storage-pool-type>
由於 Azure 原則 限制,Azure Container Storage 無法安裝
如果已備妥 Azure 原則 限制,Azure 容器記憶體可能無法安裝。 具體而言,Azure Container Storage 依賴特殊許可權的容器。 您可以設定 Azure 原則 來封鎖具特殊許可權的容器。 當它們遭到封鎖時,Azure Container Storage 的安裝可能會逾時或失敗,而且您可能會在記錄中看到 gatekeeper-controller
錯誤,例如:
$ kubectl logs -n gatekeeper-system deployment/gatekeeper-controller
...
{"level":"info","ts":1722622443.9484184,"logger":"webhook","msg":"denied admission: Privileged container is not allowed: prereq, securityContext: {\"privileged\": true, \"runAsUser\": 0}","hookType":"validation","process":"admission","details":{},"event_type":"violation","constraint_name":"azurepolicy-k8sazurev2noprivilege-686dd8b209a774ba977c","constraint_group":"constraints.gatekeeper.sh","constraint_api_version":"v1beta1","constraint_kind":"K8sAzureV2NoPrivilege","constraint_action":"deny","resource_group":"","resource_api_version":"v1","resource_kind":"Pod","resource_namespace":"acstor","resource_name":"azurecontainerstorage-prereq-gt58x","request_username":"system:serviceaccount:kube-system:daemon-set-controller"}
{"level":"info","ts":1722622443.9839077,"logger":"webhook","msg":"denied admission: Privileged container is not allowed: metrics-exporter, securityContext: {\"privileged\": true}","hookType":"validation","process":"admission","details":{},"event_type":"violation","constraint_name":"azurepolicy-k8sazurev2noprivilege-686dd8b209a774ba977c","constraint_group":"constraints.gatekeeper.sh","constraint_api_version":"v1beta1","constraint_kind":"K8sAzureV2NoPrivilege","constraint_action":"deny","resource_group":"","resource_api_version":"v1","resource_kind":"Pod","resource_namespace":"acstor","resource_name":"azurecontainerstorage-metrics-exporter-286np","request_username":"system:serviceaccount:kube-system:daemon-set-controller"}
{"level":"info","ts":1722622444.0515249,"logger":"webhook","msg":"denied admission: Privileged container is not allowed: csi-node, securityContext: {\"privileged\": true}","hookType":"validation","process":"admission","details":{},"event_type":"violation","constraint_name":"azurepolicy-k8sazurev2noprivilege-686dd8b209a774ba977c","constraint_group":"constraints.gatekeeper.sh","constraint_api_version":"v1beta1","constraint_kind":"K8sAzureV2NoPrivilege","constraint_action":"deny","resource_group":"","resource_api_version":"v1","resource_kind":"Pod","resource_namespace":"acstor","resource_name":"azurecontainerstorage-csi-node-7hcd7","request_username":"system:serviceaccount:kube-system:daemon-set-controller"}
{"level":"info","ts":1722622444.0729053,"logger":"webhook","msg":"denied admission: Privileged container is not allowed: io-engine, securityContext: {\"privileged\": true}","hookType":"validation","process":"admission","details":{},"event_type":"violation","constraint_name":"azurepolicy-k8sazurev2noprivilege-686dd8b209a774ba977c","constraint_group":"constraints.gatekeeper.sh","constraint_api_version":"v1beta1","constraint_kind":"K8sAzureV2NoPrivilege","constraint_action":"deny","resource_group":"","resource_api_version":"v1","resource_kind":"Pod","resource_namespace":"acstor","resource_name":"azurecontainerstorage-io-engine-84hwx","request_username":"system:serviceaccount:kube-system:daemon-set-controller"}
{"level":"info","ts":1722622444.0742755,"logger":"webhook","msg":"denied admission: Privileged container is not allowed: ndm, securityContext: {\"privileged\": true}","hookType":"validation","process":"admission","details":{},"event_type":"violation","constraint_name":"azurepolicy-k8sazurev2noprivilege-686dd8b209a774ba977c","constraint_group":"constraints.gatekeeper.sh","constraint_api_version":"v1beta1","constraint_kind":"K8sAzureV2NoPrivilege","constraint_action":"deny","resource_group":"","resource_api_version":"v1","resource_kind":"Pod","resource_namespace":"acstor","resource_name":"azurecontainerstorage-ndm-x6q5n","request_username":"system:serviceaccount:kube-system:daemon-set-controller"}
{"level":"info","ts":1722622449.2412128,"logger":"webhook","msg":"denied admission: Privileged container is not allowed: ndm, securityContext: {\"privileged\": true}","hookType":"validation","process":"admission","details":{},"event_type":"violation","constraint_name":"azurepolicy-k8sazurev2noprivilege-686dd8b209a774ba977c","constraint_group":"constraints.gatekeeper.sh","constraint_api_version":"v1beta1","constraint_kind":"K8sAzureV2NoPrivilege","constraint_action":"deny","resource_group":"","resource_api_version":"v1","resource_kind":"Pod","resource_namespace":"acstor","resource_name":"azurecontainerstorage-ndm-b5nfg","request_username":"system:serviceaccount:kube-system:daemon-set-controller"}
若要解決封鎖問題,您必須將命名空間新增acstor
至 Azure 原則 的排除清單。 Azure 原則 可用來建立並強制執行規則來管理 Azure 內的資源,包括 AKS 叢集。 在某些情況下,原則可能會封鎖建立 Azure 容器記憶體 Pod 和元件。 您可以諮詢 Kubernetes 的 Azure 原則,以找到更多有關使用 Kubernetes Azure 原則 的詳細數據。
若要將 acstor
命名空間新增至排除清單,請遵循下列步驟:
- 建立您的 Azure Kubernetes 叢集。
- 啟用 AKS 的 Azure 原則。
- 建立您懷疑封鎖 Azure Container Storage 安裝的原則。
- 嘗試在 AKS 叢集中安裝 Azure Container Storage。
- 檢查閘道守衛控制器 Pod 的記錄,以確認任何原則違規。
- 將
acstor
命名空間和azure-extensions-usage-system
命名空間新增至原則的排除清單。 - 再次嘗試在 AKS 叢集中安裝 Azure Container Storage。
無法在具有污點的節點集區中安裝和啟用 Azure 容器記憶體
您可以在節點集區上設定 節點污點 ,以限制 Pod 在這些節點集區上排程。 在這些節點集區上安裝和啟用 Azure Container Storage 可能會遭到封鎖,因為無法在這些節點集區中建立必要的 Pod。 安裝時的行為會同時套用至系統節點集區,以及在啟用時套用使用者節點集區。
您可以使用下列範例來檢查節點污點:
$ az aks nodepool list -g $resourceGroup --cluster-name $clusterName --query "[].{PoolName:name, nodeTaints:nodeTaints}"
[
...
{
"PoolName": "nodepoolx",
"nodeTaints": [
"sku=gpu:NoSchedule"
]
}
]
您可以暫時移除這些污點以解除封鎖,並在安裝並成功啟用之後將其設定回來。 您可以移至 Azure 入口網站 > AKS 叢集 > 節點集區,按兩下您的節點集區,移除 [Taints 和標籤] 區段中的污點。 或者,您可以使用下列命令來移除污點並確認變更。
$ az aks nodepool update -g $resourceGroup --cluster-name $clusterName --name $nodePoolName --node-taints ""
$ az aks nodepool list -g $resourceGroup --cluster-name $clusterName --query "[].{PoolName:name, nodeTaints:nodeTaints}"
[
...
{
"PoolName": "nodepoolx",
"nodeTaints": null
}
]
成功移除節點污點之後,請重試安裝或啟用。 成功完成之後,您可以將節點污點設定回以繼續 Pod 排程限制。
無法將存放集區類型設定為 NVMe
如果您嘗試使用暫時性磁碟安裝 Azure 容器儲存體,特別是在虛擬機器 (VM) SKU 沒有 NVMe 磁碟機的叢集上使用本機 NVMe 時,您會收到下列錯誤訊息:無法將 --storage-pool-option 設定為 NVMe,因為節點集區全都不支援暫時性 NVMe 磁碟。
若要補救,請使用具有 NVMe 磁碟機的 VM SKU 建立節點集區,然後再試一次。 請參閱儲存體最佳化 VM。
針對存放集區問題進行疑難排解
若要檢查存放集區的狀態,請執行 kubectl describe sp <storage-pool-name> -n acstor
。 以下是您可能會遇到的一些問題。
暫時存放集區在其他精靈集使用暫時磁碟時,不會宣告容量
如果在具有暫存 SSD 或本機 NVMe 磁碟的節點集區上啟用暫時存放集區,如果其他精靈集正在使用這些磁碟,可能無法從這些磁碟宣告容量。
執行下列步驟,讓 Azure Container Storage 以獨佔方式管理這些本機磁碟:
執行下列命令,查看暫時存放集區所宣告的容量:
$ kubectl get sp -A NAMESPACE NAME CAPACITY AVAILABLE USED RESERVED READY AGE acstor ephemeraldisk-nvme 0 0 0 0 False 82s
此範例顯示存放集區所
ephemeraldisk-nvme
宣告的零容量。執行下列命令來確認這些本機區塊裝置的未認領狀態,並檢查磁碟上現有的檔案系統:
$ kubectl get bd -A NAMESPACE NAME NODENAME SIZE CLAIMSTATE STATUS AGE acstor blockdevice-1f7ad8fa32a448eb9768ad8e261312ff aks-nodepoolnvme-38618677-vmss000001 1920383410176 Unclaimed Active 22m acstor blockdevice-9c8096fc47cc2b41a2ed07ec17a83527 aks-nodepoolnvme-38618677-vmss000000 1920383410176 Unclaimed Active 23m $ kubectl describe bd -n acstor blockdevice-1f7ad8fa32a448eb9768ad8e261312ff Name: blockdevice-1f7ad8fa32a448eb9768ad8e261312ff … Filesystem: Fs Type: ext4 …
此範例顯示區塊裝置的狀態
Unclaimed
,且磁碟上有現有的文件系統。確認您想要在繼續之前,先使用 Azure Container Storage 獨佔管理本機數據磁碟。
停止並移除管理本機數據磁碟的精靈集或元件。
登入具有本機數據磁碟的每個節點。
從所有本機數據磁碟移除現有的檔案系統。
重新啟動 ndm 精靈集以探索未使用的本機數據磁碟。
$ kubectl rollout restart daemonset -l app=ndm -n acstor daemonset.apps/azurecontainerstorage-ndm restarted $ kubectl rollout status daemonset -l app=ndm -n acstor --watch … daemon set "azurecontainerstorage-ndm" successfully rolled out
等候幾秒鐘,並檢查暫時存放集區是否從本機數據磁碟宣告容量。
$ kubectl wait -n acstor sp --all --for condition=ready storagepool.containerstorage.azure.com/ephemeraldisk-nvme condition met $ kubectl get bd -A NAMESPACE NAME NODENAME SIZE CLAIMSTATE STATUS AGE acstor blockdevice-1f7ad8fa32a448eb9768ad8e261312ff aks-nodepoolnvme-38618677-vmss000001 1920383410176 Claimed Active 4d16h acstor blockdevice-9c8096fc47cc2b41a2ed07ec17a83527 aks-nodepoolnvme-38618677-vmss000000 1920383410176 Claimed Active 4d16h $ kubectl get sp -A NAMESPACE NAME CAPACITY AVAILABLE USED RESERVED READY AGE acstor ephemeraldisk-nvme 3840766820352 3812058578944 28708241408 26832871424 True 4d16h
此範例顯示
ephemeraldisk-nvme
存放集區已成功從節點上的本機 NVMe 磁碟宣告容量。
嘗試擴充 Azure 磁碟存放集區時發生錯誤
如果您現有的存放集區小於 4 TiB (4,096 GiB),則您只能將其擴充至 4,095 GiB。 如果您嘗試擴充超出限制,內部PVC會顯示磁碟大小或快取類型限制的錯誤訊息。 停止您的 VM 或中斷連結磁碟,然後重試作業。」
為了避免錯誤,如果目前儲存集區最初小於 4 TiB(4,096 GiB),請勿嘗試將目前的存放集區擴充至 4,095 GiB。 大於 4 TB 的存放集區最多可以擴充到可用的儲存體容量上限。
僅當使用 Premium_LRS
、Standard_LRS
、StandardSSD_LRS
、Premium_ZRS
和 StandardSSD_ZRS
磁碟 SKU 時,才適用此限制。
彈性 SAN 建立失敗
如果您嘗試建立彈性 SAN 存放集區,可能會看到以下訊息:Azure 彈性 SAN 建立失敗:已建立訂用帳戶的彈性 SAN 數目上限。 這表示您可以達到每個訂用帳戶區域中可部署之彈性 SAN 資源數目的限制。 您可以在這裡檢查限制:彈性 SAN 延展性和效能目標。 請考慮在不再使用的訂用帳戶上刪除任何現有彈性 SAN 資源,或嘗試在不同的區域中建立存放集區。
找不到封鎖裝置
如果您看到此訊息,可能會嘗試在 VM SKU 沒有 NVMe 磁碟機的叢集上建立暫時性磁碟存放集區。
若要補救,請使用具有 NVMe 磁碟機的 VM SKU 建立節點集區,然後再試一次。 請參閱儲存體最佳化 VM。
存放集區類型已啟用
如果您嘗試啟用存在的存放集區類型,您會收到下列訊息:無效--enable-azure-container-storage
的值。已針對叢集中的記憶體集區類型<storage-pool-type>
啟用 Azure 容器記憶體。 您可以執行 kubectl get sp -n acstor
來檢查您是否已建立任何現有的存放集區。
停用存放集區類型
透過 az aks update --disable-azure-container-storage <storage-pool-type>
停用存放集區類型或透過 az aks update --disable-azure-container-storage all
取消安裝 Azure 容器儲存體時,如果有該類型的現有存放集區,您會收到下列訊息:
停用記憶體集區類型的 <storage-pool-type>
Azure Container Storage 會強制刪除相同類型的所有存放集區,並影響使用這些存放集區的應用程式。 強制刪除存放集區也會導致耗用的儲存體資源流失。 您是否要在停用 Azure 容器儲存體之前,驗證是否使用任何 <storage-pool-type>
類型存放集區? (是/否)
如果您選取 Y,就會執行自動驗證,以確保沒有從存放集區建立的永續性磁碟區。 選取 n 會略過此驗證,並停用存放集區類型、刪除任何現有的存放集區,並可能會影響您的應用程式。
針對磁碟區問題進行疑難排解
Pod 暫止建立,因為暫時磁碟區大小超過可用的容量
暫時性磁碟區會配置在單一節點上。 當您設定 Pod 的暫時性磁碟區大小時,大小應該小於單一節點暫時性磁碟的可用容量。 否則,Pod 建立會處於擱置狀態。
使用下列命令來檢查 Pod 建立是否處於擱置狀態。
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
fiopod 0/1 Pending 0 17s
在此範例中,Pod fiopod
處於 Pending
狀態。
使用下列命令來檢查 Pod 是否有 persistentvolumeclaim 建立的警告事件。
$ kubectl describe pod fiopod
...
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning FailedScheduling 40s default-scheduler 0/3 nodes are available: waiting for ephemeral volume controller to create the persistentvolumeclaim "fiopod-ephemeralvolume". preemption: 0/3 nodes are available: 3 Preemption is not helpful for scheduling..
在此範例中,Pod 會顯示建立永續性磁碟區宣告 fiopod-ephemeralvolume
的警告事件。
使用下列命令來檢查持續性磁碟區宣告是否因為容量不足而無法佈建。
$ kubectl describe pvc fiopod-ephemeralvolume
...
Warning ProvisioningFailed 107s (x13 over 20m) containerstorage.csi.azure.com_aks-nodepool1-29463073-vmss000000_xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx failed to provision volume with StorageClass "acstor-ephemeraldisk-temp": rpc error: code = Internal desc = Operation failed: GenericOperation("error in response: status code '507 Insufficient Storage', content: 'RestJsonError { details: \"Operation failed due to insufficient resources: Not enough suitable pools available, 0/1\", message: \"SvcError :: NotEnoughResources\", kind: ResourceExhausted }'")
在此範例中,Insufficient Storage
會顯示為磁碟區佈建失敗的原因。
執行下列命令來檢查單一節點暫時性磁碟的可用容量。
$ kubectl get diskpool -n acstor
NAME CAPACITY AVAILABLE USED RESERVED READY AGE
ephemeraldisk-temp-diskpool-jaxwb 75660001280 75031990272 628011008 560902144 True 21h
ephemeraldisk-temp-diskpool-wzixx 75660001280 75031990272 628011008 560902144 True 21h
ephemeraldisk-temp-diskpool-xbtlj 75660001280 75031990272 628011008 560902144 True 21h
在此範例中,單一節點的可用暫存磁碟容量為 75031990272
位元組或 69 GiB。
調整小於可用容量的磁碟區記憶體大小,然後重新部署您的 Pod。 請參閱使用一般暫時性磁碟區部署 Pod。
磁碟區因中繼資料存放區離線而無法連結
Azure 容器儲存體使用 etcd
(這是分散式的可靠索引鍵/值存放區),用於儲存和管理磁碟區的中繼資料以支援磁碟區協調流程作業。 為了獲得高可用性和復原能力,etcd
會在這些集區中執行。 當執行少於兩 etcd
個實例時,Azure Container Storage 會停止磁碟區協調流程作業,同時仍允許數據存取磁碟區。 Azure 容器儲存體會在 etcd
執行個體離線和復原時自動進行偵測。 不過,如果您在重新啟動 AKS 叢集之後注意到磁碟區協調流程錯誤,實例可能會 etcd
無法自動復原。 請遵循本節中的指示,判斷 etcd
執行個體的健全狀態。
執行下列命令來取得 Pod 的清單。
kubectl get pods
您可能會看到類似下列的輸出。
NAME READY STATUS RESTARTS AGE
fiopod 0/1 ContainerCreating 0 25m
描述 Pod:
kubectl describe pod fiopod
一般而言,如果元數據存放區離線,您會看到磁碟區失敗訊息。 在此範例中,fiopod 處於 ContainerCreating 狀態,而 FailedAttachVolume 警告表示建立因磁碟區連結失敗而擱置。
Name: fiopod
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 25m default-scheduler Successfully assigned default/fiopod to aks-nodepool1-xxxxxxxx-vmss000009
Warning FailedAttachVolume 3m8s (x6 over 23m) attachdetach-controller AttachVolume.Attach failed for volume "pvc-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" : timed out waiting for external-attacher of containerstorage.csi.azure.com CSI driver to attach volume xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
您也可以執行下列命令以檢查 etcd
執行個體的狀態:
kubectl get pods -n acstor | grep "^etcd"
您應該看到類似以下的輸出,其中所有執行個體都處於執行中狀態:
etcd-azurecontainerstorage-bn89qvzvzv 1/1 Running 0 4d19h
etcd-azurecontainerstorage-phf92lmqml 1/1 Running 0 4d19h
etcd-azurecontainerstorage-xznvwcgq4p 1/1 Running 0 4d19h
如果執行少於兩個實例,磁碟區不會附加,因為元數據存放區已脫機,且自動復原失敗。 如果是,請向 Azure 支援提出支援票證。