MinikubeWindowsContainers
MinikubeWindowsContainers copied to clipboard
Author script to enable powershell remote for Windows Node
To test this PR you require a windows VM running Windows Server 2022. I've shared a quick guide to setup such a VM at the last bit.
Here's how you test this work:
- Open a PowerShell Window as Administator .
- Navigate to the automation directory
cd automation
- Run the following command
.\SetUp.ps1 -ISOFilePath "YourISOFilePath" -VMName "minikube-ws22" -UserName "Administrator" -Pass "Minikube@2024"
Replace 'YourISOFilePath'
, with the actual values.
There is an optional parameter, $KubernetesVersion which you can pass or the latest Kubernetes version will be used for your configuration
You should expect the following output
Clean Up Steps
kubectl get nodes
kubectl drain minikube-ws22 --ignore-daemonsets --delete-local-data
kubectl delete node minikube-ws22
minikube delete --all
$VMName = 'minikube-ws22'
Stop-VM -Name $VMName -TurnOff
Remove-VM -Name $VMName -Force
Remove-Item -Path ${env:homepath}\.minikube\machines\$VMName -Force -Recurse
Thanks for the contributions @bobsira. Let me know when this PR is ready for review.
Thanks for the contributions @bobsira. Let me know when this PR is ready for review.
This work is ready for review!
I got multiple errors trying this. Here's what I did:
- Followed the process to create the MiniKube cluster as per original instructions.
- Created the VM manually but stopped after setting up the password inside the VM.
- Tried the "run" command as per instructions and got the following:
PS C:\GitHub\MinikubeWindowsContainers-user-bosira-remote-powershell-script\automation> Run -VMName 'minikube-m03' -UserName 'Administrator' -Pass 'Pa$$w0rd'
The specified module 'C:\Users\Administrator\Documents\MinikubeWindowsContainers\automation\ContainerdTools.psm1' was not loaded because no valid module file was found in any module directory.
+ CategoryInfo : ResourceUnavailable: (C:\Users\Admini...inerdTools.psm1:String) [Import-Module], FileNotFoundException
+ FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
+ PSComputerName : minikube-m03
The specified module 'C:\Users\Administrator\Documents\MinikubeWindowsContainers\automation\k8Tools.psm1' was not loaded because no valid module file was found in any module directory.
+ CategoryInfo : ResourceUnavailable: (C:\Users\Admini...on\k8Tools.psm1:String) [Import-Module], FileNotFoundException
+ FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
+ PSComputerName : minikube-m03
The specified module 'C:\Users\Administrator\Documents\MinikubeWindowsContainers\automation\MinikubeTools.psm1' was not loaded because no valid module file was found in any module directory.
+ CategoryInfo : ResourceUnavailable: (C:\Users\Admini...ikubeTools.psm1:String) [Import-Module], FileNotFoundException
+ FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
+ PSComputerName : minikube-m03
The specified module 'C:\Users\Administrator\Documents\MinikubeWindowsContainers\automation\NSSMTools.psm1' was not loaded because no valid module file was found in any module directory.
+ CategoryInfo : ResourceUnavailable: (C:\Users\Admini...\NSSMTools.psm1:String) [Import-Module], FileNotFoundException
+ FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
+ PSComputerName : minikube-m03
The term 'C:\Users\Administrator\Documents\MinikubeWindowsContainers\automation\InitNode.ps1' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the
name, or if a path was included, verify that the path is correct and try again.
+ CategoryInfo : ObjectNotFound: (C:\Users\Admini...on\InitNode.ps1:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
+ PSComputerName : minikube-m03
W0110 16:45:29.669506 110584 main.go:291] Unable to resolve the current Docker CLI context "default": context "default": context not found: open C:\Users\viniap\.docker\contexts\meta\37a8eec1ce19687d132fe29051dca629d164e2c4958ba141d5f4133a33f0688f\meta.json: The system cannot find the path specified.
The specified module 'C:\Users\Administrator\Documents\MinikubeWindowsContainers\automation\MinikubeTools.psm1' was not loaded because no valid module file was found in any module directory.
+ CategoryInfo : ResourceUnavailable: (C:\Users\Admini...ikubeTools.psm1:String) [Import-Module], FileNotFoundException
+ FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
+ PSComputerName : minikube-m03
The term 'Add-Host' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try
again.
+ CategoryInfo : ObjectNotFound: (Add-Host:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
+ PSComputerName : minikube-m03
W0110 16:45:34.683380 81500 main.go:291] Unable to resolve the current Docker CLI context "default": context "default": context not found: open C:\Users\viniap\.docker\contexts\meta\37a8eec1ce19687d132fe29051dca629d164e2c4958ba141d5f4133a33f0688f\meta.json: The system cannot find the path specified.
ssh: Process exited with status 1
bash: line 0: cd: /var/lib/minikube/binaries/v1.27.3/: No such file or directory --cri-socket "npipe:////./pipe/containerd-containerd" --v=5
The specified module 'C:\Users\Administrator\Documents\MinikubeWindowsContainers\automation\MinikubeTools.psm1' was not loaded because no valid module file was found in any module directory.
+ CategoryInfo : ResourceUnavailable: (C:\Users\Admini...ikubeTools.psm1:String) [Import-Module], FileNotFoundException
+ FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
+ PSComputerName : minikube-m03
The specified module 'C:\Users\Administrator\Documents\MinikubeWindowsContainers\automation\k8Tools.psm1' was not loaded because no valid module file was found in any module directory.
+ CategoryInfo : ResourceUnavailable: (C:\Users\Admini...on\k8Tools.psm1:String) [Import-Module], FileNotFoundException
+ FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
+ PSComputerName : minikube-m03
The term 'Get-Kubeadm' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and
try again.
+ CategoryInfo : ObjectNotFound: (Get-Kubeadm:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
+ PSComputerName : minikube-m03
The term 'bash:' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try
again.
+ CategoryInfo : ObjectNotFound: (bash::String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
+ PSComputerName : minikube-m03
The term 'Set-MinikubeFolderError' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is
correct and try again.
+ CategoryInfo : ObjectNotFound: (Set-MinikubeFolderError:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
+ PSComputerName : minikube-m03
The term 'bash:' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try
again.
+ CategoryInfo : ObjectNotFound: (bash::String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
+ PSComputerName : minikube-m03
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
minikube Ready control-plane 59m v1.27.4 192.168.0.253 <none> Buildroot 2021.02.12 5.10.57 containerd://1.7.2
minikube-m02 Ready <none> 57m v1.27.4 192.168.0.2 <none> Buildroot 2021.02.12 5.10.57 containerd://1.7.2
It seems multiple modules were not loaded into the PS session. Trying to troubleshoot the above now.
I got multiple errors trying this. Here's what I did:
- Followed the process to create the MiniKube cluster as per original instructions.
- Created the VM manually but stopped after setting up the password inside the VM.
- Tried the "run" command as per instructions and got the following:
PS C:\GitHub\MinikubeWindowsContainers-user-bosira-remote-powershell-script\automation> Run -VMName 'minikube-m03' -UserName 'Administrator' -Pass 'Pa$$w0rd' The specified module 'C:\Users\Administrator\Documents\MinikubeWindowsContainers\automation\ContainerdTools.psm1' was not loaded because no valid module file was found in any module directory. + CategoryInfo : ResourceUnavailable: (C:\Users\Admini...inerdTools.psm1:String) [Import-Module], FileNotFoundException + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand + PSComputerName : minikube-m03 The specified module 'C:\Users\Administrator\Documents\MinikubeWindowsContainers\automation\k8Tools.psm1' was not loaded because no valid module file was found in any module directory. + CategoryInfo : ResourceUnavailable: (C:\Users\Admini...on\k8Tools.psm1:String) [Import-Module], FileNotFoundException + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand + PSComputerName : minikube-m03 The specified module 'C:\Users\Administrator\Documents\MinikubeWindowsContainers\automation\MinikubeTools.psm1' was not loaded because no valid module file was found in any module directory. + CategoryInfo : ResourceUnavailable: (C:\Users\Admini...ikubeTools.psm1:String) [Import-Module], FileNotFoundException + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand + PSComputerName : minikube-m03 The specified module 'C:\Users\Administrator\Documents\MinikubeWindowsContainers\automation\NSSMTools.psm1' was not loaded because no valid module file was found in any module directory. + CategoryInfo : ResourceUnavailable: (C:\Users\Admini...\NSSMTools.psm1:String) [Import-Module], FileNotFoundException + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand + PSComputerName : minikube-m03 The term 'C:\Users\Administrator\Documents\MinikubeWindowsContainers\automation\InitNode.ps1' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. + CategoryInfo : ObjectNotFound: (C:\Users\Admini...on\InitNode.ps1:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException + PSComputerName : minikube-m03 W0110 16:45:29.669506 110584 main.go:291] Unable to resolve the current Docker CLI context "default": context "default": context not found: open C:\Users\viniap\.docker\contexts\meta\37a8eec1ce19687d132fe29051dca629d164e2c4958ba141d5f4133a33f0688f\meta.json: The system cannot find the path specified. The specified module 'C:\Users\Administrator\Documents\MinikubeWindowsContainers\automation\MinikubeTools.psm1' was not loaded because no valid module file was found in any module directory. + CategoryInfo : ResourceUnavailable: (C:\Users\Admini...ikubeTools.psm1:String) [Import-Module], FileNotFoundException + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand + PSComputerName : minikube-m03 The term 'Add-Host' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. + CategoryInfo : ObjectNotFound: (Add-Host:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException + PSComputerName : minikube-m03 W0110 16:45:34.683380 81500 main.go:291] Unable to resolve the current Docker CLI context "default": context "default": context not found: open C:\Users\viniap\.docker\contexts\meta\37a8eec1ce19687d132fe29051dca629d164e2c4958ba141d5f4133a33f0688f\meta.json: The system cannot find the path specified. ssh: Process exited with status 1 bash: line 0: cd: /var/lib/minikube/binaries/v1.27.3/: No such file or directory --cri-socket "npipe:////./pipe/containerd-containerd" --v=5 The specified module 'C:\Users\Administrator\Documents\MinikubeWindowsContainers\automation\MinikubeTools.psm1' was not loaded because no valid module file was found in any module directory. + CategoryInfo : ResourceUnavailable: (C:\Users\Admini...ikubeTools.psm1:String) [Import-Module], FileNotFoundException + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand + PSComputerName : minikube-m03 The specified module 'C:\Users\Administrator\Documents\MinikubeWindowsContainers\automation\k8Tools.psm1' was not loaded because no valid module file was found in any module directory. + CategoryInfo : ResourceUnavailable: (C:\Users\Admini...on\k8Tools.psm1:String) [Import-Module], FileNotFoundException + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand + PSComputerName : minikube-m03 The term 'Get-Kubeadm' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. + CategoryInfo : ObjectNotFound: (Get-Kubeadm:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException + PSComputerName : minikube-m03 The term 'bash:' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. + CategoryInfo : ObjectNotFound: (bash::String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException + PSComputerName : minikube-m03 The term 'Set-MinikubeFolderError' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. + CategoryInfo : ObjectNotFound: (Set-MinikubeFolderError:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException + PSComputerName : minikube-m03 The term 'bash:' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. + CategoryInfo : ObjectNotFound: (bash::String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException + PSComputerName : minikube-m03 NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME minikube Ready control-plane 59m v1.27.4 192.168.0.253 <none> Buildroot 2021.02.12 5.10.57 containerd://1.7.2 minikube-m02 Ready <none> 57m v1.27.4 192.168.0.2 <none> Buildroot 2021.02.12 5.10.57 containerd://1.7.2
@vrapolinario run the following command first ---> . .\Run.ps1
then go ahead and run Run -VMName 'minikube-m03' -UserName 'Administrator' -Pass 'Pa$$w0rd'
this should fix your issue
@bobsira I did. It asked to run each of the modules. That error us even when running that command prior.
Trying to look into your error messages to see I can I can spot what your are missing. Just one last bit after creating the VM manually and after setting up the password inside the VM also do have the following bit from the original docs before you can the execute the run command
Set-SConfig -AutoLaunch $false
Rename-Computer -NewName minikube-m03
Install-WindowsFeature -Name containers
Restart-Computer -Force