Skip to content

Commit a952c76

Browse files
authored
Merge pull request #262681 from nathaniel-msft/node-access-1
AKS Node Access page revision.
2 parents 73e5494 + 84b4098 commit a952c76

File tree

2 files changed

+55
-43
lines changed

2 files changed

+55
-43
lines changed

articles/aks/index.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ landingContent:
160160
- text: Connect to Windows Server nodes over RDP
161161
url: rdp.md
162162
- text: Connect to Windows Server nodes over SSH
163-
url: node-access.md#create-the-ssh-connection-to-a-windows-node
163+
url: node-access.md#windows-server-proxy-connection
164164
- text: Windows Server containers FAQ
165165
url: windows-faq.md
166166

articles/aks/node-access.md

Lines changed: 54 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,44 @@
11
---
22
title: Connect to Azure Kubernetes Service (AKS) cluster nodes
33
description: Learn how to connect to Azure Kubernetes Service (AKS) cluster nodes for troubleshooting and maintenance tasks.
4-
ms.topic: article
5-
ms.date: 12/20/2023
4+
ms.topic: troubleshooting
5+
ms.date: 01/08/2024
66
ms.reviewer: mattmcinnes
77
ms.custom: contperf-fy21q4, devx-track-linux
88
#Customer intent: As a cluster operator, I want to learn how to connect to virtual machines in an AKS cluster to perform maintenance or troubleshoot a problem.
99
---
1010

1111
# Connect to Azure Kubernetes Service (AKS) cluster nodes for maintenance or troubleshooting
1212

13-
Throughout the lifecycle of your Azure Kubernetes Service (AKS) cluster, you might need to access an AKS node. This access could be for maintenance, log collection, or troubleshooting operations. You can securely authenticate against AKS Linux and Windows nodes using SSH, and you can also [connect to Windows Server nodes using remote desktop protocol (RDP)][aks-windows-rdp]. For security reasons, the AKS nodes aren't exposed to the internet. To connect to the AKS nodes, you use `kubectl debug` or the private IP address.
13+
Throughout the lifecycle of your Azure Kubernetes Service (AKS) cluster, you eventually need to directly access an AKS node. This access could be for maintenance, log collection, or troubleshooting operations.
1414

15-
This article shows you how to create a connection to an AKS node and update the SSH key on an existing AKS cluster.
15+
You access a node through authentication, which methods vary depending on your Node OS and method of connection. You securely authenticate against AKS Linux and Windows nodes using SSH. Alternatively, for Windows Servers you can also connect to Windows Server nodes using the [remote desktop protocol (RDP)][aks-windows-rdp].
16+
17+
For security reasons, AKS nodes aren't exposed to the internet. Instead, to connect directly to any AKS nodes, you need to use either `kubectl debug` or the host's private IP address.
18+
19+
This guide shows you how to create a connection to an AKS node and update the SSH key of your AKS cluster.
1620

1721
## Before you begin
1822

19-
This article assumes you have an SSH key. If not, you can create an SSH key using [macOS or Linux][ssh-nix] or [Windows][ssh-windows], to know more refer [Manage SSH configuration][manage-ssh-node-access]. Make sure you save the key pair in an OpenSSH format, other formats like .ppk aren't supported.
23+
To follow along the steps, you need to use Azure CLI that supports version 2.0.64 or later. Run `az --version` to check the version. If you need to install or upgrade, see [Install Azure CLI][install-azure-cli].
24+
25+
Complete these steps if you don't have an SSH key. Create an SSH key depending on your Node OS Image, for [macOS and Linux][ssh-nix], or [Windows][ssh-windows]. Make sure you save the key pair in the OpenSSH format, avoid unsupported formats such as `.ppk`. Next, refer to [Manage SSH configuration][manage-ssh-node-access] to add the key to your cluster.
26+
27+
## Linux and macOS
2028

21-
You also need the Azure CLI version 2.0.64 or later installed and configured. Run `az --version` to find the version. If you need to install or upgrade, see [Install Azure CLI][install-azure-cli].
29+
Linux and macOS users can SSH to access their node using `kubectl debug` or their private IP Address. Windows users should skip to the Windows Server Proxy section for a workaround to SSH via proxy.
2230

23-
## Create an interactive shell connection to a Linux node using kubectl
31+
### SSH using kubectl debug
2432

25-
To create an interactive shell connection to a Linux node, use the `kubectl debug` command to run a privileged container on your node.
33+
To create an interactive shell connection, use the `kubectl debug` command to run a privileged container on your node.
2634

2735
1. To list your nodes, use the `kubectl get nodes` command:
2836

2937
```bash
3038
kubectl get nodes -o wide
3139
```
3240

33-
The following example resembles output from the command:
41+
Sample output:
3442

3543
```output
3644
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE
@@ -39,44 +47,49 @@ To create an interactive shell connection to a Linux node, use the `kubectl debu
3947
aksnpwin000000 Ready agent 160m v1.25.6 10.224.0.62 <none> Windows Server 2022 Datacenter
4048
```
4149

42-
2. Use the `kubectl debug` command to run a container image on the node to connect to it. The following command starts a privileged container on your node and connects to it.
50+
2. Use the `kubectl debug` command to start a privileged container on your node and connect to it.
4351

4452
```bash
4553
kubectl debug node/aks-nodepool1-37663765-vmss000000 -it --image=mcr.microsoft.com/cbl-mariner/busybox:2.0
4654
```
4755

48-
The following example resembles output from the command:
56+
Sample output:
4957

5058
```output
5159
Creating debugging pod node-debugger-aks-nodepool1-37663765-vmss000000-bkmmx with container debugger on node aks-nodepool1-37663765-vmss000000.
5260
If you don't see a command prompt, try pressing enter.
5361
root@aks-nodepool1-37663765-vmss000000:/#
5462
```
5563
56-
This privileged container gives access to the node.
64+
You now have access to the node through a privileged container as a debugging pod.
5765
5866
> [!NOTE]
5967
> You can interact with the node session by running `chroot /host` from the privileged container.
6068
61-
### Remove Linux node access
69+
### Exit kubectl debug mode
6270
63-
When you're done with a debugging pod, enter the `exit` command to end the interactive shell session. After the interactive container session closes, delete the pod used for access with `kubectl delete pod`.
71+
When you're done with your node, enter the `exit` command to end the interactive shell session. After the interactive container session closes, delete the debugging pod used with `kubectl delete pod`.
6472
6573
```bash
6674
kubectl delete pod node-debugger-aks-nodepool1-37663765-vmss000000-bkmmx
6775
```
68-
## Create an interactive shell connection to a node using private IP
6976

70-
If you don't have access to the Kubernetes API, you can get access to properties such as ```Node IP``` and ```Node Name``` through the AKS Agentpool Preview API(preview version 07-02-2023 or above) to troubleshoot node-specific issues in your AKS node pools. For convenience, we also expose the public IP if the node has a public IP assigned. However in order to SSH into the node, you need to be in the cluster's virtual network.
77+
## Private IP Method
78+
79+
If you don't have access to the Kubernetes API, you can get access to properties such as ```Node IP``` and ```Node Name``` through the [AKS Agent Pool Preview API][agent-pool-rest-api] (preview version 07-02-2023 or above) to troubleshoot node-specific issues in your AKS node pools.
80+
81+
### Create an interactive shell connection to a node using the IP address
82+
83+
For convenience, the nodepools are exposed when the node has a public IP assigned. However, you need to be in the cluster's virtual network to SSH into the node.
7184

72-
1. To get the private IP via CLI, use az cli version 2.53 or above with aks-preview extension installed.
85+
1. To get the private IP, use the `machine list` to show all your VMs.
7386

7487
```bash
7588
az aks machine list --resource-group myResourceGroup --cluster-name myAKSCluster --nodepool-name nodepool1 -o table
7689

7790
```
7891

79-
The following example resembles output from the command:
92+
Sample output:
8093

8194
```output
8295
Name Ip
@@ -85,60 +98,66 @@ aks-nodepool1-33555069-vmss000000 10.224.0.5,family:IPv4;
8598
aks-nodepool1-33555069-vmss000001 10.224.0.6,family:IPv4;
8699
aks-nodepool1-33555069-vmss000002 10.224.0.4,family:IPv4;
87100
```
88-
To target a specific node inside the nodepool, use this command:
101+
To target a specific node inside the nodepool, add a `--machine-name` flag:
89102

90103
```bash
91104
az aks machine show --cluster-name myAKScluster --nodepool-name nodepool1 -g myResourceGroup --machine-name aks-nodepool1-33555069-vmss000000 -o table
92105

93106
```
94-
The following example resembles output from the command:
107+
Sample output:
95108

96109
```output
97110
Name Ip
98111
--------------------------------- --------------------------
99112
aks-nodepool1-33555069-vmss000000 10.224.0.5,family:IPv4;
100113
```
101114

102-
2. Use the private IP to SSH into the node. [Azure Bastion][azure-bastion] also provides you with information for securely connecting to virtual machines via private IP address. Make sure that you configure an Azure Bastion host for the virtual network in which the VM resides.
115+
2. SSH using your private IP address to access your node.
103116

104117
```bash
105118
106119
```
107120

108-
## Create the SSH connection to a Windows node
121+
3. Optionally, you can test with Azure Bastion. Follow these steps to set up [Azure Bastion][azure-bastion] to test your connection to your virtual machines using a private IP address. Make sure that the Azure Bastion is hosted in the same virtual network as your VM.
109122

110-
At this time, you can't connect to a Windows Server node directly by using `kubectl debug`. Instead, you need to first connect to another node in the cluster, then connect to the Windows Server node from that node using SSH. Alternatively, you can [connect to Windows Server nodes using remote desktop protocol (RDP) connections][aks-windows-rdp] instead of using SSH or use SSH with 'machines API' presented at the start of this document.
123+
## Windows Server proxy connection
111124

112-
To connect to another node in the cluster, use the `kubectl debug` command. For more information, see the Linux section.
125+
Follow these steps as a workaround to connect with SSH on a Windows Server node.
113126

114-
To create the SSH connection to the Windows Server node from another node, use the SSH keys provided when you created the AKS cluster and the internal IP address of the Windows Server node.
127+
### Create a proxy server
128+
129+
At this time, you can't connect to a Windows Server node directly by using `kubectl debug`. Instead, you need to first connect to another node in the cluster with `kubectl`, then connect to the Windows Server node from that node using SSH. Alternatively, you can connect to Windows Server nodes using [remote desktop protocol (RDP) connections][aks-windows-rdp].
130+
131+
To connect to another node in the cluster, use the `kubectl debug` command. For more information, follow the above steps in the kubectl section. Create an SSH connection to the Windows Server node from another node, and use the SSH keys provided when you created the AKS cluster and the internal IP address of the Windows Server node.
115132

116133
> [!IMPORTANT]
117134
>
118-
> The following steps for creating the SSH connection to the Windows Server node from another node can only be used if you created your AKS cluster using the Azure CLI and the `--generate-ssh-keys` parameter. AKS Update command can also be used to manage, create SSH keys on an existing AKS cluster. For more information refer [Manage SSH configuration][manage-ssh-node-access].
135+
> The following steps for creating the SSH connection to the Windows Server node from another node can only be used if you created your AKS cluster using the Azure CLI and the `--generate-ssh-keys` parameter. The AKS Update command can also be used to manage, create SSH keys on an existing AKS cluster. For more information, see [manage SSH node access][manage-ssh-node-access].
136+
137+
Finish the prior steps to use kubectl debug, then return to this section, as you need to run the `kubectl debug` in your proxy.
119138

120139
1. Open a new terminal window and use the `kubectl get pods` command to get the name of the pod started by `kubectl debug`.
121140

122141
```bash
123142
kubectl get pods
124143
```
125144

126-
The following example resembles output from the command:
145+
Sample output:
127146

128147
```output
129148
NAME READY STATUS RESTARTS AGE
130149
node-debugger-aks-nodepool1-37663765-vmss000000-bkmmx 1/1 Running 0 21s
131150
```
132151

133-
In the previous example, *node-debugger-aks-nodepool1-37663765-vmss000000-bkmmx* is the name of the pod started by `kubectl debug`.
152+
In the sample output, *node-debugger-aks-nodepool1-37663765-vmss000000-bkmmx* is the name of the pod started by `kubectl debug`.
134153

135154
2. Use the `kubectl port-forward` command to open a connection to the deployed pod:
136155

137156
```bash
138157
kubectl port-forward node-debugger-aks-nodepool1-37663765-vmss000000-bkmmx 2022:22
139158
```
140159

141-
The following example resembles output from the command:
160+
Sample output:
142161

143162
```output
144163
Forwarding from 127.0.0.1:2022 -> 22
@@ -153,7 +172,7 @@ To create the SSH connection to the Windows Server node from another node, use t
153172
kubectl get no -o custom-columns=NAME:metadata.name,'INTERNAL_IP:status.addresses[?(@.type == \"InternalIP\")].address'
154173
```
155174

156-
The following example resembles output from the command:
175+
Sample output:
157176

158177
```output
159178
NAME INTERNAL_IP
@@ -168,19 +187,12 @@ To create the SSH connection to the Windows Server node from another node, use t
168187
ssh -o 'ProxyCommand ssh -p 2022 -W %h:%p [email protected]' [email protected]
169188
```
170189
171-
The following example resembles output from the command:
190+
Sample output:
172191
173192
```output
174193
The authenticity of host '10.224.0.62 (10.224.0.62)' can't be established.
175194
ECDSA key fingerprint is SHA256:1234567890abcdefghijklmnopqrstuvwxyzABCDEFG.
176195
Are you sure you want to continue connecting (yes/no)? yes
177-
178-
[...]
179-
180-
Microsoft Windows [Version 10.0.17763.1935]
181-
(c) 2018 Microsoft Corporation. All rights reserved.
182-
183-
azureuser@aksnpwin000000 C:\Users\azureuser>
184196
```
185197
186198
> [!NOTE]
@@ -192,18 +204,18 @@ To create the SSH connection to the Windows Server node from another node, use t
192204
193205
## Next steps
194206
195-
If you need more troubleshooting data, you can [view the kubelet logs][view-kubelet-logs] or [view the Kubernetes master node logs][view-master-logs].
207+
If you need more troubleshooting data, you can [view the kubelet logs][view-kubelet-logs] or [view the Kubernetes control plane logs][view-control-plane-logs].
196208
197-
See [Manage SSH configuration][manage-ssh-node-access] to learn about managing the SSH key on an AKS cluster or node pools.
209+
To learn about managing your SSH keys, see [Manage SSH configuration][manage-ssh-node-access].
198210
199211
<!-- INTERNAL LINKS -->
200212
[view-kubelet-logs]: kubelet-logs.md
201-
[view-master-logs]: monitor-aks-reference.md#resource-logs
213+
[view-control-plane-logs]: monitor-aks-reference.md#resource-logs
202214
[install-azure-cli]: /cli/azure/install-azure-cli
203215
[aks-windows-rdp]: rdp.md
204216
[azure-bastion]: ../bastion/bastion-overview.md
205217
[ssh-nix]: ../virtual-machines/linux/mac-create-ssh-keys.md
206218
[ssh-windows]: ../virtual-machines/linux/ssh-from-windows.md
207-
[agentpool-rest-api]: /rest/api/aks/agent-pools/get#agentpool
219+
[agent-pool-rest-api]: /rest/api/aks/agent-pools/get#agentpool
208220
[manage-ssh-node-access]: manage-ssh-node-access.md
209221

0 commit comments

Comments
 (0)