From 5120063ad4a0272580b241767de96652eebb78d2 Mon Sep 17 00:00:00 2001 From: Hunter Gregory Date: Tue, 21 Mar 2023 13:09:49 -0700 Subject: [PATCH 1/6] fix: [WIN-NPM] update PATH so we can use debugging tools via NPM --- npm/examples/windows/azure-npm.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/npm/examples/windows/azure-npm.yaml b/npm/examples/windows/azure-npm.yaml index a914e18927..b6206f6389 100644 --- a/npm/examples/windows/azure-npm.yaml +++ b/npm/examples/windows/azure-npm.yaml @@ -109,7 +109,7 @@ spec: - name: NPM_CONFIG value: .\\etc\\azure-npm\\azure-npm.json - name: PATH - value: '%CONTAINER_SANDBOX_MOUNT_POINT%\Windows\System32\WindowsPowershell\v1.0\' + value: '%CONTAINER_SANDBOX_MOUNT_POINT%\Windows\System32\WindowsPowershell\v1.0\;C:\Windows\System32\' volumeMounts: - name: azure-npm-config mountPath: .\\etc\\azure-npm From 1563283d854a5360dc9bc325b4524c324be6690c Mon Sep 17 00:00:00 2001 From: Hunter Gregory <42728408+huntergregory@users.noreply.github.com> Date: Wed, 22 Mar 2023 16:08:16 -0700 Subject: [PATCH 2/6] append to path instead of overwriting --- npm/examples/windows/azure-npm.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/npm/examples/windows/azure-npm.yaml b/npm/examples/windows/azure-npm.yaml index b6206f6389..49c0246a4b 100644 --- a/npm/examples/windows/azure-npm.yaml +++ b/npm/examples/windows/azure-npm.yaml @@ -109,7 +109,7 @@ spec: - name: NPM_CONFIG value: .\\etc\\azure-npm\\azure-npm.json - name: PATH - value: '%CONTAINER_SANDBOX_MOUNT_POINT%\Windows\System32\WindowsPowershell\v1.0\;C:\Windows\System32\' + value: '%PATH%;%CONTAINER_SANDBOX_MOUNT_POINT%\Windows\System32\WindowsPowershell\v1.0\;C:\Windows\System32\' volumeMounts: - name: azure-npm-config mountPath: .\\etc\\azure-npm From 9cf6611cbe120b69a0951980a2f3c346c9a7bc72 Mon Sep 17 00:00:00 2001 From: Hunter Gregory <42728408+huntergregory@users.noreply.github.com> Date: Thu, 23 Mar 2023 14:38:24 -0700 Subject: [PATCH 3/6] set original path --- npm/examples/windows/azure-npm.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/npm/examples/windows/azure-npm.yaml b/npm/examples/windows/azure-npm.yaml index 49c0246a4b..b052b17b9a 100644 --- a/npm/examples/windows/azure-npm.yaml +++ b/npm/examples/windows/azure-npm.yaml @@ -109,7 +109,7 @@ spec: - name: NPM_CONFIG value: .\\etc\\azure-npm\\azure-npm.json - name: PATH - value: '%PATH%;%CONTAINER_SANDBOX_MOUNT_POINT%\Windows\System32\WindowsPowershell\v1.0\;C:\Windows\System32\' + value: 'C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\dotnet\;c:\program files\containerd;C:\Windows\system32\config\systemprofile\AppData\Local\Microsoft\WindowsApps' volumeMounts: - name: azure-npm-config mountPath: .\\etc\\azure-npm From 0ea4e9ac3d287f7abb15a34a88beb87697fbbcdd Mon Sep 17 00:00:00 2001 From: Hunter Gregory <42728408+huntergregory@users.noreply.github.com> Date: Thu, 23 Mar 2023 14:52:15 -0700 Subject: [PATCH 4/6] Update azure-npm-capz.yaml --- npm/examples/windows/azure-npm-capz.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/npm/examples/windows/azure-npm-capz.yaml b/npm/examples/windows/azure-npm-capz.yaml index 18ce85e3bd..e22213090b 100644 --- a/npm/examples/windows/azure-npm-capz.yaml +++ b/npm/examples/windows/azure-npm-capz.yaml @@ -109,6 +109,8 @@ spec: fieldPath: spec.nodeName - name: NPM_CONFIG value: .\\etc\\azure-npm\\azure-npm.json + - name: PATH + value: 'C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\dotnet\;c:\program files\containerd;C:\Windows\system32\config\systemprofile\AppData\Local\Microsoft\WindowsApps' volumeMounts: - name: azure-npm-config mountPath: .\\etc\\azure-npm From f295f23397c052e18450ffdc2e947169e6230f7a Mon Sep 17 00:00:00 2001 From: Hunter Gregory <42728408+huntergregory@users.noreply.github.com> Date: Thu, 23 Mar 2023 15:26:09 -0700 Subject: [PATCH 5/6] add powershell to PATH in setkubeconfigpath.ps1 --- npm/examples/windows/setkubeconfigpath.ps1 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/npm/examples/windows/setkubeconfigpath.ps1 b/npm/examples/windows/setkubeconfigpath.ps1 index 38ec3440b2..72689f9c4a 100644 --- a/npm/examples/windows/setkubeconfigpath.ps1 +++ b/npm/examples/windows/setkubeconfigpath.ps1 @@ -1,3 +1,7 @@ +# add powershell.exe to the path +$pwshPath = "C:\" + $env:CONTAINER_SANDBOX_MOUNT_POINT + "\Windows\System32\WindowsPowershell\v1.0\" +$env:PATH += ";" + $pwshPath + # pull the server value from the kubeconfig on host to construct our own kubeconfig, but using service principal settings # this is required to build a kubeconfig using the kubeconfig on disk in c:\k, and the service principle granted in the container mount, to generate clientset $cpEndpoint = Get-Content C:\k\config | ForEach-Object -Process {if($_.Contains("server:")) {$_.Trim().Split()[1]}} From e6726212ea3e78e8c8b67fbe70cca56ceb7ea06b Mon Sep 17 00:00:00 2001 From: Hunter Gregory Date: Thu, 23 Mar 2023 16:28:18 -0700 Subject: [PATCH 6/6] remove pwsh call and undo path updates and change to setkubeconfig.ps1 --- npm/examples/windows/azure-npm-capz.yaml | 3 --- npm/examples/windows/azure-npm.yaml | 3 --- npm/examples/windows/setkubeconfigpath.ps1 | 4 ---- 3 files changed, 10 deletions(-) diff --git a/npm/examples/windows/azure-npm-capz.yaml b/npm/examples/windows/azure-npm-capz.yaml index e22213090b..42df3d6681 100644 --- a/npm/examples/windows/azure-npm-capz.yaml +++ b/npm/examples/windows/azure-npm-capz.yaml @@ -90,7 +90,6 @@ spec: [ '.\setkubeconfigpath-capz.ps1', ";", - "powershell.exe", '.\npm.exe', "start", '--kubeconfig=.\kubeconfig', @@ -109,8 +108,6 @@ spec: fieldPath: spec.nodeName - name: NPM_CONFIG value: .\\etc\\azure-npm\\azure-npm.json - - name: PATH - value: 'C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\dotnet\;c:\program files\containerd;C:\Windows\system32\config\systemprofile\AppData\Local\Microsoft\WindowsApps' volumeMounts: - name: azure-npm-config mountPath: .\\etc\\azure-npm diff --git a/npm/examples/windows/azure-npm.yaml b/npm/examples/windows/azure-npm.yaml index b052b17b9a..5aa04b1c65 100644 --- a/npm/examples/windows/azure-npm.yaml +++ b/npm/examples/windows/azure-npm.yaml @@ -89,7 +89,6 @@ spec: [ '.\setkubeconfigpath.ps1', ";", - "powershell.exe", '.\npm.exe', "start", '--kubeconfig=.\kubeconfig', @@ -108,8 +107,6 @@ spec: fieldPath: spec.nodeName - name: NPM_CONFIG value: .\\etc\\azure-npm\\azure-npm.json - - name: PATH - value: 'C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\dotnet\;c:\program files\containerd;C:\Windows\system32\config\systemprofile\AppData\Local\Microsoft\WindowsApps' volumeMounts: - name: azure-npm-config mountPath: .\\etc\\azure-npm diff --git a/npm/examples/windows/setkubeconfigpath.ps1 b/npm/examples/windows/setkubeconfigpath.ps1 index 72689f9c4a..38ec3440b2 100644 --- a/npm/examples/windows/setkubeconfigpath.ps1 +++ b/npm/examples/windows/setkubeconfigpath.ps1 @@ -1,7 +1,3 @@ -# add powershell.exe to the path -$pwshPath = "C:\" + $env:CONTAINER_SANDBOX_MOUNT_POINT + "\Windows\System32\WindowsPowershell\v1.0\" -$env:PATH += ";" + $pwshPath - # pull the server value from the kubeconfig on host to construct our own kubeconfig, but using service principal settings # this is required to build a kubeconfig using the kubeconfig on disk in c:\k, and the service principle granted in the container mount, to generate clientset $cpEndpoint = Get-Content C:\k\config | ForEach-Object -Process {if($_.Contains("server:")) {$_.Trim().Split()[1]}}