從 Azure Kubernetes Service (AKS) 叢集節點取得 kubelet 記錄Get kubelet logs from Azure Kubernetes Service (AKS) cluster nodes

在操作 AKS 叢集,您可能需要檢閱的問題進行疑難排解的記錄檔。As part of operating an AKS cluster, you may need to review logs to troubleshoot a problem. 內建於 Azure 入口網站是以檢視記錄檔的能力AKS 主要元件 or containers in an AKS clusterBuilt-in to the Azure portal is the ability to view logs for the AKS master components or containers in an AKS cluster. 有時候,您可能需要取得kubelet AKS 節點以進行疑難排解的記錄檔。Occasionally, you may need to get kubelet logs from an AKS node for troubleshooting purposes.

本文說明如何使用journalctl若要檢視kubelet AKS 節點上的記錄。This article shows you how you can use journalctl to view the kubelet logs on an AKS node.

開始之前Before you begin

此文章假設您目前具有 AKS 叢集。This article assumes that you have an existing AKS cluster. 如果您需要 AKS 叢集,請參閱 AKS 快速入門使用 Azure CLI or using the Azure portalIf you need an AKS cluster, see the AKS quickstart using the Azure CLI or using the Azure portal.

建立 SSH 連線Create an SSH connection

首先,請針對您需要檢視 kubelet 記錄的節點建立 SSH 連線。First, create an SSH connection with the node on which you need to view kubelet logs. 這項作業會詳細說明透過 ssh 連線到 Azure Kubernetes Service (AKS) 叢集節點文件。This operation is detailed in the SSH into Azure Kubernetes Service (AKS) cluster nodes document.

取得 kubelet 記錄Get kubelet logs

一旦您已連線到節點後,請執行下列命令以提取 kubelet 記錄:Once you have connected to the node, run the following command to pull the kubelet logs:

sudo journalctl -u kubelet -o cat

下列範例輸出顯示 kubelet 記錄資料:The following sample output shows the kubelet log data:

I0508 12:26:17.905042    8672 kubelet_node_status.go:497] Using Node Hostname from cloudprovider: "aks-agentpool-11482510-0"
I0508 12:26:27.943494    8672 kubelet_node_status.go:497] Using Node Hostname from cloudprovider: "aks-agentpool-11482510-0"
I0508 12:26:28.920125    8672 server.go:796] GET /stats/summary: (10.370874ms) 200 [[Ruby] 10.244.0.2:52292]
I0508 12:26:37.964650    8672 kubelet_node_status.go:497] Using Node Hostname from cloudprovider: "aks-agentpool-11482510-0"
I0508 12:26:47.996449    8672 kubelet_node_status.go:497] Using Node Hostname from cloudprovider: "aks-agentpool-11482510-0"
I0508 12:26:58.019746    8672 kubelet_node_status.go:497] Using Node Hostname from cloudprovider: "aks-agentpool-11482510-0"
I0508 12:27:05.107680    8672 server.go:796] GET /stats/summary/: (24.853838ms) 200 [[Go-http-client/1.1] 10.244.0.3:44660]
I0508 12:27:08.041736    8672 kubelet_node_status.go:497] Using Node Hostname from cloudprovider: "aks-agentpool-11482510-0"
I0508 12:27:18.068505    8672 kubelet_node_status.go:497] Using Node Hostname from cloudprovider: "aks-agentpool-11482510-0"
I0508 12:27:28.094889    8672 kubelet_node_status.go:497] Using Node Hostname from cloudprovider: "aks-agentpool-11482510-0"
I0508 12:27:38.121346    8672 kubelet_node_status.go:497] Using Node Hostname from cloudprovider: "aks-agentpool-11482510-0"
I0508 12:27:44.015205    8672 server.go:796] GET /stats/summary: (30.236824ms) 200 [[Ruby] 10.244.0.2:52588]
I0508 12:27:48.145640    8672 kubelet_node_status.go:497] Using Node Hostname from cloudprovider: "aks-agentpool-11482510-0"
I0508 12:27:58.178534    8672 kubelet_node_status.go:497] Using Node Hostname from cloudprovider: "aks-agentpool-11482510-0"
I0508 12:28:05.040375    8672 server.go:796] GET /stats/summary/: (27.78503ms) 200 [[Go-http-client/1.1] 10.244.0.3:44660]
I0508 12:28:08.214158    8672 kubelet_node_status.go:497] Using Node Hostname from cloudprovider: "aks-agentpool-11482510-0"
I0508 12:28:18.242160    8672 kubelet_node_status.go:497] Using Node Hostname from cloudprovider: "aks-agentpool-11482510-0"
I0508 12:28:28.274408    8672 kubelet_node_status.go:497] Using Node Hostname from cloudprovider: "aks-agentpool-11482510-0"
I0508 12:28:38.296074    8672 kubelet_node_status.go:497] Using Node Hostname from cloudprovider: "aks-agentpool-11482510-0"
I0508 12:28:48.321952    8672 kubelet_node_status.go:497] Using Node Hostname from cloudprovider: "aks-agentpool-11482510-0"
I0508 12:28:58.344656    8672 kubelet_node_status.go:497] Using Node Hostname from cloudprovider: "aks-agentpool-11482510-0"

後續步驟Next steps

如果您需要從 Kubernetes 主機的其他疑難排解資訊,請參閱檢視主要節點會記錄在 AKS 的 KubernetesIf you need additional troubleshooting information from the Kubernetes master, see view Kubernetes master node logs in AKS.