Skip to content

Commit 2594f71

Browse files
Merge pull request #267382 from AbelHu/abelch/update-win-hpc-example
{AKS} update Windows host process containers
2 parents e670b9f + 282a4ae commit 2594f71

File tree

2 files changed

+64
-18
lines changed

2 files changed

+64
-18
lines changed

articles/aks/node-access.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,56 @@ To connect to another node in the cluster, use the `kubectl debug` command. For
172172
> ssh -o 'ProxyCommand ssh -p 2022 -W %h:%p [email protected]' -o PreferredAuthentications=password [email protected]
173173
> ```
174174
175+
## Use Host Process Container to access Windows node
176+
177+
1. Create `hostprocess.yaml` with the following content and replacing `AKSWINDOWSNODENAME` with the AKS Windows node name.
178+
179+
```yaml
180+
apiVersion: v1
181+
kind: Pod
182+
metadata:
183+
labels:
184+
pod: hpc
185+
name: hpc
186+
spec:
187+
securityContext:
188+
windowsOptions:
189+
hostProcess: true
190+
runAsUserName: "NT AUTHORITY\\SYSTEM"
191+
hostNetwork: true
192+
containers:
193+
- name: hpc
194+
image: mcr.microsoft.com/windows/servercore:ltsc2022 # Use servercore:1809 for WS2019
195+
command:
196+
- powershell.exe
197+
- -Command
198+
- "Start-Sleep 2147483"
199+
imagePullPolicy: IfNotPresent
200+
nodeSelector:
201+
kubernetes.io/os: windows
202+
kubernetes.io/hostname: AKSWINDOWSNODENAME
203+
tolerations:
204+
- effect: NoSchedule
205+
key: node.kubernetes.io/unschedulable
206+
operator: Exists
207+
- effect: NoSchedule
208+
key: node.kubernetes.io/network-unavailable
209+
operator: Exists
210+
- effect: NoExecute
211+
key: node.kubernetes.io/unreachable
212+
operator: Exists
213+
```
214+
215+
2. Run `kubectl apply -f hostprocess.yaml` to deploy the Windows host process container (HPC) in the specified Windows node.
216+
217+
3. Use `kubectl exec -it [HPC-POD-NAME] -- powershell`.
218+
219+
4. You can run any PowerShell commands inside the HPC container to access the Windows node.
220+
221+
> [!Note]
222+
>
223+
> You need to switch the root folder to `C:\` inside the HPC container to access the files in the Windows node.
224+
175225
## SSH using Azure Bastion for Windows
176226
177227
If your Linux proxy node isn't reachable, using Azure Bastion as a proxy is an alternative. This method requires that you set up an Azure Bastion host for the virtual network in which the cluster resides. See [Connect with Azure Bastion][azure-bastion] for more details.

articles/aks/use-windows-hpc.md

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,12 @@ To use HostProcess features with your deployment, set *hostProcess: true* and *h
3232
```yaml
3333
spec:
3434
...
35-
containers:
36-
...
37-
securityContext:
38-
windowsOptions:
39-
hostProcess: true
40-
...
35+
securityContext:
36+
windowsOptions:
37+
hostProcess: true
38+
...
4139
hostNetwork: true
40+
containers:
4241
...
4342
```
4443

@@ -63,21 +62,18 @@ spec:
6362
spec:
6463
nodeSelector:
6564
kubernetes.io/os: windows
65+
securityContext:
66+
windowsOptions:
67+
hostProcess: true
68+
runAsUserName: "NT AUTHORITY\\SYSTEM"
69+
hostNetwork: true
6670
containers:
6771
- name: powershell
68-
image: mcr.microsoft.com/powershell:lts-nanoserver-1809
69-
securityContext:
70-
windowsOptions:
71-
hostProcess: true
72-
runAsUserName: "NT AUTHORITY\\SYSTEM"
72+
image: mcr.microsoft.com/powershell:lts-nanoserver-1809 # or lts-nanoserver-ltsc2022
7373
command:
74-
- C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
75-
- -command
76-
- |
77-
$AdminRights = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]"Administrator")
78-
Write-Host "Process has admin rights: $AdminRights"
79-
while ($true) { Start-Sleep -Seconds 2147483 }
80-
hostNetwork: true
74+
- powershell.exe
75+
- -Command
76+
- Start-Sleep -Seconds 2147483
8177
terminationGracePeriodSeconds: 0
8278
```
8379

0 commit comments

Comments
 (0)