From 8cf82570d5649273fc8401c9447f5db305232e5e Mon Sep 17 00:00:00 2001 From: bosira Date: Thu, 12 Oct 2023 01:27:23 +0100 Subject: [PATCH 01/52] initial commit --- automation/Remote.ps1 | 254 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 254 insertions(+) create mode 100644 automation/Remote.ps1 diff --git a/automation/Remote.ps1 b/automation/Remote.ps1 new file mode 100644 index 0000000..463656a --- /dev/null +++ b/automation/Remote.ps1 @@ -0,0 +1,254 @@ +function Start-VirtualMachine { + param ( + [String] + [ValidateNotNullOrEmpty()] + $VMName, + + [String] + [ValidateNotNullOrEmpty()] + $SwitchName, + + [String] + [ValidateNotNullOrEmpty()] + $ISOFile + ) + + New-VM -Name $VMName -Generation 1 -MemoryStartupBytes 6000MB -Path ${env:homepath}\.minikube\machines\ -NewVHDPath ${env:homepath}\.minikube\machines\$VMName\VHD.vhdx -NewVHDSizeBytes 127000MB -SwitchName $SwitchName + Set-VM -Name $VMName -ProcessorCount 2 -AutomaticCheckpointsEnabled $false + Set-VMProcessor -VMName $VMName -ExposeVirtualizationExtensions $true + Set-VMDvdDrive -VMName $VMName -Path $ISOFile + Start-VM -Name $VMName +} + +# $VMName = 'minikube-m03'; +# $UserName = 'Administrator'; +# $Password = 'M@kindu.2021'; +function Set-Credential { + param ( + [String] + [ValidateNotNullOrEmpty()] + $VMName, + + [String] + [ValidateNotNullOrEmpty()] + $UserName, + + [String] + [ValidateNotNullOrEmpty()] + $Pass + ) + + $SecurePassword = ConvertTo-SecureString -String $Password -AsPlainText -Force; + $Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $Username, $SecurePassword ; + + return $Credential + +} + +function Install-Containerd { + param( + [string] + [ValidateNotNullOrEmpty()] + [parameter(HelpMessage = "ContainerD version to use. Default 1.7.6")] + $Version = "1.7.6", + + [String] + [parameter(HelpMessage = "Path to install containerd. Defaults to ~\program files\containerd")] + $InstallPath = "$Env:ProgramFiles\containerd", + + [String] + [parameter(HelpMessage = "Path to download files. Defaults to user's Downloads folder")] + $DownloadPath = ".\bin\" + ) + + $Version = $Version.TrimStart('v') + $EnvPath = "$InstallPath\bin" + + $containerdTarFile = "containerd-${version}-windows-amd64.tar.gz" + $Uri = "https://github.com/containerd/containerd/releases/download/v$version/$($containerdTarFile)" + $params = @{ + Feature = "containerd" + Version = $Version + Uri = $Uri + InstallPath = $InstallPath + DownloadPath = "$DownloadPath\$containerdTarFile" + EnvPath = $EnvPath + cleanup = $true + } + + Write-Output "Downloading and installing Containerd at $InstallPath" + Invoke-WebRequest -Uri $Uri -OutFile $DownloadPath\$containerdTarFile -Verbose + Install-RequiredFeature @params + + Write-Output "Containerd successfully installed at $InstallPath" + containerd.exe -v + + Write-Output "For containerd usage: run 'containerd -h'" +} + +function Start-ContainerdService { + Set-Service containerd -StartupType Automatic + try { + Start-Service containerd -Force + + # Waiting for containerd to come to steady state + (Get-Service containerd -ErrorAction SilentlyContinue).WaitForStatus('Running', '00:00:30') + } + catch { + Throw "Couldn't start Containerd service. $_" + } +} + +function Initialize-ContainerdService { + param( + [string] + [parameter(HelpMessage = "Containerd path")] + $ContainerdPath = "$Env:ProgramFiles\containerd" + ) + + Write-Output "Configuring the containerd service" + + #Configure containerd service + $containerdConfigFile = "$ContainerdPath\config.toml" + $containerdDefault = containerd.exe config default + $containerdDefault | Out-File $ContainerdPath\config.toml -Encoding ascii + Write-Information -InformationAction Continue -MessageData "Review containerd configutations at $containerdConfigFile" + + Add-MpPreference -ExclusionProcess "$ContainerdPath\containerd.exe" + + # Review the configuration. Depending on setup you may want to adjust: + # - the sandbox_image (Kubernetes pause image) + # - cni bin_dir and conf_dir locations + # Get-Content $containerdConfigFile + # TODO: Complete the script make the following changes in the .toml file + # + # Setting Old value New Value + # bin_dir "C:\\Program Files\\containerd\\cni\\bin" "c:\\opt\\cni\\bin" + # conf_dir "C:\\Program Files\\containerd\\cni\\conf" "c:\\etc\\cni\\net.d\\" + + # Register containerd service + Add-FeatureToPath -Feature "containerd" -Path "$ContainerdPath\bin" + containerd.exe --register-service --log-level debug --service-name containerd --log-file "$env:TEMP\containerd.log" + if ($LASTEXITCODE -gt 0) { + Throw "Failed to register containerd service. $_" + } + + Write-Output "Containerd service" + Get-Service *containerd* | Select-Object Name, DisplayName, ServiceName, ServiceType, StartupType, Status, RequiredServices, ServicesDependedOn +} + +function Install-NSSM { + param( + [string] + [ValidateNotNullOrEmpty()] + [parameter(HelpMessage = "NSSM version to use. Default 2.24")] + $Version = "2.24", + + [String] + [parameter(HelpMessage = "Architecture ")] + $Arch = "win64", + + [String] + [parameter(HelpMessage = "Path to download files.")] + $DownloadPath = "c:\k" + ) + + $Version = $Version.TrimStart('v') + + $nssmTarFile = "nssm-${version}.zip" + $Uri = "https://k8stestinfrabinaries.blob.core.windows.net/nssm-mirror/$($nssmTarFile)" + $params = @{ + Feature = "nssm" + Version = $Version + Uri = $Uri + InstallPath = $InstallPath + DownloadPath = "$DownloadPath\$containerdTarFile" + EnvPath = $EnvPath + cleanup = $true + } + + Write-Output "Downloading and installing Containerd at $InstallPath" + Invoke-WebRequest -Uri $Uri -OutFile $DownloadPath\$containerdTarFile -Verbose + Install-RequiredFeature @params + + Write-Output "Containerd successfully installed at $InstallPath" + containerd.exe -v + + Write-Output "For containerd usage: run 'containerd -h'" +} + + +function Install-Kubelet { + param ( + [string] + [ValidateNotNullOrEmpty()] + $KubernetesVersion = "v1.27.3" + ) + + # Define the URL for kubelet download + $KubeletUrl = "https://dl.k8s.io/$KubernetesVersion/bin/windows/amd64/kubelet.exe" + + # Download kubelet + Invoke-WebRequest -Uri $KubeletUrl -OutFile "c:\k\kubelet.exe" + + # Create the Start-kubelet.ps1 script + @" +`$FileContent = Get-Content -Path "/var/lib/kubelet/kubeadm-flags.env" +`$kubeAdmArgs = `$FileContent.TrimStart(`'KUBELET_KUBEADM_ARGS=`').Trim(`'"`') + +`$args = "--cert-dir=`$env:SYSTEMDRIVE/var/lib/kubelet/pki", + "--config=`$env:SYSTEMDRIVE/var/lib/kubelet/config.yaml", + "--bootstrap-kubeconfig=`$env:SYSTEMDRIVE/etc/kubernetes/bootstrap-kubelet.conf", + "--kubeconfig=`$env:SYSTEMDRIVE/etc/kubernetes/kubelet.conf", + "--hostname-override=`$(hostname)", + "--enable-debugging-handlers", + "--cgroups-per-qos=false", + "--enforce-node-allocatable=``"``"", + "--resolv-conf=``"``"" + +`$kubeletCommandLine = "c:\k\kubelet.exe " + (`$args -join " ") + " `$kubeAdmArgs" +Invoke-Expression `$kubeletCommandLine +"@ | Set-Content -Path "c:\k\Start-kubelet.ps1" + + # Install kubelet as a Windows service + "c:\k\nssm.exe install kubelet Powershell -ExecutionPolicy Bypass -NoProfile c:\k\Start-kubelet.ps1" + "c:\k\nssm.exe set Kubelet AppStdout C:\k\kubelet.log" + "c:\k\nssm.exe set Kubelet AppStderr C:\k\kubelet.err.log" +} + + +# Example usage: Install-Kubelet -KubernetesVersion "v1.27.3" + + +function Enable-FireWall-Ports { + New-NetFirewallRule -Name kubelet -DisplayName 'kubelet' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 10250 + +} + + +function Start-RemoteSession { + param ( + [String] + [ValidateNotNullOrEmpty()] + $VMName, + + [PSCredential] + [ValidateNotNullOrEmpty()] + $Credential + ) + + Enter-PSSession -VMName $VMName -Credential $Credential; +} + +function Remove-VirtualMachine { + param ( + [String] + [ValidateNotNullOrEmpty()] + $VMName + ) + + Stop-VM -Name $VMName -TurnOff + Remove-VM -Name $VMName -Force + Remove-Item -Path ${env:homepath}\.minikube\machines\$VMName -Force -Recurse + +} \ No newline at end of file From 8a1ce2a1bf54bd35f089dc0c84de6a48b110bfc7 Mon Sep 17 00:00:00 2001 From: bosira Date: Tue, 24 Oct 2023 02:23:26 +0100 Subject: [PATCH 02/52] intial refactoring and seperation of concerns --- automation/ContainerdTools.psm1 | 142 ++++++++++++++++++++++++++ automation/NSSMTools.psm1 | 39 ++++++++ automation/Remote.ps1 | 170 ++------------------------------ automation/SetUpUtilities.psm1 | 11 +++ automation/k8Tools.psm1 | 40 ++++++++ 5 files changed, 241 insertions(+), 161 deletions(-) create mode 100644 automation/ContainerdTools.psm1 create mode 100644 automation/NSSMTools.psm1 create mode 100644 automation/SetUpUtilities.psm1 create mode 100644 automation/k8Tools.psm1 diff --git a/automation/ContainerdTools.psm1 b/automation/ContainerdTools.psm1 new file mode 100644 index 0000000..453d397 --- /dev/null +++ b/automation/ContainerdTools.psm1 @@ -0,0 +1,142 @@ +function Get-ContainerdLatestVersion { + $latestVersion = Get-LatestToolVersion -Repository "containerd/containerd" + return $latestVersion +} + +function Install-Containerd { + param( + [string] + [ValidateNotNullOrEmpty()] + [parameter(HelpMessage = "ContainerD version to use. Default 1.7.6")] + $Version, + + [String] + [parameter(HelpMessage = "Path to install containerd. Defaults to ~\program files\containerd")] + $InstallPath = "$Env:ProgramFiles\containerd", + + [String] + [parameter(HelpMessage = "Path to download files. Defaults to user's Downloads folder")] + $DownloadPath = ".\bin\" + ) + + if(!$Version) { + # Get default version + $Version = Get-ContainerdLatestVersion + } + $Version = $Version.TrimStart('v') + Write-Output "Downloading and installing Containerd v$version at $InstallPath" + + $EnvPath = "$InstallPath\bin" + + # Download file from repo + $containerdTarFile = "containerd-${version}-windows-amd64.tar.gz" + try { + $Uri = "https://github.com/containerd/containerd/releases/download/v$version/$($containerdTarFile)" + Invoke-WebRequest -Uri $Uri -OutFile $DownloadPath\$containerdTarFile -Verbose + } + catch { + if ($_.ErrorDetails.Message -eq "Not found") { + Throw "Containerd download failed. Invalid URL: $uri" + } + + Throw "Containerd download failed. $_" + } + + + # Untar and install tool + $params = @{ + Feature = "containerd" + InstallPath = $InstallPath + DownloadPath = "$DownloadPath\$containerdTarFile" + EnvPath = $EnvPath + cleanup = $true + } + + + Install-RequiredFeature @params + + Write-Output "Containerd v$version successfully installed at $InstallPath" + containerd.exe -v + + Write-Output "For containerd usage: run 'containerd -h'" +} + +function Start-ContainerdService { + Set-Service containerd -StartupType Automatic + try { + Start-Service containerd -Force + + # Waiting for containerd to come to steady state + (Get-Service containerd -ErrorAction SilentlyContinue).WaitForStatus('Running', '00:00:30') + } + catch { + Throw "Couldn't start Containerd service. $_" + } +} + +function Initialize-ContainerdService { + param( + [string] + [parameter(HelpMessage = "Containerd path")] + $ContainerdPath = "$Env:ProgramFiles\containerd" + ) + + Write-Output "Configuring the containerd service" + + #Configure containerd service + $containerdConfigFile = "$ContainerdPath\config.toml" + $containerdDefault = containerd.exe config default + $containerdDefault | Out-File $ContainerdPath\config.toml -Encoding ascii + Write-Information -InformationAction Continue -MessageData "Review containerd configutations at $containerdConfigFile" + + Add-MpPreference -ExclusionProcess "$ContainerdPath\containerd.exe" + + # Review the configuration. Depending on setup you may want to adjust: + # - the sandbox_image (Kubernetes pause image) + # - cni bin_dir and conf_dir locations + + + # Setting Old value New Value + # bin_dir "C:\\Program Files\\containerd\\cni\\bin" "c:\\opt\\cni\\bin" + # conf_dir "C:\\Program Files\\containerd\\cni\\conf" "c:\\etc\\cni\\net.d\\" + + # Read the content of the config.toml file + $containerdConfigContent = Get-Content -Path $containerdConfigFile -Raw + + # Define the replacements + $replacements = @( + @{ + Find = 'bin_dir = "C:\\Program Files\\containerd\\cni\\bin"' + Replace = 'bin_dir = "c:\\opt\\cni\\bin"' + }, + @{ + Find = 'conf_dir = "C:\\Program Files\\containerd\\cni\\conf"' + Replace = 'conf_dir = "c:\\etc\\cni\\net.d\\"' + } + ) + + # Perform the replacements + foreach ($replacement in $replacements) { + $containerdConfigContent = $containerdConfigContent -replace [regex]::Escape($replacement.Find), $replacement.Replace + } + + # Save the modified content back to the config.toml file + Set-Content -Path $containerdConfigFile -Value $containerdConfigContent + + # Output a message indicating the changes + Write-Host "Changes applied to $containerdConfigFile" + + # Create the folders above + mkdir c:\opt\cni\bin + mkdir c:\etc\cni\net.d + + # Register containerd service + Add-FeatureToPath -Feature "containerd" -Path "$ContainerdPath\bin" + containerd.exe --register-service --log-level debug --service-name containerd --log-file "$env:TEMP\containerd.log" + if ($LASTEXITCODE -gt 0) { + Throw "Failed to register containerd service. $_" + } + + Write-Output "Containerd service" + Get-Service *containerd* | Select-Object Name, DisplayName, ServiceName, ServiceType, StartupType, Status, RequiredServices, ServicesDependedOn +} \ No newline at end of file diff --git a/automation/NSSMTools.psm1 b/automation/NSSMTools.psm1 new file mode 100644 index 0000000..32a7dde --- /dev/null +++ b/automation/NSSMTools.psm1 @@ -0,0 +1,39 @@ +function Install-NSSM { + param( + [string] + [ValidateNotNullOrEmpty()] + [parameter(HelpMessage = "NSSM version to use. Default 2.24")] + $Version = "2.24", + + [String] + [parameter(HelpMessage = "Architecture ")] + $Arch = "win64", + + [String] + [parameter(HelpMessage = "Path to download files.")] + $DownloadPath = "c:\k" + ) + + $Version = $Version.TrimStart('v') + + $nssmTarFile = "nssm-${version}.zip" + $Uri = "https://k8stestinfrabinaries.blob.core.windows.net/nssm-mirror/$($nssmTarFile)" + $params = @{ + Feature = "nssm" + Version = $Version + Uri = $Uri + InstallPath = $InstallPath + DownloadPath = "$DownloadPath\$containerdTarFile" + EnvPath = $EnvPath + cleanup = $true + } + + Write-Output "Downloading and installing Containerd at $InstallPath" + Invoke-WebRequest -Uri $Uri -OutFile $DownloadPath\$containerdTarFile -Verbose + Install-RequiredFeature @params + + Write-Output "Containerd successfully installed at $InstallPath" + containerd.exe -v + + Write-Output "For containerd usage: run 'containerd -h'" +} \ No newline at end of file diff --git a/automation/Remote.ps1 b/automation/Remote.ps1 index 463656a..5e71923 100644 --- a/automation/Remote.ps1 +++ b/automation/Remote.ps1 @@ -13,7 +13,7 @@ function Start-VirtualMachine { $ISOFile ) - New-VM -Name $VMName -Generation 1 -MemoryStartupBytes 6000MB -Path ${env:homepath}\.minikube\machines\ -NewVHDPath ${env:homepath}\.minikube\machines\$VMName\VHD.vhdx -NewVHDSizeBytes 127000MB -SwitchName $SwitchName + New-VM -Name $VMName -Generation 1 -MemoryStartupBytes 6000M B -Path ${env:homepath}\.minikube\machines\ -NewVHDPath ${env:homepath}\.minikube\machines\$VMName\VHD.vhdx -NewVHDSizeBytes 127000MB -SwitchName $SwitchName Set-VM -Name $VMName -ProcessorCount 2 -AutomaticCheckpointsEnabled $false Set-VMProcessor -VMName $VMName -ExposeVirtualizationExtensions $true Set-VMDvdDrive -VMName $VMName -Path $ISOFile @@ -45,179 +45,27 @@ function Set-Credential { } -function Install-Containerd { +function Rename-Node { param( [string] [ValidateNotNullOrEmpty()] - [parameter(HelpMessage = "ContainerD version to use. Default 1.7.6")] - $Version = "1.7.6", - - [String] - [parameter(HelpMessage = "Path to install containerd. Defaults to ~\program files\containerd")] - $InstallPath = "$Env:ProgramFiles\containerd", - - [String] - [parameter(HelpMessage = "Path to download files. Defaults to user's Downloads folder")] - $DownloadPath = ".\bin\" + $NewName = "minikube-m03" ) - - $Version = $Version.TrimStart('v') - $EnvPath = "$InstallPath\bin" - - $containerdTarFile = "containerd-${version}-windows-amd64.tar.gz" - $Uri = "https://github.com/containerd/containerd/releases/download/v$version/$($containerdTarFile)" - $params = @{ - Feature = "containerd" - Version = $Version - Uri = $Uri - InstallPath = $InstallPath - DownloadPath = "$DownloadPath\$containerdTarFile" - EnvPath = $EnvPath - cleanup = $true - } - - Write-Output "Downloading and installing Containerd at $InstallPath" - Invoke-WebRequest -Uri $Uri -OutFile $DownloadPath\$containerdTarFile -Verbose - Install-RequiredFeature @params - - Write-Output "Containerd successfully installed at $InstallPath" - containerd.exe -v - - Write-Output "For containerd usage: run 'containerd -h'" + Set-SConfig -AutoLaunch $false + Rename-Computer -NewName $NewName } -function Start-ContainerdService { - Set-Service containerd -StartupType Automatic - try { - Start-Service containerd -Force - - # Waiting for containerd to come to steady state - (Get-Service containerd -ErrorAction SilentlyContinue).WaitForStatus('Running', '00:00:30') - } - catch { - Throw "Couldn't start Containerd service. $_" - } +function Install-ContainerFeatures { + Install-WindowsFeature -Name containers } -function Initialize-ContainerdService { - param( - [string] - [parameter(HelpMessage = "Containerd path")] - $ContainerdPath = "$Env:ProgramFiles\containerd" - ) - - Write-Output "Configuring the containerd service" - - #Configure containerd service - $containerdConfigFile = "$ContainerdPath\config.toml" - $containerdDefault = containerd.exe config default - $containerdDefault | Out-File $ContainerdPath\config.toml -Encoding ascii - Write-Information -InformationAction Continue -MessageData "Review containerd configutations at $containerdConfigFile" - - Add-MpPreference -ExclusionProcess "$ContainerdPath\containerd.exe" - - # Review the configuration. Depending on setup you may want to adjust: - # - the sandbox_image (Kubernetes pause image) - # - cni bin_dir and conf_dir locations - # Get-Content $containerdConfigFile - # TODO: Complete the script make the following changes in the .toml file - # - # Setting Old value New Value - # bin_dir "C:\\Program Files\\containerd\\cni\\bin" "c:\\opt\\cni\\bin" - # conf_dir "C:\\Program Files\\containerd\\cni\\conf" "c:\\etc\\cni\\net.d\\" - - # Register containerd service - Add-FeatureToPath -Feature "containerd" -Path "$ContainerdPath\bin" - containerd.exe --register-service --log-level debug --service-name containerd --log-file "$env:TEMP\containerd.log" - if ($LASTEXITCODE -gt 0) { - Throw "Failed to register containerd service. $_" - } - - Write-Output "Containerd service" - Get-Service *containerd* | Select-Object Name, DisplayName, ServiceName, ServiceType, StartupType, Status, RequiredServices, ServicesDependedOn -} - -function Install-NSSM { - param( - [string] - [ValidateNotNullOrEmpty()] - [parameter(HelpMessage = "NSSM version to use. Default 2.24")] - $Version = "2.24", - - [String] - [parameter(HelpMessage = "Architecture ")] - $Arch = "win64", - - [String] - [parameter(HelpMessage = "Path to download files.")] - $DownloadPath = "c:\k" - ) - - $Version = $Version.TrimStart('v') +function Restart-Node { + Restart-Computer -Force - $nssmTarFile = "nssm-${version}.zip" - $Uri = "https://k8stestinfrabinaries.blob.core.windows.net/nssm-mirror/$($nssmTarFile)" - $params = @{ - Feature = "nssm" - Version = $Version - Uri = $Uri - InstallPath = $InstallPath - DownloadPath = "$DownloadPath\$containerdTarFile" - EnvPath = $EnvPath - cleanup = $true - } - - Write-Output "Downloading and installing Containerd at $InstallPath" - Invoke-WebRequest -Uri $Uri -OutFile $DownloadPath\$containerdTarFile -Verbose - Install-RequiredFeature @params - - Write-Output "Containerd successfully installed at $InstallPath" - containerd.exe -v - - Write-Output "For containerd usage: run 'containerd -h'" } -function Install-Kubelet { - param ( - [string] - [ValidateNotNullOrEmpty()] - $KubernetesVersion = "v1.27.3" - ) - - # Define the URL for kubelet download - $KubeletUrl = "https://dl.k8s.io/$KubernetesVersion/bin/windows/amd64/kubelet.exe" - - # Download kubelet - Invoke-WebRequest -Uri $KubeletUrl -OutFile "c:\k\kubelet.exe" - - # Create the Start-kubelet.ps1 script - @" -`$FileContent = Get-Content -Path "/var/lib/kubelet/kubeadm-flags.env" -`$kubeAdmArgs = `$FileContent.TrimStart(`'KUBELET_KUBEADM_ARGS=`').Trim(`'"`') - -`$args = "--cert-dir=`$env:SYSTEMDRIVE/var/lib/kubelet/pki", - "--config=`$env:SYSTEMDRIVE/var/lib/kubelet/config.yaml", - "--bootstrap-kubeconfig=`$env:SYSTEMDRIVE/etc/kubernetes/bootstrap-kubelet.conf", - "--kubeconfig=`$env:SYSTEMDRIVE/etc/kubernetes/kubelet.conf", - "--hostname-override=`$(hostname)", - "--enable-debugging-handlers", - "--cgroups-per-qos=false", - "--enforce-node-allocatable=``"``"", - "--resolv-conf=``"``"" - -`$kubeletCommandLine = "c:\k\kubelet.exe " + (`$args -join " ") + " `$kubeAdmArgs" -Invoke-Expression `$kubeletCommandLine -"@ | Set-Content -Path "c:\k\Start-kubelet.ps1" - - # Install kubelet as a Windows service - "c:\k\nssm.exe install kubelet Powershell -ExecutionPolicy Bypass -NoProfile c:\k\Start-kubelet.ps1" - "c:\k\nssm.exe set Kubelet AppStdout C:\k\kubelet.log" - "c:\k\nssm.exe set Kubelet AppStderr C:\k\kubelet.err.log" -} - -# Example usage: Install-Kubelet -KubernetesVersion "v1.27.3" function Enable-FireWall-Ports { diff --git a/automation/SetUpUtilities.psm1 b/automation/SetUpUtilities.psm1 new file mode 100644 index 0000000..227a6ec --- /dev/null +++ b/automation/SetUpUtilities.psm1 @@ -0,0 +1,11 @@ +function Get-LatestToolVersion($repository) { + try { + $uri = "https://api.github.com/repos/$repository/releases/latest" + $response = Invoke-WebRequest -Uri $uri + $version = ($response.content | ConvertFrom-Json).tag_name + return $version.TrimStart("v") + } + catch { + Throw "Could not get $repository version. $_" + } +} \ No newline at end of file diff --git a/automation/k8Tools.psm1 b/automation/k8Tools.psm1 new file mode 100644 index 0000000..438c217 --- /dev/null +++ b/automation/k8Tools.psm1 @@ -0,0 +1,40 @@ +function Install-Kubelet { + param ( + [string] + [ValidateNotNullOrEmpty()] + $KubernetesVersion = "v1.27.3" + ) + + # Define the URL for kubelet download + $KubeletUrl = "https://dl.k8s.io/$KubernetesVersion/bin/windows/amd64/kubelet.exe" + + # Download kubelet + Invoke-WebRequest -Uri $KubeletUrl -OutFile "c:\k\kubelet.exe" + + # Create the Start-kubelet.ps1 script + @" +`$FileContent = Get-Content -Path "/var/lib/kubelet/kubeadm-flags.env" +`$kubeAdmArgs = `$FileContent.TrimStart(`'KUBELET_KUBEADM_ARGS=`').Trim(`'"`') + +`$args = "--cert-dir=`$env:SYSTEMDRIVE/var/lib/kubelet/pki", + "--config=`$env:SYSTEMDRIVE/var/lib/kubelet/config.yaml", + "--bootstrap-kubeconfig=`$env:SYSTEMDRIVE/etc/kubernetes/bootstrap-kubelet.conf", + "--kubeconfig=`$env:SYSTEMDRIVE/etc/kubernetes/kubelet.conf", + "--hostname-override=`$(hostname)", + "--enable-debugging-handlers", + "--cgroups-per-qos=false", + "--enforce-node-allocatable=``"``"", + "--resolv-conf=``"``"" + +`$kubeletCommandLine = "c:\k\kubelet.exe " + (`$args -join " ") + " `$kubeAdmArgs" +Invoke-Expression `$kubeletCommandLine +"@ | Set-Content -Path "c:\k\Start-kubelet.ps1" + + # Install kubelet as a Windows service + "c:\k\nssm.exe install kubelet Powershell -ExecutionPolicy Bypass -NoProfile c:\k\Start-kubelet.ps1" + "c:\k\nssm.exe set Kubelet AppStdout C:\k\kubelet.log" + "c:\k\nssm.exe set Kubelet AppStderr C:\k\kubelet.err.log" +} + + +# Example usage: Install-Kubelet -KubernetesVersion "v1.27.3" \ No newline at end of file From 5b3e54a2ab6e2f530077eb677eddc81870d426b3 Mon Sep 17 00:00:00 2001 From: bosira Date: Tue, 31 Oct 2023 09:48:34 +0000 Subject: [PATCH 03/52] more updates on the set up scripts --- automation/Install-Windows.psm1 | 0 automation/MinikubeTools.psm1 | 47 +++++++++++++++ automation/NodeManTools.psm1 | 62 +++++++++++++++++++ automation/Remote.ps1 | 102 -------------------------------- automation/Remote.psm1 | 51 ++++++++++++++++ automation/Run.ps1 | 0 automation/SetUpUtilities.psm1 | 22 +++++++ 7 files changed, 182 insertions(+), 102 deletions(-) create mode 100644 automation/Install-Windows.psm1 create mode 100644 automation/MinikubeTools.psm1 create mode 100644 automation/NodeManTools.psm1 delete mode 100644 automation/Remote.ps1 create mode 100644 automation/Remote.psm1 create mode 100644 automation/Run.ps1 diff --git a/automation/Install-Windows.psm1 b/automation/Install-Windows.psm1 new file mode 100644 index 0000000..e69de29 diff --git a/automation/MinikubeTools.psm1 b/automation/MinikubeTools.psm1 new file mode 100644 index 0000000..14cbbc1 --- /dev/null +++ b/automation/MinikubeTools.psm1 @@ -0,0 +1,47 @@ +function Start-Minikube { + param ( + [string] + [ValidateNotNullOrEmpty()] + $SwitchName = "External VM Switch" + ) + + minikube start --driver=hyperv --hyperv-virtual-switch=$SwitchName --nodes=2 --cni=flannel --container-runtime=containerd +} + +function Set-Flannel { + param ( + [string] + [ValidateNotNullOrEmpty()] + $NodeName + ) + + if ($NodeName) { + minikube ssh "sudo sysctl net.bridge.bridge-nf-call-iptables=1 && exit" + } else { + minikube ssh -n $NodeName "sudo sysctl net.bridge.bridge-nf-call-iptables=1 && exit" + } + +} + +function Get-JoinCommand { + param ( + [string] + [ValidateNotNullOrEmpty()] + $Version = "v1.27.3" + ) + + $JoinCommand = (minikube ssh "cd /var/lib/minikube/binaries/v1.27.3/ && sudo ./kubeadm token create --print-join-command") + + # Replace 'kubeadm' with '.\kubeadm' + $outputString = $JoinCommand -replace 'kubeadm', '.\kubeadm' + + # Append '--cri-socket "npipe:////./pipe/containerd-containerd"' + $outputString += ' --cri-socket "npipe:////./pipe/containerd-containerd"' + + # Print the modified string + Write-Host $outputString + + return $outputString + + +} \ No newline at end of file diff --git a/automation/NodeManTools.psm1 b/automation/NodeManTools.psm1 new file mode 100644 index 0000000..31a9190 --- /dev/null +++ b/automation/NodeManTools.psm1 @@ -0,0 +1,62 @@ +function Start-VirtualMachine { + param ( + [String] + [ValidateNotNullOrEmpty()] + $VMName, + + [String] + [ValidateNotNullOrEmpty()] + $SwitchName, + + [String] + [ValidateNotNullOrEmpty()] + $ISOFile + ) + + $VM = @{ + Name = $VMName + MemoryStartupBytes = 6000MB + Generation = 2 + NewVHDPath = "${env:homepath}\.minikube\machines\$VMName\VHD.vhdx" + NewVHDSizeBytes = 127000MB + BootDevice = "VHD" + Path = "${env:homepath}\.minikube\machines\" + SwitchName = (Get-VMSwitch).Name + } + + New-VM @VM + + # New-VM -Name $VMName -Generation 1 -MemoryStartupBytes 6000MB -Path ${env:homepath}\.minikube\machines\ -NewVHDPath ${env:homepath}\.minikube\machines\$VMName\VHD.vhdx -NewVHDSizeBytes 127000MB -SwitchName $SwitchName + Set-VM -Name $VMName -ProcessorCount 2 -AutomaticCheckpointsEnabled $false + Set-VMProcessor -VMName $VMName -ExposeVirtualizationExtensions $true + Set-VMDvdDrive -VMName $VMName -Path $ISOFile + Start-VM -Name $VMName +} + +function Set-NodeForMinikube { + param( + [string] + [ValidateNotNullOrEmpty()] + $NewName = "minikube-m03" + ) + + Set-SConfig -AutoLaunch $false + Restart-Computer -Force + Install-WindowsFeature -Name containers + Restart-Computer -Force + +} + + +function Remove-VirtualMachine { + param ( + [String] + [ValidateNotNullOrEmpty()] + $VMName + ) + + Stop-VM -Name $VMName -TurnOff + Remove-VM -Name $VMName -Force + Remove-Item -Path ${env:homepath}\.minikube\machines\$VMName -Force -Recurse + +} \ No newline at end of file diff --git a/automation/Remote.ps1 b/automation/Remote.ps1 deleted file mode 100644 index 5e71923..0000000 --- a/automation/Remote.ps1 +++ /dev/null @@ -1,102 +0,0 @@ -function Start-VirtualMachine { - param ( - [String] - [ValidateNotNullOrEmpty()] - $VMName, - - [String] - [ValidateNotNullOrEmpty()] - $SwitchName, - - [String] - [ValidateNotNullOrEmpty()] - $ISOFile - ) - - New-VM -Name $VMName -Generation 1 -MemoryStartupBytes 6000M B -Path ${env:homepath}\.minikube\machines\ -NewVHDPath ${env:homepath}\.minikube\machines\$VMName\VHD.vhdx -NewVHDSizeBytes 127000MB -SwitchName $SwitchName - Set-VM -Name $VMName -ProcessorCount 2 -AutomaticCheckpointsEnabled $false - Set-VMProcessor -VMName $VMName -ExposeVirtualizationExtensions $true - Set-VMDvdDrive -VMName $VMName -Path $ISOFile - Start-VM -Name $VMName -} - -# $VMName = 'minikube-m03'; -# $UserName = 'Administrator'; -# $Password = 'M@kindu.2021'; -function Set-Credential { - param ( - [String] - [ValidateNotNullOrEmpty()] - $VMName, - - [String] - [ValidateNotNullOrEmpty()] - $UserName, - - [String] - [ValidateNotNullOrEmpty()] - $Pass - ) - - $SecurePassword = ConvertTo-SecureString -String $Password -AsPlainText -Force; - $Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $Username, $SecurePassword ; - - return $Credential - -} - -function Rename-Node { - param( - [string] - [ValidateNotNullOrEmpty()] - $NewName = "minikube-m03" - ) - Set-SConfig -AutoLaunch $false - Rename-Computer -NewName $NewName -} - -function Install-ContainerFeatures { - Install-WindowsFeature -Name containers -} - -function Restart-Node { - Restart-Computer -Force - -} - - - - - -function Enable-FireWall-Ports { - New-NetFirewallRule -Name kubelet -DisplayName 'kubelet' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 10250 - -} - - -function Start-RemoteSession { - param ( - [String] - [ValidateNotNullOrEmpty()] - $VMName, - - [PSCredential] - [ValidateNotNullOrEmpty()] - $Credential - ) - - Enter-PSSession -VMName $VMName -Credential $Credential; -} - -function Remove-VirtualMachine { - param ( - [String] - [ValidateNotNullOrEmpty()] - $VMName - ) - - Stop-VM -Name $VMName -TurnOff - Remove-VM -Name $VMName -Force - Remove-Item -Path ${env:homepath}\.minikube\machines\$VMName -Force -Recurse - -} \ No newline at end of file diff --git a/automation/Remote.psm1 b/automation/Remote.psm1 new file mode 100644 index 0000000..32af07d --- /dev/null +++ b/automation/Remote.psm1 @@ -0,0 +1,51 @@ +# $VMName = 'minikube-m03'; +# $UserName = 'Administrator'; +# $Password = 'M@kindu.2021'; +function Set-Credential { + param ( + [String] + [ValidateNotNullOrEmpty()] + $VMName = 'minikube-m03', + + [String] + [ValidateNotNullOrEmpty()] + $UserName = 'Administrator', + + [String] + [ValidateNotNullOrEmpty()] + $Pass = 'M@kindu.2021' + ) + + $SecurePassword = ConvertTo-SecureString -String $Password -AsPlainText -Force; + $Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $Username, $SecurePassword ; + + return $Credential + +} + +function Start-RemoteSession { + param ( + [String] + [ValidateNotNullOrEmpty()] + $VMName, + + [PSCredential] + [ValidateNotNullOrEmpty()] + $Credential + ) + + Enter-PSSession -VMName $VMName -Credential $Credential; +} + + + + + + + +function Enable-FireWall-Ports { + New-NetFirewallRule -Name kubelet -DisplayName 'kubelet' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 10250 + +} + + diff --git a/automation/Run.ps1 b/automation/Run.ps1 new file mode 100644 index 0000000..e69de29 diff --git a/automation/SetUpUtilities.psm1 b/automation/SetUpUtilities.psm1 index 227a6ec..bf90113 100644 --- a/automation/SetUpUtilities.psm1 +++ b/automation/SetUpUtilities.psm1 @@ -1,3 +1,25 @@ +function Get-HyperV { + $hyperv = Get-WindowsOptionalFeature -FeatureName Microsoft-Hyper-V-All -Online + # Check if Hyper-V is enabled + if($hyperv.State -eq "Enabled") { + Write-Host "Hyper-V is enabled." + } else { + Write-Host "Hyper-V is disabled." + } + +} + +function Set-VmSwitch { + $net = Get-NetAdapter | Where-Object { $_.Status -eq 'Up' } + New-VMSwitch -Name "External VM Switch" -AllowManagementOS $True -NetAdapterName $net.Name +} + +function Get-VmSwitch { + $SwitchName = "External VM Switch" + return $SwitchName + +} + function Get-LatestToolVersion($repository) { try { $uri = "https://api.github.com/repos/$repository/releases/latest" From b72ec337b64c252e0a0c70d4c4e7b857b4cf6657 Mon Sep 17 00:00:00 2001 From: bosira Date: Wed, 8 Nov 2023 14:57:43 +0000 Subject: [PATCH 04/52] more updates to the automation scripts --- README.md | 2 +- automation/ContainerdTools.psm1 | 8 +++- automation/MinikubeTools.psm1 | 36 ++++++++++++++++- automation/NSSMTools.psm1 | 72 +++++++++++++++++++-------------- automation/Remote.psm1 | 15 +------ automation/Run.ps1 | 30 ++++++++++++++ automation/k8Tools.psm1 | 26 ++++++++++-- 7 files changed, 137 insertions(+), 52 deletions(-) diff --git a/README.md b/README.md index 6e5942c..cf8a570 100644 --- a/README.md +++ b/README.md @@ -193,7 +193,7 @@ You will need to append the IP address of the master node to the Hosts file on t > You can find the IP address of the master Linux node by running the following command on your machine: > >```powershell ->minikube node list +>minikube ip >``` Your hosts file should look similar to this: diff --git a/automation/ContainerdTools.psm1 b/automation/ContainerdTools.psm1 index 453d397..dd63979 100644 --- a/automation/ContainerdTools.psm1 +++ b/automation/ContainerdTools.psm1 @@ -139,4 +139,10 @@ function Initialize-ContainerdService { Write-Output "Containerd service" Get-Service *containerd* | Select-Object Name, DisplayName, ServiceName, ServiceType, StartupType, Status, RequiredServices, ServicesDependedOn -} \ No newline at end of file +} + + +Export-ModuleMember -Function Get-ContainerdLatestVersion +Export-ModuleMember -Function Install-Containerd +Export-ModuleMember -Function Start-ContainerdService +Export-ModuleMember -Function Initialize-ContainerdService \ No newline at end of file diff --git a/automation/MinikubeTools.psm1 b/automation/MinikubeTools.psm1 index 14cbbc1..4bc8dfd 100644 --- a/automation/MinikubeTools.psm1 +++ b/automation/MinikubeTools.psm1 @@ -8,6 +8,12 @@ function Start-Minikube { minikube start --driver=hyperv --hyperv-virtual-switch=$SwitchName --nodes=2 --cni=flannel --container-runtime=containerd } +function Get-LinuxMasterNodeIP { + $IP = minikube ip + return $IP + +} + function Set-Flannel { param ( [string] @@ -43,5 +49,33 @@ function Get-JoinCommand { return $outputString +} + +function Set-MinikubeFolderError { + mkdir c:\var\lib\minikube\certs + Copy-Item C:\etc\kubernetes\pki\ca.crt -Destination C:\var\lib\Minikube\Certs + Remove-Item C:\etc\kubernetes\pki\ca.crt +} + +function Add-Host { + param ( + [string] + [ValidateNotNullOrEmpty()] + $IP, + [string] + [ValidateNotNullOrEmpty()] + $Path = "C:\Windows\System32\drivers\etc\hosts" + ) + + Add-Content -Path $Path -Value "`n`t`t$IP`tcontrol-plane.minikube.internal" -Force -} \ No newline at end of file +} + + +Export-ModuleMember -Function Start-Minikube +Export-ModuleMember -Function Get-LinuxMasterNodeIP +Export-ModuleMember -Function Set-Flannel +Export-ModuleMember -Function Get-JoinCommand +Export-ModuleMember -Function Invoke-RunCommand +Export-ModuleMember -Function Set-MinikubeFolderError +Export-ModuleMember -Function Add-Host \ No newline at end of file diff --git a/automation/NSSMTools.psm1 b/automation/NSSMTools.psm1 index 32a7dde..2bc8ef2 100644 --- a/automation/NSSMTools.psm1 +++ b/automation/NSSMTools.psm1 @@ -1,39 +1,49 @@ function Install-NSSM { - param( - [string] - [ValidateNotNullOrEmpty()] - [parameter(HelpMessage = "NSSM version to use. Default 2.24")] - $Version = "2.24", + Set-Location c:\k + $arch = "win64" + curl.exe -L https://k8stestinfrabinaries.blob.core.windows.net/nssm-mirror/nssm-2.24.zip -o nssm.zip + tar.exe C c:\k\ -xvf .\nssm.zip --strip-components 2 */$arch/*.exe + +} + +Export-ModuleMember -Function Install-NSSM + +# function Install-NSSM { +# param( +# [string] +# [ValidateNotNullOrEmpty()] +# [parameter(HelpMessage = "NSSM version to use. Default 2.24")] +# $Version = "2.24", - [String] - [parameter(HelpMessage = "Architecture ")] - $Arch = "win64", +# [String] +# [parameter(HelpMessage = "Architecture ")] +# $Arch = "win64", - [String] - [parameter(HelpMessage = "Path to download files.")] - $DownloadPath = "c:\k" - ) +# [String] +# [parameter(HelpMessage = "Path to download files.")] +# $DownloadPath = "c:\k" +# ) - $Version = $Version.TrimStart('v') +# $Version = $Version.TrimStart('v') - $nssmTarFile = "nssm-${version}.zip" - $Uri = "https://k8stestinfrabinaries.blob.core.windows.net/nssm-mirror/$($nssmTarFile)" - $params = @{ - Feature = "nssm" - Version = $Version - Uri = $Uri - InstallPath = $InstallPath - DownloadPath = "$DownloadPath\$containerdTarFile" - EnvPath = $EnvPath - cleanup = $true - } +# $nssmTarFile = "nssm-${version}.zip" +# $Uri = "https://k8stestinfrabinaries.blob.core.windows.net/nssm-mirror/$($nssmTarFile)" +# $params = @{ +# Feature = "nssm" +# Version = $Version +# Uri = $Uri +# InstallPath = $InstallPath +# DownloadPath = "$DownloadPath\$containerdTarFile" +# EnvPath = $EnvPath +# cleanup = $true +# } - Write-Output "Downloading and installing Containerd at $InstallPath" - Invoke-WebRequest -Uri $Uri -OutFile $DownloadPath\$containerdTarFile -Verbose - Install-RequiredFeature @params +# Write-Output "Downloading and installing Containerd at $InstallPath" +# Invoke-WebRequest -Uri $Uri -OutFile $DownloadPath\$containerdTarFile -Verbose +# Install-RequiredFeature @params - Write-Output "Containerd successfully installed at $InstallPath" - containerd.exe -v +# Write-Output "Containerd successfully installed at $InstallPath" +# containerd.exe -v - Write-Output "For containerd usage: run 'containerd -h'" -} \ No newline at end of file +# Write-Output "For containerd usage: run 'containerd -h'" +# } \ No newline at end of file diff --git a/automation/Remote.psm1 b/automation/Remote.psm1 index 32af07d..cf0dd02 100644 --- a/automation/Remote.psm1 +++ b/automation/Remote.psm1 @@ -35,17 +35,4 @@ function Start-RemoteSession { ) Enter-PSSession -VMName $VMName -Credential $Credential; -} - - - - - - - -function Enable-FireWall-Ports { - New-NetFirewallRule -Name kubelet -DisplayName 'kubelet' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 10250 - -} - - +} \ No newline at end of file diff --git a/automation/Run.ps1 b/automation/Run.ps1 index e69de29..6300ed2 100644 --- a/automation/Run.ps1 +++ b/automation/Run.ps1 @@ -0,0 +1,30 @@ +Import-Module -Name "ContainerdTools.psm1" -Force +Import-Module -Name "k8Tools.psm1" -Force +Import-Module -Name "MinikubeTools.psm1" -Force +Import-Module -Name "NSSMTools.psm1" -Force + +Install-Containerd +Initialize-ContainerdService +Start-ContainerdService +Install-NSSM +Install-Kubelet +Set-Port + +$IP = minikube ip +$Path = $Path = "C:\Windows\System32\drivers\etc\hosts" + +Add-Host -IP $IP -Path $Path + +Get-Kubeadm + + +$JoinCommand = Get-JoinCommand + +Invoke-Expression $JoinCommand + +Set-MinikubeFolderError + +Invoke-Expression $JoinCommand + +# windows node successfully joined in the cluster +& kubectl get nodes -o wide \ No newline at end of file diff --git a/automation/k8Tools.psm1 b/automation/k8Tools.psm1 index 438c217..7f00f76 100644 --- a/automation/k8Tools.psm1 +++ b/automation/k8Tools.psm1 @@ -31,10 +31,28 @@ Invoke-Expression `$kubeletCommandLine "@ | Set-Content -Path "c:\k\Start-kubelet.ps1" # Install kubelet as a Windows service - "c:\k\nssm.exe install kubelet Powershell -ExecutionPolicy Bypass -NoProfile c:\k\Start-kubelet.ps1" - "c:\k\nssm.exe set Kubelet AppStdout C:\k\kubelet.log" - "c:\k\nssm.exe set Kubelet AppStderr C:\k\kubelet.err.log" + c:\k\nssm.exe install kubelet Powershell -ExecutionPolicy Bypass -NoProfile c:\k\Start-kubelet.ps1 + c:\k\nssm.exe set Kubelet AppStdout C:\k\kubelet.log + c:\k\nssm.exe set Kubelet AppStderr C:\k\kubelet.err.log +} + +function Set-Port { + New-NetFirewallRule -Name kubelet -DisplayName 'kubelet' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 10250 + +} + +function Get-Kubeadm { + param ( + [string] + [ValidateNotNullOrEmpty()] + $KubernetesVersion = "v1.27.3" + ) + curl.exe -L https://dl.k8s.io/$KubernetesVersion/bin/windows/amd64/kubeadm.exe -o c:\k\kubeadm.exe + Set-Location c:\k } -# Example usage: Install-Kubelet -KubernetesVersion "v1.27.3" \ No newline at end of file +# Example usage: Install-Kubelet -KubernetesVersion "v1.27.3" +Export-ModuleMember -Function Install-Kubelet +Export-ModuleMember -Function Set-Port +Export-ModuleMember -Function Get-Kubeadm \ No newline at end of file From 18efcf959942dba616d8ade5d1ab85c004aa8d38 Mon Sep 17 00:00:00 2001 From: bosira Date: Mon, 13 Nov 2023 08:27:46 +0000 Subject: [PATCH 05/52] fixes to containerd installation --- automation/ContainerdTools.psm1 | 11 +++-- automation/Run.ps1 | 8 ++-- automation/SetUpUtilities.psm1 | 85 ++++++++++++++++++++++++++++++++- 3 files changed, 96 insertions(+), 8 deletions(-) diff --git a/automation/ContainerdTools.psm1 b/automation/ContainerdTools.psm1 index dd63979..ffb298c 100644 --- a/automation/ContainerdTools.psm1 +++ b/automation/ContainerdTools.psm1 @@ -1,3 +1,5 @@ +Import-Module -Name "$PSScriptRoot\SetUpUtilities.psm1" -Force + function Get-ContainerdLatestVersion { $latestVersion = Get-LatestToolVersion -Repository "containerd/containerd" return $latestVersion @@ -16,17 +18,20 @@ function Install-Containerd { [String] [parameter(HelpMessage = "Path to download files. Defaults to user's Downloads folder")] - $DownloadPath = ".\bin\" + $DownloadPath = "$HOME\Downloads" ) + # Uninstall if tool exists at specified location. Requires user consent + # Uninstall-ContainerTool -Tool "ContainerD" -Path $InstallPath + if(!$Version) { # Get default version $Version = Get-ContainerdLatestVersion } + $Version = $Version.TrimStart('v') Write-Output "Downloading and installing Containerd v$version at $InstallPath" - $EnvPath = "$InstallPath\bin" # Download file from repo $containerdTarFile = "containerd-${version}-windows-amd64.tar.gz" @@ -48,7 +53,7 @@ function Install-Containerd { Feature = "containerd" InstallPath = $InstallPath DownloadPath = "$DownloadPath\$containerdTarFile" - EnvPath = $EnvPath + EnvPath = "$InstallPath\bin" cleanup = $true } diff --git a/automation/Run.ps1 b/automation/Run.ps1 index 6300ed2..148812a 100644 --- a/automation/Run.ps1 +++ b/automation/Run.ps1 @@ -1,7 +1,7 @@ -Import-Module -Name "ContainerdTools.psm1" -Force -Import-Module -Name "k8Tools.psm1" -Force -Import-Module -Name "MinikubeTools.psm1" -Force -Import-Module -Name "NSSMTools.psm1" -Force +Import-Module -Name "$PSScriptRoot\ContainerdTools.psm1" -Force +Import-Module -Name "$PSScriptRoot\k8Tools.psm1" -Force +Import-Module -Name "$PSScriptRoot\MinikubeTools.psm1" -Force +Import-Module -Name "$PSScriptRoot\NSSMTools.psm1" -Force Install-Containerd Initialize-ContainerdService diff --git a/automation/SetUpUtilities.psm1 b/automation/SetUpUtilities.psm1 index bf90113..bb576ed 100644 --- a/automation/SetUpUtilities.psm1 +++ b/automation/SetUpUtilities.psm1 @@ -1,3 +1,5 @@ +$envPathRegKey = "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" + function Get-HyperV { $hyperv = Get-WindowsOptionalFeature -FeatureName Microsoft-Hyper-V-All -Online # Check if Hyper-V is enabled @@ -30,4 +32,85 @@ function Get-LatestToolVersion($repository) { catch { Throw "Could not get $repository version. $_" } -} \ No newline at end of file +} + +function ParsePathString($pathString) { + $parsedString = $pathString -split ";" | ` + ForEach-Object { $_.TrimEnd("\") } | ` + Select-Object -Unique | ` + Where-Object { ![string]::IsNullOrWhiteSpace($_) } + + if (!$parsedString) { + $DebugPreference = 'Stop' + Write-Debug "Env path cannot be null or an empty string" + } + return $parsedString -join ";" +} + +function Install-RequiredFeature { + param( + [string] $Feature, + [string] $InstallPath, + [string] $DownloadPath, + [string] $EnvPath, + [boolean] $cleanup + ) + + # Create the directory to untar to + Write-Information -InformationAction Continue -MessageData "Extracting $Feature to $InstallPath" + if (!(Test-Path $InstallPath)) { + New-Item -ItemType Directory -Force -Path $InstallPath | Out-Null + } + + # Untar file + if ($DownloadPath.EndsWith("tar.gz")) { + tar.exe -xf $DownloadPath -C $InstallPath + if ($LASTEXITCODE -gt 0) { + Throw "Could not untar $DownloadPath. $_" + } + } + + # Add to env path + Add-FeatureToPath -Feature $Feature -Path $EnvPath + + # Clean up + if ($CleanUp) { + Write-Output "Cleanup to remove downloaded files" + Remove-Item $downloadPath -Force -ErrorAction Continue + } +} + +function Add-FeatureToPath { + param ( + [string] + [ValidateNotNullOrEmpty()] + [parameter(HelpMessage = "Feature to add to env path")] + $feature, + + [string] + [ValidateNotNullOrEmpty()] + [parameter(HelpMessage = "Path where the feature is installed")] + $path + ) + + $currPath = (Get-ItemProperty -Path $envPathRegKey -Name path).path + $currPath = ParsePathString -PathString $currPath + if (!($currPath -like "*$feature*")) { + Write-Information -InformationAction Continue -MessageData "Adding $feature to Environment Path RegKey" + + # Add to reg key + Set-ItemProperty -Path $envPathRegKey -Name PATH -Value "$currPath;$path" + } + + $currPath = ParsePathString -PathString $env:Path + if (!($currPath -like "*$feature*")) { + Write-Information -InformationAction Continue -MessageData "Adding $feature to env path" + # Add to env path + [Environment]::SetEnvironmentVariable("Path", "$($env:path);$path", [System.EnvironmentVariableTarget]::Machine) + $env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + } +} + +Export-ModuleMember -Function Get-LatestToolVersion +Export-ModuleMember -Function Install-RequiredFeature +Export-ModuleMember -Function Add-FeatureToPath \ No newline at end of file From 226cc321a22a8b57fe1a211d962d0ab5c09d3f67 Mon Sep 17 00:00:00 2001 From: bosira Date: Mon, 13 Nov 2023 08:31:14 +0000 Subject: [PATCH 06/52] changes to VM specification --- automation/NodeManTools.psm1 | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/automation/NodeManTools.psm1 b/automation/NodeManTools.psm1 index 31a9190..4d632aa 100644 --- a/automation/NodeManTools.psm1 +++ b/automation/NodeManTools.psm1 @@ -15,10 +15,9 @@ function Start-VirtualMachine { $VM = @{ Name = $VMName - MemoryStartupBytes = 6000MB - Generation = 2 + MemoryStartupBytes = 1GB NewVHDPath = "${env:homepath}\.minikube\machines\$VMName\VHD.vhdx" - NewVHDSizeBytes = 127000MB + NewVHDSizeBytes = 10GB BootDevice = "VHD" Path = "${env:homepath}\.minikube\machines\" SwitchName = (Get-VMSwitch).Name From 3a48a66086503cdbb71d752f62b9e3b60387bf48 Mon Sep 17 00:00:00 2001 From: bosira Date: Wed, 15 Nov 2023 16:10:55 +0000 Subject: [PATCH 07/52] response content cannot be parsed because the Internet Explorer engine is not available fix --- automation/SetUpUtilities.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automation/SetUpUtilities.psm1 b/automation/SetUpUtilities.psm1 index bb576ed..d6d45dd 100644 --- a/automation/SetUpUtilities.psm1 +++ b/automation/SetUpUtilities.psm1 @@ -25,7 +25,7 @@ function Get-VmSwitch { function Get-LatestToolVersion($repository) { try { $uri = "https://api.github.com/repos/$repository/releases/latest" - $response = Invoke-WebRequest -Uri $uri + $response = Invoke-WebRequest -Uri $uri -UseBasicParsing $version = ($response.content | ConvertFrom-Json).tag_name return $version.TrimStart("v") } From 33456f53f30e920e06681e5cd5d520d400265ee4 Mon Sep 17 00:00:00 2001 From: bosira Date: Sat, 18 Nov 2023 16:06:52 +0000 Subject: [PATCH 08/52] fix to containerd start service command --- automation/ContainerdTools.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automation/ContainerdTools.psm1 b/automation/ContainerdTools.psm1 index ffb298c..158f34b 100644 --- a/automation/ContainerdTools.psm1 +++ b/automation/ContainerdTools.psm1 @@ -69,7 +69,7 @@ function Install-Containerd { function Start-ContainerdService { Set-Service containerd -StartupType Automatic try { - Start-Service containerd -Force + Start-Service containerd # Waiting for containerd to come to steady state (Get-Service containerd -ErrorAction SilentlyContinue).WaitForStatus('Running', '00:00:30') From 12c572764e27d3b03b71187ef2df77db293deffd Mon Sep 17 00:00:00 2001 From: bosira Date: Sun, 19 Nov 2023 18:50:22 +0000 Subject: [PATCH 09/52] logical change to replacement of toml conf file --- automation/ContainerdTools.psm1 | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/automation/ContainerdTools.psm1 b/automation/ContainerdTools.psm1 index 158f34b..9a56b65 100644 --- a/automation/ContainerdTools.psm1 +++ b/automation/ContainerdTools.psm1 @@ -120,13 +120,26 @@ function Initialize-ContainerdService { } ) - # Perform the replacements - foreach ($replacement in $replacements) { - $containerdConfigContent = $containerdConfigContent -replace [regex]::Escape($replacement.Find), $replacement.Replace + # check if replacements are neede and perform them in one iteration + $replacementsNeeded = $false + foreach($replacement in $replacements) { + if ($containerdConfigContent -contains $replacement.Find) { + $replacementsNeeded = $true + $containerdConfigContent = $containerdConfigContent -replace [regex]::Escape($replacement.Find), $replacement.Replace + } } - # Save the modified content back to the config.toml file - Set-Content -Path $containerdConfigFile -Value $containerdConfigContent + # Perform the replacements only if needed + if ($replacementsNeeded) { + # Save the modified content back to the config.toml file + Set-Content -Path $containerdConfigFile -Value $containerdConfigContent + + # Output a message indicating the changes + Write-Host "Changes applied to $containerdConfigFile" + } else { + Write-Host "No changes needed in $containerdConfigFile" + } + # Output a message indicating the changes Write-Host "Changes applied to $containerdConfigFile" From fbd7f389ce5a5b7b2becb08151e17c0454372027 Mon Sep 17 00:00:00 2001 From: bosira Date: Sun, 19 Nov 2023 23:06:49 +0000 Subject: [PATCH 10/52] error handling additions --- automation/ContainerdTools.psm1 | 40 +++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/automation/ContainerdTools.psm1 b/automation/ContainerdTools.psm1 index 9a56b65..d505794 100644 --- a/automation/ContainerdTools.psm1 +++ b/automation/ContainerdTools.psm1 @@ -144,17 +144,39 @@ function Initialize-ContainerdService { # Output a message indicating the changes Write-Host "Changes applied to $containerdConfigFile" - # Create the folders above - mkdir c:\opt\cni\bin - mkdir c:\etc\cni\net.d - - # Register containerd service - Add-FeatureToPath -Feature "containerd" -Path "$ContainerdPath\bin" - containerd.exe --register-service --log-level debug --service-name containerd --log-file "$env:TEMP\containerd.log" - if ($LASTEXITCODE -gt 0) { - Throw "Failed to register containerd service. $_" + # Create the folders if they do not exist + $binDir = "c:\opt\cni\bin" + $confDir = "c:\etc\cni\net.d" + + if (!(Test-Path $binDir)) { + mkdir $binDir + Write-Host "Created $binDir" + } + + if (!(Test-Path $confDir)) { + mkdir $confDir + Write-Host "Created $confDir" + } + + + $pathExists = [System.Environment]::GetEnvironmentVariable('PATH', [System.EnvironmentVariableTarget]::Machine) -like "*$ContainerdPath\bin*" + if (-not $pathExists) { + # Register containerd service + Add-FeatureToPath -Feature "containerd" -Path "$ContainerdPath\bin" } + # Check if the containerd service is already registered + $containerdServiceExists = Get-Service -Name "containerd" -ErrorAction SilentlyContinue + if (-not $containerdServiceExists) { + containerd.exe --register-service --log-level debug --service-name containerd --log-file "$env:TEMP\containerd.log" + if ($LASTEXITCODE -gt 0) { + Throw "Failed to register containerd service. $_" + } + } else { + Write-Host "Containerd service is already registered." + } + + Write-Output "Containerd service" Get-Service *containerd* | Select-Object Name, DisplayName, ServiceName, ServiceType, StartupType, Status, RequiredServices, ServicesDependedOn } From 3dbc715b75af35cc1f74879e14736bb3138f0ce6 Mon Sep 17 00:00:00 2001 From: bosira Date: Mon, 20 Nov 2023 00:06:54 +0000 Subject: [PATCH 11/52] updates to NSSM install --- automation/ContainerdTools.psm1 | 4 ++-- automation/NSSMTools.psm1 | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/automation/ContainerdTools.psm1 b/automation/ContainerdTools.psm1 index d505794..b93d39b 100644 --- a/automation/ContainerdTools.psm1 +++ b/automation/ContainerdTools.psm1 @@ -77,6 +77,8 @@ function Start-ContainerdService { catch { Throw "Couldn't start Containerd service. $_" } + + Get-Service *containerd* | Select-Object Name, DisplayName, ServiceName, ServiceType, StartupType, Status, RequiredServices, ServicesDependedOn } function Initialize-ContainerdService { @@ -176,8 +178,6 @@ function Initialize-ContainerdService { Write-Host "Containerd service is already registered." } - - Write-Output "Containerd service" Get-Service *containerd* | Select-Object Name, DisplayName, ServiceName, ServiceType, StartupType, Status, RequiredServices, ServicesDependedOn } diff --git a/automation/NSSMTools.psm1 b/automation/NSSMTools.psm1 index 2bc8ef2..fc2ac3f 100644 --- a/automation/NSSMTools.psm1 +++ b/automation/NSSMTools.psm1 @@ -1,5 +1,7 @@ function Install-NSSM { - Set-Location c:\k + if (-not (Test-Path -Path "c:\k" -PathType Container)) { + mkdir "c:\k" + } $arch = "win64" curl.exe -L https://k8stestinfrabinaries.blob.core.windows.net/nssm-mirror/nssm-2.24.zip -o nssm.zip tar.exe C c:\k\ -xvf .\nssm.zip --strip-components 2 */$arch/*.exe From aec248335d3b646f0574c072728d58a2275a3ac3 Mon Sep 17 00:00:00 2001 From: bosira Date: Wed, 29 Nov 2023 07:30:51 +0000 Subject: [PATCH 12/52] uninstall containerd logic --- automation/ContainerdTools.psm1 | 85 ++++++++++++++++++++++++++++++++- 1 file changed, 83 insertions(+), 2 deletions(-) diff --git a/automation/ContainerdTools.psm1 b/automation/ContainerdTools.psm1 index b93d39b..c71e224 100644 --- a/automation/ContainerdTools.psm1 +++ b/automation/ContainerdTools.psm1 @@ -22,7 +22,7 @@ function Install-Containerd { ) # Uninstall if tool exists at specified location. Requires user consent - # Uninstall-ContainerTool -Tool "ContainerD" -Path $InstallPath + Uninstall-ContainerTool -Tool "ContainerD" -Path $InstallPath if(!$Version) { # Get default version @@ -66,6 +66,23 @@ function Install-Containerd { Write-Output "For containerd usage: run 'containerd -h'" } +function Uninstall-ContainerTool ($tool, $path) { + $pathItems = Get-ChildItem -Path $path -ErrorAction SilentlyContinue + if ($null -eq $pathItems) { + return + } + + Write-Warning "Uninstalling preinstalled $tool at the path $path" + try { + $command = "Uninstall-$tool -Path '$path'" + Invoke-Expression -Command $command + } + catch { + Throw "Could not uninstall $tool. $_" + } +} + + function Start-ContainerdService { Set-Service containerd -StartupType Automatic try { @@ -181,8 +198,72 @@ function Initialize-ContainerdService { Get-Service *containerd* | Select-Object Name, DisplayName, ServiceName, ServiceType, StartupType, Status, RequiredServices, ServicesDependedOn } +function Uninstall-Containerd { + param( + [string] + [parameter(HelpMessage = "Containerd path")] + $Path + ) + Write-Output "Uninstalling containerd" + + if (!$Path) { + $Path = Get-DefaultInstallPath -Tool "containerd" + } + + $pathItems = Get-ChildItem -Path $Path -ErrorAction SilentlyContinue + if (!$pathItems.Name.Length) { + Write-Warning "Containerd does not exist at $Path or the directory is empty" + return + } + + try { + Stop-ContainerdService + } + catch { + Write-Warning "$_" + } + + # Unregister containerd service + Unregister-Containerd + + # Delete the containerd key + $regkey = "HKLM:\SYSTEM\CurrentControlSet\Services\containerd" + Get-Item -path $regkey -ErrorAction SilentlyContinue | Remove-Item -Recurse -Force + + # Remove the folder where containerd service was installed + Get-Item -Path $Path -ErrorAction SilentlyContinue | Remove-Item -Recurse -Force + + # Remove from env path + Remove-FeatureFromPath -Feature "containerd" + + Write-Output "Successfully uninstalled Containerd." +} +function Unregister-Containerd { + $scQueryResult = (sc.exe query containerd) | Select-String -Pattern "SERVICE_NAME: containerd" + if (!$scQueryResult) { + Write-Warning "Containerd service does not exist as an installed service." + return + } + # Unregister containerd service + containerd.exe --unregister-service + if ($LASTEXITCODE -gt 0) { + Write-Warning "Could not unregister containerd service. $_" + } + else { + Start-Sleep -Seconds 15 + } + + # # Delete containerd service + # sc.exe delete containerd + # if ($LASTEXITCODE -gt 0) { + # Write-Warning "Could not delete containerd service. $_" + # } +} + Export-ModuleMember -Function Get-ContainerdLatestVersion Export-ModuleMember -Function Install-Containerd +Export-ModuleMember -Function Uninstall-ContainerTool Export-ModuleMember -Function Start-ContainerdService -Export-ModuleMember -Function Initialize-ContainerdService \ No newline at end of file +Export-ModuleMember -Function Initialize-ContainerdService +Export-ModuleMember -Function Uninstall-Containerd \ No newline at end of file From 8c9f3d7fbb18b8bb5642d80196def6a1271ddbdb Mon Sep 17 00:00:00 2001 From: bosira Date: Wed, 29 Nov 2023 07:55:18 +0000 Subject: [PATCH 13/52] added stop containerd serv --- automation/ContainerdTools.psm1 | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/automation/ContainerdTools.psm1 b/automation/ContainerdTools.psm1 index c71e224..f045654 100644 --- a/automation/ContainerdTools.psm1 +++ b/automation/ContainerdTools.psm1 @@ -98,6 +98,24 @@ function Start-ContainerdService { Get-Service *containerd* | Select-Object Name, DisplayName, ServiceName, ServiceType, StartupType, Status, RequiredServices, ServicesDependedOn } +function Stop-ContainerdService { + $containerdStatus = Get-Service containerd -ErrorAction SilentlyContinue + if (!$containerdStatus) { + Write-Warning "Containerd service does not exist as an installed service." + return + } + + try { + Stop-Service containerd -NoWait + + # Waiting for containerd to come to steady state + (Get-Service containerd -ErrorAction SilentlyContinue).WaitForStatus('Stopped', '00:00:30') + } + catch { + Throw "Couldn't stop Containerd service. $_" + } +} + function Initialize-ContainerdService { param( [string] From 4b21c83578e64628b29642f8b66a2652e8b5037b Mon Sep 17 00:00:00 2001 From: bosira Date: Wed, 29 Nov 2023 08:01:34 +0000 Subject: [PATCH 14/52] changes to import statement --- automation/ContainerdTools.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automation/ContainerdTools.psm1 b/automation/ContainerdTools.psm1 index f045654..40c0278 100644 --- a/automation/ContainerdTools.psm1 +++ b/automation/ContainerdTools.psm1 @@ -281,7 +281,7 @@ function Unregister-Containerd { Export-ModuleMember -Function Get-ContainerdLatestVersion Export-ModuleMember -Function Install-Containerd -Export-ModuleMember -Function Uninstall-ContainerTool Export-ModuleMember -Function Start-ContainerdService +Export-ModuleMember -Function Stop-ContainerdService -Alias Stop-Containerd Export-ModuleMember -Function Initialize-ContainerdService Export-ModuleMember -Function Uninstall-Containerd \ No newline at end of file From 949cf748b105881a3f83587ffbf2fa09f028167a Mon Sep 17 00:00:00 2001 From: bosira Date: Wed, 29 Nov 2023 08:23:01 +0000 Subject: [PATCH 15/52] restructed file imports --- automation/ContainerdTools.psm1 | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/automation/ContainerdTools.psm1 b/automation/ContainerdTools.psm1 index 40c0278..5092e54 100644 --- a/automation/ContainerdTools.psm1 +++ b/automation/ContainerdTools.psm1 @@ -66,23 +66,6 @@ function Install-Containerd { Write-Output "For containerd usage: run 'containerd -h'" } -function Uninstall-ContainerTool ($tool, $path) { - $pathItems = Get-ChildItem -Path $path -ErrorAction SilentlyContinue - if ($null -eq $pathItems) { - return - } - - Write-Warning "Uninstalling preinstalled $tool at the path $path" - try { - $command = "Uninstall-$tool -Path '$path'" - Invoke-Expression -Command $command - } - catch { - Throw "Could not uninstall $tool. $_" - } -} - - function Start-ContainerdService { Set-Service containerd -StartupType Automatic try { From a3488cd5809dd07ad9c1e3f196af6574e3716cd0 Mon Sep 17 00:00:00 2001 From: bosira Date: Thu, 7 Dec 2023 23:54:19 +0000 Subject: [PATCH 16/52] fix for Uninstall-ContainerTool --- automation/SetUpUtilities.psm1 | 69 +++++++++++++++++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-) diff --git a/automation/SetUpUtilities.psm1 b/automation/SetUpUtilities.psm1 index d6d45dd..418ed68 100644 --- a/automation/SetUpUtilities.psm1 +++ b/automation/SetUpUtilities.psm1 @@ -80,6 +80,22 @@ function Install-RequiredFeature { } } +function Uninstall-ContainerTool ($tool, $path) { + $pathItems = Get-ChildItem -Path $path -ErrorAction SilentlyContinue + if ($null -eq $pathItems) { + return + } + + Write-Warning "Uninstalling preinstalled $tool at the path $path" + try { + $command = "Uninstall-$tool -Path '$path'" + Invoke-Expression -Command $command + } + catch { + Throw "Could not uninstall $tool. $_" + } +} + function Add-FeatureToPath { param ( [string] @@ -111,6 +127,57 @@ function Add-FeatureToPath { } } +function Remove-FeatureFromPath { + param ( + [string] + [ValidateNotNullOrEmpty()] + [parameter(HelpMessage = "Feature to remove from env path")] + $feature + ) + + # Remove from regkey + $currPath = (Get-ItemProperty -Path $envPathRegKey -Name path).path + $currPath = ParsePathString -PathString $currPath + if ($currPath -like "*$feature*") { + $NewPath = removeFeatureFromPath -PathString $currPath -Feature $feature + Set-ItemProperty -Path $envPathRegKey -Name PATH -Value $NewPath + } + + # Remove from env path + $currPath = ParsePathString -PathString $env:Path + if ($currPath -like "*$feature*") { + Write-Information -InformationAction Continue -MessageData "Removing $feature from env path" + $newPathString = removeFeatureFromPath -PathString $currPath -Feature $feature + [Environment]::SetEnvironmentVariable("Path", "$newPathString", [System.EnvironmentVariableTarget]::Machine) + $env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + } +} + +function ParsePathString($pathString) { + $parsedString = $pathString -split ";" | ` + ForEach-Object { $_.TrimEnd("\") } | ` + Select-Object -Unique | ` + Where-Object { ![string]::IsNullOrWhiteSpace($_) } + + if (!$parsedString) { + $DebugPreference = 'Stop' + Write-Debug "Env path cannot be null or an empty string" + } + return $parsedString -join ";" +} + +function RemoveFeatureFromPath ($pathString, $feature) { + $parsedString = $pathString -split ";" | Where-Object { !($_ -like "*$feature*") } + + if (!$parsedString) { + $DebugPreference = 'Stop' + Write-Debug "Env path cannot be null or an empty string" + } + return $parsedString -join ";" +} + Export-ModuleMember -Function Get-LatestToolVersion Export-ModuleMember -Function Install-RequiredFeature -Export-ModuleMember -Function Add-FeatureToPath \ No newline at end of file +Export-ModuleMember -Function Uninstall-ContainerTool +Export-ModuleMember -Function Add-FeatureToPath +Export-ModuleMember -Function Remove-FeatureFromPath \ No newline at end of file From 2f71d71b2083f2c49b514c217d810e4a75589e06 Mon Sep 17 00:00:00 2001 From: bosira Date: Fri, 8 Dec 2023 01:17:21 +0000 Subject: [PATCH 17/52] removed containerd uninstalll logic --- automation/ContainerdTools.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automation/ContainerdTools.psm1 b/automation/ContainerdTools.psm1 index 5092e54..da49832 100644 --- a/automation/ContainerdTools.psm1 +++ b/automation/ContainerdTools.psm1 @@ -22,7 +22,7 @@ function Install-Containerd { ) # Uninstall if tool exists at specified location. Requires user consent - Uninstall-ContainerTool -Tool "ContainerD" -Path $InstallPath + # Uninstall-ContainerTool -Tool "ContainerD" -Path $InstallPath if(!$Version) { # Get default version From 3ba153848a68f6d5f44dfb9c72e0df779a305ef5 Mon Sep 17 00:00:00 2001 From: bosira Date: Fri, 8 Dec 2023 02:43:26 +0000 Subject: [PATCH 18/52] script tp execute the process --- automation/Main.ps1 | 33 ++++++++++++++++++++++++++ automation/Run.ps1 | 57 +++++++++++++++++++++++++++++---------------- 2 files changed, 70 insertions(+), 20 deletions(-) create mode 100644 automation/Main.ps1 diff --git a/automation/Main.ps1 b/automation/Main.ps1 new file mode 100644 index 0000000..23665a6 --- /dev/null +++ b/automation/Main.ps1 @@ -0,0 +1,33 @@ +Import-Module -Name "$PSScriptRoot\ContainerdTools.psm1" -Force +Import-Module -Name "$PSScriptRoot\k8Tools.psm1" -Force +Import-Module -Name "$PSScriptRoot\MinikubeTools.psm1" -Force +Import-Module -Name "$PSScriptRoot\NSSMTools.psm1" -Force + +Install-Containerd +Initialize-ContainerdService +Start-ContainerdService +Install-NSSM +Install-Kubelet +Set-Port + +$IP = minikube ip +$Path = $Path = "C:\Windows\System32\drivers\etc\hosts" + +Add-Host -IP $IP -Path $Path + +Get-Kubeadm + + +$JoinCommand = Get-JoinCommand + +Invoke-Expression $JoinCommand + +Set-MinikubeFolderError + +Invoke-Expression $JoinCommand + +# windows node successfully joined in the cluster +& kubectl get nodes -o wide + + + diff --git a/automation/Run.ps1 b/automation/Run.ps1 index 148812a..06714ef 100644 --- a/automation/Run.ps1 +++ b/automation/Run.ps1 @@ -1,30 +1,47 @@ -Import-Module -Name "$PSScriptRoot\ContainerdTools.psm1" -Force -Import-Module -Name "$PSScriptRoot\k8Tools.psm1" -Force -Import-Module -Name "$PSScriptRoot\MinikubeTools.psm1" -Force -Import-Module -Name "$PSScriptRoot\NSSMTools.psm1" -Force +function Run { + param ( + [string]$VMName, + [string]$UserName, + [string]$Pass + ) -Install-Containerd -Initialize-ContainerdService -Start-ContainerdService -Install-NSSM -Install-Kubelet -Set-Port + $SecurePassword = ConvertTo-SecureString -String $Pass -AsPlainText -Force + $Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $Username, $SecurePassword -$IP = minikube ip -$Path = $Path = "C:\Windows\System32\drivers\etc\hosts" + Enter-PSSession -VMName $VMName -Credential $Credential -Add-Host -IP $IP -Path $Path + # Invoke-Command -VMName $VMName -Credential $Credential -ScriptBlock {Get-Culture} -Get-Kubeadm + $LocalScriptsPath = $PWD + $CompressedFilePath = "$LocalScriptsPath\MinikubeWindowsContainers.zip" + Compress-Archive -Path $LocalScriptsPath -DestinationPath $CompressedFilePath -Force -$JoinCommand = Get-JoinCommand + $RemoteScriptsPath = "C:\Users\Administrator\Documents" -Invoke-Expression $JoinCommand + Copy-Item -Path $CompressedFilePath -Destination $RemoteScriptsPath -Force -ToSession $Session -Set-MinikubeFolderError + $ScriptBlock = { + $CompressedFilePath = "C:\Users\Administrator\Documents\MinikubeWindowsContainers.zip" + $UncompressedFolderPath = "C:\Users\Administrator\Documents" + Expand-Archive -Path $CompressedFilePath -DestinationPath $UncompressedFolderPath -Force + } + + Invoke-Command -VMName $VMName -Credential $Credential -ScriptBlock $ScriptBlock + + $ScriptBlock = { + $UncompressedFolderPath = "C:\Users\Administrator\Documents\MinikubeWindowsContainers" + + Import-Module -Name "$UncompressedFolderPath\automation\ContainerdTools.psm1" -Force + Import-Module -Name "$UncompressedFolderPath\automation\k8Tools.psm1" -Force + Import-Module -Name "$UncompressedFolderPath\automation\MinikubeTools.psm1" -Force + Import-Module -Name "$UncompressedFolderPath\automation\NSSMTools.psm1" -Force + + # Run the main script + . "$UncompressedFolderPath\automation\Main.ps1" + } + + Invoke-Command -VMName $VMName -Credential $Credential -ScriptBlock $ScriptBlock +} -Invoke-Expression $JoinCommand -# windows node successfully joined in the cluster -& kubectl get nodes -o wide \ No newline at end of file From 6c0e96e920087ed896889f5a589bb157be166885 Mon Sep 17 00:00:00 2001 From: bosira Date: Fri, 8 Dec 2023 02:56:23 +0000 Subject: [PATCH 19/52] fix on parent directory reference --- automation/Run.ps1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/automation/Run.ps1 b/automation/Run.ps1 index 06714ef..4fcc9e1 100644 --- a/automation/Run.ps1 +++ b/automation/Run.ps1 @@ -12,7 +12,8 @@ function Run { # Invoke-Command -VMName $VMName -Credential $Credential -ScriptBlock {Get-Culture} - $LocalScriptsPath = $PWD + $CurrrentDirectory = $PWD + $LocalScriptsPath = Split-Path -Path $CurrrentDirectory -Parent $CompressedFilePath = "$LocalScriptsPath\MinikubeWindowsContainers.zip" Compress-Archive -Path $LocalScriptsPath -DestinationPath $CompressedFilePath -Force From 4936277524a67ca4708801edd11d2f2a0d6553b0 Mon Sep 17 00:00:00 2001 From: bosira Date: Fri, 8 Dec 2023 12:09:42 +0000 Subject: [PATCH 20/52] added the missing session declaration --- automation/Run.ps1 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/automation/Run.ps1 b/automation/Run.ps1 index 4fcc9e1..88a2a3f 100644 --- a/automation/Run.ps1 +++ b/automation/Run.ps1 @@ -20,6 +20,8 @@ function Run { $RemoteScriptsPath = "C:\Users\Administrator\Documents" + $session = New-PSSession -VMName $VMName -Credential $Credential + Copy-Item -Path $CompressedFilePath -Destination $RemoteScriptsPath -Force -ToSession $Session $ScriptBlock = { From 1c1900f447d67cf3204c7e7346ec8595c600aa39 Mon Sep 17 00:00:00 2001 From: Bob Sira Date: Mon, 11 Dec 2023 08:16:31 -0800 Subject: [PATCH 21/52] changes to flow of execution --- automation/ContainerdTools.psm1 | 2 +- automation/{Main.ps1 => InitNode.ps1} | 16 ---------- automation/Run.ps1 | 46 +++++++++++++++++++++++++-- 3 files changed, 45 insertions(+), 19 deletions(-) rename automation/{Main.ps1 => InitNode.ps1} (52%) diff --git a/automation/ContainerdTools.psm1 b/automation/ContainerdTools.psm1 index da49832..5092e54 100644 --- a/automation/ContainerdTools.psm1 +++ b/automation/ContainerdTools.psm1 @@ -22,7 +22,7 @@ function Install-Containerd { ) # Uninstall if tool exists at specified location. Requires user consent - # Uninstall-ContainerTool -Tool "ContainerD" -Path $InstallPath + Uninstall-ContainerTool -Tool "ContainerD" -Path $InstallPath if(!$Version) { # Get default version diff --git a/automation/Main.ps1 b/automation/InitNode.ps1 similarity index 52% rename from automation/Main.ps1 rename to automation/InitNode.ps1 index 23665a6..000dad4 100644 --- a/automation/Main.ps1 +++ b/automation/InitNode.ps1 @@ -10,24 +10,8 @@ Install-NSSM Install-Kubelet Set-Port -$IP = minikube ip -$Path = $Path = "C:\Windows\System32\drivers\etc\hosts" -Add-Host -IP $IP -Path $Path -Get-Kubeadm - - -$JoinCommand = Get-JoinCommand - -Invoke-Expression $JoinCommand - -Set-MinikubeFolderError - -Invoke-Expression $JoinCommand - -# windows node successfully joined in the cluster -& kubectl get nodes -o wide diff --git a/automation/Run.ps1 b/automation/Run.ps1 index 88a2a3f..c69c1f8 100644 --- a/automation/Run.ps1 +++ b/automation/Run.ps1 @@ -1,3 +1,5 @@ +Import-Module -Name "$PSScriptRoot\k8Tools.psm1" -Force + function Run { param ( [string]$VMName, @@ -40,11 +42,51 @@ function Run { Import-Module -Name "$UncompressedFolderPath\automation\MinikubeTools.psm1" -Force Import-Module -Name "$UncompressedFolderPath\automation\NSSMTools.psm1" -Force - # Run the main script - . "$UncompressedFolderPath\automation\Main.ps1" + # Initialize Windows Node + . "$UncompressedFolderPath\automation\InitNode.ps1" + + Exit-PSSession } Invoke-Command -VMName $VMName -Credential $Credential -ScriptBlock $ScriptBlock + + + $commandString = "minikube ip" + $IP = Invoke-Expression -Command $commandString + Write-Host "$IP --- IP" + + $ScriptBlock = { + [CmdletBinding()] + param ( + [Parameter()] + [string] + $IP + ) + $UncompressedFolderPath = "C:\Users\Administrator\Documents\MinikubeWindowsContainers" + + Import-Module -Name "$UncompressedFolderPath\automation\MinikubeTools.psm1" -Force + + # Set Host File + #. "$UncompressedFolderPath\automation\SetHost.ps1" + Add-Host -IP $IP + + Exit-PSSession + } + + Invoke-Command -VMName $VMName -Credential $Credential -ScriptBlock $ScriptBlock -ArgumentList $IP + + Get-Kubeadm + + $JoinCommand = Get-JoinCommand + + Invoke-Expression $JoinCommand + + Set-MinikubeFolderError + + Invoke-Expression $JoinCommand + + # windows node successfully joined in the cluster + & kubectl get nodes -o wide } From 9f16ddeb434d5ab5c4ff5cbeb7895b1fdeb68654 Mon Sep 17 00:00:00 2001 From: bosira Date: Mon, 11 Dec 2023 16:30:20 +0000 Subject: [PATCH 22/52] removed unwanted definition --- automation/SetUpUtilities.psm1 | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/automation/SetUpUtilities.psm1 b/automation/SetUpUtilities.psm1 index 418ed68..f771c74 100644 --- a/automation/SetUpUtilities.psm1 +++ b/automation/SetUpUtilities.psm1 @@ -1,27 +1,5 @@ $envPathRegKey = "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" -function Get-HyperV { - $hyperv = Get-WindowsOptionalFeature -FeatureName Microsoft-Hyper-V-All -Online - # Check if Hyper-V is enabled - if($hyperv.State -eq "Enabled") { - Write-Host "Hyper-V is enabled." - } else { - Write-Host "Hyper-V is disabled." - } - -} - -function Set-VmSwitch { - $net = Get-NetAdapter | Where-Object { $_.Status -eq 'Up' } - New-VMSwitch -Name "External VM Switch" -AllowManagementOS $True -NetAdapterName $net.Name -} - -function Get-VmSwitch { - $SwitchName = "External VM Switch" - return $SwitchName - -} - function Get-LatestToolVersion($repository) { try { $uri = "https://api.github.com/repos/$repository/releases/latest" From 85426d6432ba8e9a398f3acf1c4995633d625514 Mon Sep 17 00:00:00 2001 From: bosira Date: Tue, 12 Dec 2023 11:35:55 +0000 Subject: [PATCH 23/52] nssm service check --- automation/NSSMTools.psm1 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/automation/NSSMTools.psm1 b/automation/NSSMTools.psm1 index fc2ac3f..47f58ab 100644 --- a/automation/NSSMTools.psm1 +++ b/automation/NSSMTools.psm1 @@ -1,4 +1,8 @@ function Install-NSSM { + if (Get-Command 'nssm' -ErrorAction SilentlyContinue) { + Write-Output "NSSM is already installed." + return + } if (-not (Test-Path -Path "c:\k" -PathType Container)) { mkdir "c:\k" } From d50cc1ed6bef5b54f64bc0e9dfcb9ec4984784c9 Mon Sep 17 00:00:00 2001 From: Bob Sira Date: Tue, 12 Dec 2023 05:36:37 -0800 Subject: [PATCH 24/52] more error handling code --- automation/MinikubeTools.psm1 | 3 +++ automation/NSSMTools.psm1 | 47 +++-------------------------------- automation/k8Tools.psm1 | 16 ++++++++++-- 3 files changed, 21 insertions(+), 45 deletions(-) diff --git a/automation/MinikubeTools.psm1 b/automation/MinikubeTools.psm1 index 4bc8dfd..6e82b5a 100644 --- a/automation/MinikubeTools.psm1 +++ b/automation/MinikubeTools.psm1 @@ -44,6 +44,9 @@ function Get-JoinCommand { # Append '--cri-socket "npipe:////./pipe/containerd-containerd"' $outputString += ' --cri-socket "npipe:////./pipe/containerd-containerd"' + # View stack trace + $outputString += ' --v=5' + # Print the modified string Write-Host $outputString diff --git a/automation/NSSMTools.psm1 b/automation/NSSMTools.psm1 index 47f58ab..a933dc2 100644 --- a/automation/NSSMTools.psm1 +++ b/automation/NSSMTools.psm1 @@ -1,55 +1,16 @@ function Install-NSSM { - if (Get-Command 'nssm' -ErrorAction SilentlyContinue) { + $nssmService = Get-WmiObject win32_service | Where-Object {$_.PathName -like '*nssm*'} + if ($nssmService) { Write-Output "NSSM is already installed." return } + if (-not (Test-Path -Path "c:\k" -PathType Container)) { mkdir "c:\k" } $arch = "win64" curl.exe -L https://k8stestinfrabinaries.blob.core.windows.net/nssm-mirror/nssm-2.24.zip -o nssm.zip tar.exe C c:\k\ -xvf .\nssm.zip --strip-components 2 */$arch/*.exe - } -Export-ModuleMember -Function Install-NSSM - -# function Install-NSSM { -# param( -# [string] -# [ValidateNotNullOrEmpty()] -# [parameter(HelpMessage = "NSSM version to use. Default 2.24")] -# $Version = "2.24", - -# [String] -# [parameter(HelpMessage = "Architecture ")] -# $Arch = "win64", - -# [String] -# [parameter(HelpMessage = "Path to download files.")] -# $DownloadPath = "c:\k" -# ) - -# $Version = $Version.TrimStart('v') - -# $nssmTarFile = "nssm-${version}.zip" -# $Uri = "https://k8stestinfrabinaries.blob.core.windows.net/nssm-mirror/$($nssmTarFile)" -# $params = @{ -# Feature = "nssm" -# Version = $Version -# Uri = $Uri -# InstallPath = $InstallPath -# DownloadPath = "$DownloadPath\$containerdTarFile" -# EnvPath = $EnvPath -# cleanup = $true -# } - -# Write-Output "Downloading and installing Containerd at $InstallPath" -# Invoke-WebRequest -Uri $Uri -OutFile $DownloadPath\$containerdTarFile -Verbose -# Install-RequiredFeature @params - -# Write-Output "Containerd successfully installed at $InstallPath" -# containerd.exe -v - -# Write-Output "For containerd usage: run 'containerd -h'" -# } \ No newline at end of file +Export-ModuleMember -Function Install-NSSM \ No newline at end of file diff --git a/automation/k8Tools.psm1 b/automation/k8Tools.psm1 index 7f00f76..51ab05d 100644 --- a/automation/k8Tools.psm1 +++ b/automation/k8Tools.psm1 @@ -5,6 +5,13 @@ function Install-Kubelet { $KubernetesVersion = "v1.27.3" ) + # Check if kubelet service is already installed + $nssmService = Get-WmiObject win32_service | Where-Object {$_.PathName -like '*nssm*'} + if ($nssmService.Name -eq 'kubelet') { + Write-Output "Kubelet service is already installed." + return + } + # Define the URL for kubelet download $KubeletUrl = "https://dl.k8s.io/$KubernetesVersion/bin/windows/amd64/kubelet.exe" @@ -37,8 +44,13 @@ Invoke-Expression `$kubeletCommandLine } function Set-Port { - New-NetFirewallRule -Name kubelet -DisplayName 'kubelet' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 10250 - + $firewallRule = Get-NetFirewallRule -Name 'kubelet' -ErrorAction SilentlyContinue + if ($firewallRule) { + Write-Output "Firewall rule 'kubelet' already exists." + return + } + + New-NetFirewallRule -Name 'kubelet' -DisplayName 'kubelet' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 10250 } function Get-Kubeadm { From c508c3860cd2a6ce81d066b106ff800f9110d5ab Mon Sep 17 00:00:00 2001 From: Bob Sira Date: Wed, 13 Dec 2023 08:40:00 -0800 Subject: [PATCH 25/52] folder creation error handling --- automation/MinikubeTools.psm1 | 13 ++++++++++--- automation/Run.ps1 | 5 +---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/automation/MinikubeTools.psm1 b/automation/MinikubeTools.psm1 index 6e82b5a..423d91b 100644 --- a/automation/MinikubeTools.psm1 +++ b/automation/MinikubeTools.psm1 @@ -55,9 +55,16 @@ function Get-JoinCommand { } function Set-MinikubeFolderError { - mkdir c:\var\lib\minikube\certs - Copy-Item C:\etc\kubernetes\pki\ca.crt -Destination C:\var\lib\Minikube\Certs - Remove-Item C:\etc\kubernetes\pki\ca.crt + if (!(Test-Path -Path c:\var\lib\minikube\certs)) { + mkdir c:\var\lib\minikube\certs + } + + if (Test-Path -Path C:\etc\kubernetes\pki\ca.crt) { + Copy-Item C:\etc\kubernetes\pki\ca.crt -Destination C:\var\lib\Minikube\Certs + Remove-Item C:\etc\kubernetes\pki\ca.crt + } else { + Write-Output "File C:\etc\kubernetes\pki\ca.crt does not exist." + } } function Add-Host { diff --git a/automation/Run.ps1 b/automation/Run.ps1 index c69c1f8..3c07ac0 100644 --- a/automation/Run.ps1 +++ b/automation/Run.ps1 @@ -1,4 +1,5 @@ Import-Module -Name "$PSScriptRoot\k8Tools.psm1" -Force +Import-Module -Name "$PSScriptRoot\MinikubeTools.psm1" -Force function Run { param ( @@ -42,7 +43,6 @@ function Run { Import-Module -Name "$UncompressedFolderPath\automation\MinikubeTools.psm1" -Force Import-Module -Name "$UncompressedFolderPath\automation\NSSMTools.psm1" -Force - # Initialize Windows Node . "$UncompressedFolderPath\automation\InitNode.ps1" Exit-PSSession @@ -53,7 +53,6 @@ function Run { $commandString = "minikube ip" $IP = Invoke-Expression -Command $commandString - Write-Host "$IP --- IP" $ScriptBlock = { [CmdletBinding()] @@ -66,8 +65,6 @@ function Run { Import-Module -Name "$UncompressedFolderPath\automation\MinikubeTools.psm1" -Force - # Set Host File - #. "$UncompressedFolderPath\automation\SetHost.ps1" Add-Host -IP $IP Exit-PSSession From a4c14e2418af05638ce937a3773829b2f8c952ac Mon Sep 17 00:00:00 2001 From: Bob Sira Date: Wed, 13 Dec 2023 17:03:21 -0800 Subject: [PATCH 26/52] fix initialize containerd logic --- automation/ContainerdTools.psm1 | 24 +++++++++--------------- automation/Run.ps1 | 2 ++ 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/automation/ContainerdTools.psm1 b/automation/ContainerdTools.psm1 index 5092e54..887a4e3 100644 --- a/automation/ContainerdTools.psm1 +++ b/automation/ContainerdTools.psm1 @@ -137,32 +137,26 @@ function Initialize-ContainerdService { @{ Find = 'conf_dir = "C:\\Program Files\\containerd\\cni\\conf"' Replace = 'conf_dir = "c:\\etc\\cni\\net.d\\"' - } + } ) - # check if replacements are neede and perform them in one iteration - $replacementsNeeded = $false + # Perform the check and replacement in one loop + $replacementsMade = $false foreach($replacement in $replacements) { - if ($containerdConfigContent -contains $replacement.Find) { - $replacementsNeeded = $true + if ($containerdConfigContent -match [regex]::Escape($replacement.Find)) { $containerdConfigContent = $containerdConfigContent -replace [regex]::Escape($replacement.Find), $replacement.Replace + $replacementsMade = $true } } - # Perform the replacements only if needed - if ($replacementsNeeded) { - # Save the modified content back to the config.toml file - Set-Content -Path $containerdConfigFile -Value $containerdConfigContent - + # Write the modified content back to the config.toml file if any replacements were made + if ($replacementsMade) { + $containerdConfigContent | Set-Content -Path $containerdConfigFile # Output a message indicating the changes Write-Host "Changes applied to $containerdConfigFile" - } else { + } else { Write-Host "No changes needed in $containerdConfigFile" } - - - # Output a message indicating the changes - Write-Host "Changes applied to $containerdConfigFile" # Create the folders if they do not exist $binDir = "c:\opt\cni\bin" diff --git a/automation/Run.ps1 b/automation/Run.ps1 index 3c07ac0..45228d4 100644 --- a/automation/Run.ps1 +++ b/automation/Run.ps1 @@ -1,5 +1,7 @@ +Import-Module -Name "$PSScriptRoot\ContainerdTools.psm1" -Force Import-Module -Name "$PSScriptRoot\k8Tools.psm1" -Force Import-Module -Name "$PSScriptRoot\MinikubeTools.psm1" -Force +Import-Module -Name "$PSScriptRoot\NSSMTools.psm1" -Force function Run { param ( From 9ed73509ed3035a527845eee06840e746a41c4da Mon Sep 17 00:00:00 2001 From: Bob Sira Date: Wed, 13 Dec 2023 18:09:41 -0800 Subject: [PATCH 27/52] indentation fix in hosts file --- automation/MinikubeTools.psm1 | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/automation/MinikubeTools.psm1 b/automation/MinikubeTools.psm1 index 423d91b..2f0f74d 100644 --- a/automation/MinikubeTools.psm1 +++ b/automation/MinikubeTools.psm1 @@ -77,8 +77,13 @@ function Add-Host { $Path = "C:\Windows\System32\drivers\etc\hosts" ) - Add-Content -Path $Path -Value "`n`t`t$IP`tcontrol-plane.minikube.internal" -Force - + $entry = "`t$IP`tcontrol-plane.minikube.internal" + + $hostsContent = Get-Content -Path $Path -Raw + if ($hostsContent -notmatch [regex]::Escape($entry)) { + # If the entry does not exist, add it + Add-Content -Path $Path -Value "$entry" -Force + } } From f8ff45eb71ed78253bd8a36ee45a9aac3b99b22f Mon Sep 17 00:00:00 2001 From: Bob Sira Date: Wed, 3 Jan 2024 08:35:25 -0800 Subject: [PATCH 28/52] phase one remoting complete --- automation/MinikubeTools.psm1 | 11 ----------- automation/Run.ps1 | 36 ++++++++++++++++++++++++++++++----- 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/automation/MinikubeTools.psm1 b/automation/MinikubeTools.psm1 index 2f0f74d..69e8976 100644 --- a/automation/MinikubeTools.psm1 +++ b/automation/MinikubeTools.psm1 @@ -35,21 +35,11 @@ function Get-JoinCommand { [ValidateNotNullOrEmpty()] $Version = "v1.27.3" ) - $JoinCommand = (minikube ssh "cd /var/lib/minikube/binaries/v1.27.3/ && sudo ./kubeadm token create --print-join-command") - - # Replace 'kubeadm' with '.\kubeadm' $outputString = $JoinCommand -replace 'kubeadm', '.\kubeadm' - - # Append '--cri-socket "npipe:////./pipe/containerd-containerd"' $outputString += ' --cri-socket "npipe:////./pipe/containerd-containerd"' - - # View stack trace $outputString += ' --v=5' - - # Print the modified string Write-Host $outputString - return $outputString } @@ -81,7 +71,6 @@ function Add-Host { $hostsContent = Get-Content -Path $Path -Raw if ($hostsContent -notmatch [regex]::Escape($entry)) { - # If the entry does not exist, add it Add-Content -Path $Path -Value "$entry" -Force } } diff --git a/automation/Run.ps1 b/automation/Run.ps1 index 45228d4..d079e32 100644 --- a/automation/Run.ps1 +++ b/automation/Run.ps1 @@ -73,19 +73,45 @@ function Run { } Invoke-Command -VMName $VMName -Credential $Credential -ScriptBlock $ScriptBlock -ArgumentList $IP - - Get-Kubeadm + $JoinCommand = Get-JoinCommand - Invoke-Expression $JoinCommand + $ScriptBlock = { + [CmdletBinding()] + param ( + [Parameter()] + [string] + $JoinCommand + ) + $UncompressedFolderPath = "C:\Users\Administrator\Documents\MinikubeWindowsContainers" + + Import-Module -Name "$UncompressedFolderPath\automation\MinikubeTools.psm1" -Force + Import-Module -Name "$UncompressedFolderPath\automation\k8Tools.psm1" -Force + + Get-Kubeadm + + Invoke-Expression $JoinCommand - Set-MinikubeFolderError + Set-MinikubeFolderError - Invoke-Expression $JoinCommand + Invoke-Expression $JoinCommand + + Exit-PSSession + } + + Invoke-Command -VMName $VMName -Credential $Credential -ScriptBlock $ScriptBlock -ArgumentList $JoinCommand # windows node successfully joined in the cluster & kubectl get nodes -o wide + + # & kubectl apply -f "$UncompressedFolderPath\flannel-overlay.yaml" + + # & kubectl apply -f "$UncompressedFolderPathkube\kube-proxy.yaml" + + # & kubectl get pods -A + + # & kubectl get nodes -o wide } From 29505da9c2138411d585a08378e6e50afefb4f1f Mon Sep 17 00:00:00 2001 From: bosira Date: Mon, 15 Jan 2024 01:59:07 +0000 Subject: [PATCH 29/52] containerd setup modification --- automation/ContainerdTools.psm1 | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/automation/ContainerdTools.psm1 b/automation/ContainerdTools.psm1 index 887a4e3..caa214a 100644 --- a/automation/ContainerdTools.psm1 +++ b/automation/ContainerdTools.psm1 @@ -7,11 +7,6 @@ function Get-ContainerdLatestVersion { function Install-Containerd { param( - [string] - [ValidateNotNullOrEmpty()] - [parameter(HelpMessage = "ContainerD version to use. Default 1.7.6")] - $Version, - [String] [parameter(HelpMessage = "Path to install containerd. Defaults to ~\program files\containerd")] $InstallPath = "$Env:ProgramFiles\containerd", @@ -24,10 +19,7 @@ function Install-Containerd { # Uninstall if tool exists at specified location. Requires user consent Uninstall-ContainerTool -Tool "ContainerD" -Path $InstallPath - if(!$Version) { - # Get default version - $Version = Get-ContainerdLatestVersion - } + $Version = Get-ContainerdLatestVersion $Version = $Version.TrimStart('v') Write-Output "Downloading and installing Containerd v$version at $InstallPath" @@ -40,10 +32,6 @@ function Install-Containerd { Invoke-WebRequest -Uri $Uri -OutFile $DownloadPath\$containerdTarFile -Verbose } catch { - if ($_.ErrorDetails.Message -eq "Not found") { - Throw "Containerd download failed. Invalid URL: $uri" - } - Throw "Containerd download failed. $_" } @@ -78,7 +66,6 @@ function Start-ContainerdService { Throw "Couldn't start Containerd service. $_" } - Get-Service *containerd* | Select-Object Name, DisplayName, ServiceName, ServiceType, StartupType, Status, RequiredServices, ServicesDependedOn } function Stop-ContainerdService { @@ -163,12 +150,12 @@ function Initialize-ContainerdService { $confDir = "c:\etc\cni\net.d" if (!(Test-Path $binDir)) { - mkdir $binDir + mkdir $binDir | Out-Null Write-Host "Created $binDir" } if (!(Test-Path $confDir)) { - mkdir $confDir + mkdir $confDir | Out-Null Write-Host "Created $confDir" } From af70e9a15719847be3f2cfe8d45e892f62b3ca72 Mon Sep 17 00:00:00 2001 From: bosira Date: Mon, 15 Jan 2024 02:43:00 +0000 Subject: [PATCH 30/52] feedback on remote work --- README.md | 2 +- automation/InitNode.ps1 | 6 --- automation/MinikubeTools.psm1 | 1 - automation/NSSMTools.psm1 | 2 +- automation/NodeManTools.psm1 | 61 ------------------------ automation/Remote.psm1 | 87 +++++++++++++++++++++++++++-------- automation/Run.ps1 | 11 +---- 7 files changed, 72 insertions(+), 98 deletions(-) delete mode 100644 automation/NodeManTools.psm1 diff --git a/README.md b/README.md index cf8a570..12f3dc4 100644 --- a/README.md +++ b/README.md @@ -117,7 +117,7 @@ cd $Env:ProgramFiles\containerd\ notepad config.toml ``` -The command above will copy the ContainerD binaries to the Program Files folder, and create a new config file. After that, Notepad will open so you can change some settings. You need to change the folling parameters: +The command above will copy the ContainerD binaries to the Program Files folder, and create a new config file. After that, Notepad will open so you can change some settings. You need to change the following parameters: |Setting|Old value|New Value| |-------------|----------------|----------------| diff --git a/automation/InitNode.ps1 b/automation/InitNode.ps1 index 000dad4..9fba52c 100644 --- a/automation/InitNode.ps1 +++ b/automation/InitNode.ps1 @@ -9,9 +9,3 @@ Start-ContainerdService Install-NSSM Install-Kubelet Set-Port - - - - - - diff --git a/automation/MinikubeTools.psm1 b/automation/MinikubeTools.psm1 index 69e8976..7e48401 100644 --- a/automation/MinikubeTools.psm1 +++ b/automation/MinikubeTools.psm1 @@ -17,7 +17,6 @@ function Get-LinuxMasterNodeIP { function Set-Flannel { param ( [string] - [ValidateNotNullOrEmpty()] $NodeName ) diff --git a/automation/NSSMTools.psm1 b/automation/NSSMTools.psm1 index a933dc2..e8c6765 100644 --- a/automation/NSSMTools.psm1 +++ b/automation/NSSMTools.psm1 @@ -6,7 +6,7 @@ function Install-NSSM { } if (-not (Test-Path -Path "c:\k" -PathType Container)) { - mkdir "c:\k" + mkdir "c:\k" | Out-Null } $arch = "win64" curl.exe -L https://k8stestinfrabinaries.blob.core.windows.net/nssm-mirror/nssm-2.24.zip -o nssm.zip diff --git a/automation/NodeManTools.psm1 b/automation/NodeManTools.psm1 deleted file mode 100644 index 4d632aa..0000000 --- a/automation/NodeManTools.psm1 +++ /dev/null @@ -1,61 +0,0 @@ -function Start-VirtualMachine { - param ( - [String] - [ValidateNotNullOrEmpty()] - $VMName, - - [String] - [ValidateNotNullOrEmpty()] - $SwitchName, - - [String] - [ValidateNotNullOrEmpty()] - $ISOFile - ) - - $VM = @{ - Name = $VMName - MemoryStartupBytes = 1GB - NewVHDPath = "${env:homepath}\.minikube\machines\$VMName\VHD.vhdx" - NewVHDSizeBytes = 10GB - BootDevice = "VHD" - Path = "${env:homepath}\.minikube\machines\" - SwitchName = (Get-VMSwitch).Name - } - - New-VM @VM - - # New-VM -Name $VMName -Generation 1 -MemoryStartupBytes 6000MB -Path ${env:homepath}\.minikube\machines\ -NewVHDPath ${env:homepath}\.minikube\machines\$VMName\VHD.vhdx -NewVHDSizeBytes 127000MB -SwitchName $SwitchName - Set-VM -Name $VMName -ProcessorCount 2 -AutomaticCheckpointsEnabled $false - Set-VMProcessor -VMName $VMName -ExposeVirtualizationExtensions $true - Set-VMDvdDrive -VMName $VMName -Path $ISOFile - Start-VM -Name $VMName -} - -function Set-NodeForMinikube { - param( - [string] - [ValidateNotNullOrEmpty()] - $NewName = "minikube-m03" - ) - - Set-SConfig -AutoLaunch $false - Restart-Computer -Force - Install-WindowsFeature -Name containers - Restart-Computer -Force - -} - - -function Remove-VirtualMachine { - param ( - [String] - [ValidateNotNullOrEmpty()] - $VMName - ) - - Stop-VM -Name $VMName -TurnOff - Remove-VM -Name $VMName -Force - Remove-Item -Path ${env:homepath}\.minikube\machines\$VMName -Force -Recurse - -} \ No newline at end of file diff --git a/automation/Remote.psm1 b/automation/Remote.psm1 index cf0dd02..1abfbf9 100644 --- a/automation/Remote.psm1 +++ b/automation/Remote.psm1 @@ -1,38 +1,89 @@ -# $VMName = 'minikube-m03'; -# $UserName = 'Administrator'; -# $Password = 'M@kindu.2021'; -function Set-Credential { +function Get-HyperV { + $hyperv = Get-WindowsOptionalFeature -FeatureName Microsoft-Hyper-V-All -Online + if($hyperv.State -eq "Enabled") { + Write-Host "Hyper-V is enabled." + } else { + Write-Host "Hyper-V is disabled." + } + +} + +function Set-VmSwitch { + param ( + [String] + [ValidateNotNullOrEmpty()] + $SwitchName = 'External VM Switch' + ) + $Switch = Get-VMSwitch -Name $SwitchName -ErrorAction SilentlyContinue + if ($Switch -eq $null) { + New-VMSwitch -Name $SwitchName -AllowManagementOS $True -NetAdapterName (Get-NetAdapter | Where-Object {$_.Status -eq 'Up' -and $_.Name -notlike '*vEthernet*'}).Name + } + # assign the switch created to a variable and return it from the function + $Switch = Get-VMSwitch -Name $SwitchName + return $Switch +} + +# pass switch as parameter +function Start-VirtualMachine { param ( [String] [ValidateNotNullOrEmpty()] - $VMName = 'minikube-m03', + $VMName, - [String] + [String] [ValidateNotNullOrEmpty()] - $UserName = 'Administrator', + $SwitchName, [String] [ValidateNotNullOrEmpty()] - $Pass = 'M@kindu.2021' + $ISOFile ) - $SecurePassword = ConvertTo-SecureString -String $Password -AsPlainText -Force; - $Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $Username, $SecurePassword ; + # set the vm switch first + $Switch = Set-VmSwitch -SwitchName $SwitchName + + $VM = @{ + Name = $VMName + MemoryStartupBytes = 1GB + NewVHDPath = "${env:homepath}\.minikube\machines\$VMName\VHD.vhdx" + NewVHDSizeBytes = 10GB + BootDevice = "VHD" + Path = "${env:homepath}\.minikube\machines\" + SwitchName = $Switch.Name + } - return $Credential + New-VM @VM + Set-VM -Name $VMName -ProcessorCount 2 -AutomaticCheckpointsEnabled $false + Set-VMProcessor -VMName $VMName -ExposeVirtualizationExtensions $true + Set-VMDvdDrive -VMName $VMName -Path $ISOFile + Start-VM -Name $VMName } -function Start-RemoteSession { - param ( - [String] +function Set-NodeForMinikube { + param( + [string] [ValidateNotNullOrEmpty()] - $VMName, + $NewName = "minikube-m03" + ) - [PSCredential] + Set-SConfig -AutoLaunch $false + Restart-Computer -Force + Install-WindowsFeature -Name containers + Restart-Computer -Force + +} + + +function Remove-VirtualMachine { + param ( + [String] [ValidateNotNullOrEmpty()] - $Credential + $VMName ) + + Stop-VM -Name $VMName -TurnOff + Remove-VM -Name $VMName -Force + Remove-Item -Path ${env:homepath}\.minikube\machines\$VMName -Force -Recurse - Enter-PSSession -VMName $VMName -Credential $Credential; } \ No newline at end of file diff --git a/automation/Run.ps1 b/automation/Run.ps1 index d079e32..f281bc1 100644 --- a/automation/Run.ps1 +++ b/automation/Run.ps1 @@ -105,13 +105,4 @@ function Run { # windows node successfully joined in the cluster & kubectl get nodes -o wide - # & kubectl apply -f "$UncompressedFolderPath\flannel-overlay.yaml" - - # & kubectl apply -f "$UncompressedFolderPathkube\kube-proxy.yaml" - - # & kubectl get pods -A - - # & kubectl get nodes -o wide -} - - +} \ No newline at end of file From 7f572131b05c6d6d49aece8f32657a24f597e7db Mon Sep 17 00:00:00 2001 From: Bob Sira Date: Thu, 25 Jan 2024 02:46:48 -0800 Subject: [PATCH 31/52] intial authoring of auto install file --- automation/autounattend.xml | 224 ++++++++++++++++++++++++++++++++++++ 1 file changed, 224 insertions(+) create mode 100644 automation/autounattend.xml diff --git a/automation/autounattend.xml b/automation/autounattend.xml new file mode 100644 index 0000000..8453a52 --- /dev/null +++ b/automation/autounattend.xml @@ -0,0 +1,224 @@ + + + + + + + en-US + + en-US + en-US + en-US + en-US + en-US + + + + + + + + + + + 1 + Primary + 499 + + + + 2 + EFI + 280 + + + + 3 + MSR + 16 + + + + 4 + Primary + true + + + + + + 1 + 1 + + NTFS + de94bba4-06d1-4d40-a16a-bfd50179d6ac + + + + 2 + 2 + + FAT32 + + + + 3 + 3 + + + + 4 + 4 + + NTFS + C + + + 0 + true + + + + + + + + + /IMAGE/INDEX + 3 + + + + 0 + 4 + + + + + + + + + + OnError + + true + Bosira + Microsoft + + + + + + + en-US + en-US + en-US + en-US + en-US + + + + minikube-m05 + Central Standard Time + true + + + + true + + + + + + + + YQB1AHQAbwBtAGEAdABlAHMAcQBsAFAAYQBzAHMAdwBvAHIAZAA= + false</PlainText> + </Password> + <Enabled>true</Enabled> + <Username>Administrator</Username> + </AutoLogon> + <FirstLogonCommands> + <SynchronousCommand wcm:action="add"> + <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -Command New-SelfSignedCertificate -CertstoreLocation Cert:\LocalMachine\My -DnsName "WinRMCertificate"</CommandLine> + <Description>Certificate for WinRM</Description> + <Order>1</Order> + <RequiresUserInput>true</RequiresUserInput> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -Command Enable-PSRemoting -SkipNetworkProfileCheck -Force</CommandLine> + <Description>Enable WinRM</Description> + <Order>2</Order> + <RequiresUserInput>true</RequiresUserInput> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -Command ($cert = gci Cert:\LocalMachine\My\) -and (New-Item -Path WSMan:\LocalHost\Listener -Transport HTTPS -Address * -CertificateThumbPrint $cert.Thumbprint –Force)</CommandLine> + <Description>Add HTTPS WinRM listener with previously generated certificate</Description> + <Order>3</Order> + <RequiresUserInput>true</RequiresUserInput> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -Command New-NetFirewallRule -DisplayName 'Windows Remote Management (HTTPS-In)' -Name 'Windows Remote Management (HTTPS-In)' -Profile Any -LocalPort 5986 -Protocol TCP</CommandLine> + <Description>Add firewall exception to TCP port 5986 for WinRM over HTTPS</Description> + <Order>4</Order> + <RequiresUserInput>true</RequiresUserInput> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -Command Set-Item WSMan:\localhost\Service\Auth\Basic -Value $true</CommandLine> + <Description>Enable Basic authentication</Description> + <Order>5</Order> + <RequiresUserInput>true</RequiresUserInput> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -Command Stop-Service WinRM</CommandLine> + <Description>Stop the WinRM service to allow the dism process to finish before packer executes scripts</Description> + <Order>6</Order> + <RequiresUserInput>true</RequiresUserInput> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -Command Restart-Computer -Force</CommandLine> + <Order>7</Order> + <Description>Restart computer to apply changes</Description> + </SynchronousCommand> + </FirstLogonCommands> + <OOBE> + <HideEULAPage>true</HideEULAPage> + <HideLocalAccountScreen>true</HideLocalAccountScreen> + <HideOEMRegistrationScreen>true</HideOEMRegistrationScreen> + <HideOnlineAccountScreens>true</HideOnlineAccountScreens> + <HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE> + <ProtectYourPC>1</ProtectYourPC> + </OOBE> + <UserAccounts> + <AdministratorPassword> + <Value>TQBAAGsAaQBuAGQAdQAuADIAMAAyADMAQQBkAG0AaQBuAGkAcwB0AHIAYQB0AG8AcgBQAGEAcwBzAHcAbwByAGQA</Value> + <PlainText>false</PlainText> + </AdministratorPassword> + </UserAccounts> + <RegisteredOwner /> + </component> + <component name="Microsoft-Windows-International-Core" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <InputLocale>en-US</InputLocale> + <SystemLocale>en-US</SystemLocale> + <UILanguage>en-US</UILanguage> + <UILanguageFallback>en-US</UILanguageFallback> + <UserLocale>en-US</UserLocale> + </component> + </settings> + <settings pass="offlineServicing"> + <component name="Microsoft-Windows-LUA-Settings" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <!-- https://docs.microsoft.com/en-us/windows-hardware/customize/desktop/unattend/microsoft-windows-lua-settings --> + <EnableLUA>false</EnableLUA> + </component> + </settings> + <settings pass="generalize"> + <component name="Microsoft-Windows-Security-SPP" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="NonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <SkipRearm>1</SkipRearm> + </component> + <component name="Microsoft-Windows-PnpSysprep" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <DoNotCleanUpNonPresentDevices>false</DoNotCleanUpNonPresentDevices> + </component> + </settings> + <cpi:offlineImage cpi:source="wim:d:/minikubewindowscontainers/install.wim#Windows Server 2022 SERVERDATACENTERCORE" xmlns:cpi="urn:schemas-microsoft-com:cpi" /> +</unattend> From d29165299ba582b0d273cfbee1182baf27523920 Mon Sep 17 00:00:00 2001 From: Bob Sira <bosira@microsoft.com> Date: Tue, 30 Jan 2024 00:56:01 -0800 Subject: [PATCH 32/52] BIOS/MBR-Based Hard Disk answer file --- automation/autounattend.xml | 110 +++++++----------------------------- 1 file changed, 20 insertions(+), 90 deletions(-) diff --git a/automation/autounattend.xml b/automation/autounattend.xml index 8453a52..9d6e68b 100644 --- a/automation/autounattend.xml +++ b/automation/autounattend.xml @@ -2,76 +2,42 @@ <unattend xmlns="urn:schemas-microsoft-com:unattend"> <settings pass="windowsPE"> <component name="Microsoft-Windows-International-Core-WinPE" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <!-- https://docs.microsoft.com/en-us/windows-hardware/customize/desktop/unattend/microsoft-windows-international-core-winpe --> <SetupUILanguage> <UILanguage>en-US</UILanguage> </SetupUILanguage> - <InputLocale>en-US</InputLocale> + <InputLocale>en-US</InputLocale> <SystemLocale>en-US</SystemLocale> <UILanguage>en-US</UILanguage> - <UILanguageFallback>en-US</UILanguageFallback> <UserLocale>en-US</UserLocale> </component> <component name="Microsoft-Windows-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <!-- https://docs.microsoft.com/en-us/windows-hardware/customize/desktop/unattend/microsoft-windows-setup --> <DiskConfiguration> - <!-- https://docs.microsoft.com/en-us/windows-hardware/customize/desktop/unattend/microsoft-windows-setup-diskconfiguration --> - <!-- https://docs.microsoft.com/en-us/windows-hardware/customize/desktop/unattend/microsoft-windows-setup-diskconfiguration-disk-modifypartitions-modifypartition-typeid --> <Disk wcm:action="add"> <CreatePartitions> - <!-- Windows RE Tools partition --> <CreatePartition wcm:action="add"> + <Size>250</Size> <Order>1</Order> <Type>Primary</Type> - <Size>499</Size> </CreatePartition> - <!-- System partition (ESP) --> <CreatePartition wcm:action="add"> <Order>2</Order> - <Type>EFI</Type> - <Size>280</Size> - </CreatePartition> - <!-- Microsoft reserved partition (MSR) --> - <CreatePartition wcm:action="add"> - <Order>3</Order> - <Type>MSR</Type> - <Size>16</Size> - </CreatePartition> - <!-- Windows partition --> - <CreatePartition wcm:action="add"> - <Order>4</Order> - <Type>Primary</Type> <Extend>true</Extend> + <Type>Primary</Type> </CreatePartition> </CreatePartitions> <ModifyPartitions> - <!-- Windows RE Tools partition --> <ModifyPartition wcm:action="add"> <Order>1</Order> <PartitionID>1</PartitionID> - <Label>Recovery</Label> <Format>NTFS</Format> - <TypeID>de94bba4-06d1-4d40-a16a-bfd50179d6ac</TypeID> + <Label>Boot</Label> + <Active>true</Active> </ModifyPartition> - <!-- System partition (ESP) --> <ModifyPartition wcm:action="add"> <Order>2</Order> <PartitionID>2</PartitionID> - <Label>System</Label> - <Format>FAT32</Format> - </ModifyPartition> - <!-- MSR partition does not need to be modified --> - <ModifyPartition wcm:action="add"> - <Order>3</Order> - <PartitionID>3</PartitionID> - </ModifyPartition> - <!-- Windows partition --> - <ModifyPartition wcm:action="add"> - <Order>4</Order> - <PartitionID>4</PartitionID> - <Label>Windows</Label> <Format>NTFS</Format> - <Letter>C</Letter> + <Label>System</Label> </ModifyPartition> </ModifyPartitions> <DiskID>0</DiskID> @@ -81,30 +47,25 @@ <ImageInstall> <OSImage> <InstallFrom> - <!-- https://docs.microsoft.com/en-us/windows-hardware/customize/desktop/unattend/microsoft-windows-setup-imageinstall-dataimage-installfrom-metadata-key --> - <!-- Get-WindowsImage -ImagePath D:\sources\install.wim --> <MetaData wcm:action="add"> <Key>/IMAGE/INDEX </Key> - <Value>3</Value> + <Value>2</Value> </MetaData> </InstallFrom> <InstallTo> <DiskID>0</DiskID> - <PartitionID>4</PartitionID> + <PartitionID>2</PartitionID> </InstallTo> + <WillShowUI>OnError</WillShowUI> + <InstallToAvailablePartition>false</InstallToAvailablePartition> </OSImage> </ImageInstall> <UserData> - <!-- Product Key from http://technet.microsoft.com/en-us/library/jj612867.aspx --> + <AcceptEula>true</AcceptEula> <ProductKey> - <!-- Do not uncomment the Key element if you are using trial ISOs --> - <!-- You must uncomment the Key element (and optionally insert your own key) if you are using retail or volume license ISOs --> - <!-- <Key>WX4NM-KYWYW-QJJR4-XV3QB-6VM33</Key> --> - <WillShowUI>OnError</WillShowUI> + <WillShowUI>Never</WillShowUI> + <!-- <Key>11111-22222-33333-44444-55555</Key> --> </ProductKey> - <AcceptEula>true</AcceptEula> - <FullName>Bosira</FullName> - <Organization>Microsoft</Organization> </UserData> </component> </settings> @@ -130,14 +91,13 @@ </settings> <settings pass="oobeSystem"> <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <!-- https://docs.microsoft.com/en-us/windows-hardware/customize/desktop/unattend/microsoft-windows-shell-setup --> <AutoLogon> <Password> - <Value>YQB1AHQAbwBtAGEAdABlAHMAcQBsAFAAYQBzAHMAdwBvAHIAZAA=</Value> - <PlainText>false</PlainText> + <Value>M@kindu.2023</Value> + <PlainText>true</PlainText> </Password> - <Enabled>true</Enabled> <Username>Administrator</Username> + <Enabled>true</Enabled> </AutoLogon> <FirstLogonCommands> <SynchronousCommand wcm:action="add"> @@ -182,43 +142,13 @@ <Description>Restart computer to apply changes</Description> </SynchronousCommand> </FirstLogonCommands> - <OOBE> - <HideEULAPage>true</HideEULAPage> - <HideLocalAccountScreen>true</HideLocalAccountScreen> - <HideOEMRegistrationScreen>true</HideOEMRegistrationScreen> - <HideOnlineAccountScreens>true</HideOnlineAccountScreens> - <HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE> - <ProtectYourPC>1</ProtectYourPC> - </OOBE> <UserAccounts> <AdministratorPassword> - <Value>TQBAAGsAaQBuAGQAdQAuADIAMAAyADMAQQBkAG0AaQBuAGkAcwB0AHIAYQB0AG8AcgBQAGEAcwBzAHcAbwByAGQA</Value> - <PlainText>false</PlainText> + <Value>M@kindu.2023</Value> + <PlainText>true</PlainText> </AdministratorPassword> </UserAccounts> - <RegisteredOwner /> - </component> - <component name="Microsoft-Windows-International-Core" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <InputLocale>en-US</InputLocale> - <SystemLocale>en-US</SystemLocale> - <UILanguage>en-US</UILanguage> - <UILanguageFallback>en-US</UILanguageFallback> - <UserLocale>en-US</UserLocale> - </component> - </settings> - <settings pass="offlineServicing"> - <component name="Microsoft-Windows-LUA-Settings" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <!-- https://docs.microsoft.com/en-us/windows-hardware/customize/desktop/unattend/microsoft-windows-lua-settings --> - <EnableLUA>false</EnableLUA> - </component> - </settings> - <settings pass="generalize"> - <component name="Microsoft-Windows-Security-SPP" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="NonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <SkipRearm>1</SkipRearm> - </component> - <component name="Microsoft-Windows-PnpSysprep" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <DoNotCleanUpNonPresentDevices>false</DoNotCleanUpNonPresentDevices> </component> </settings> - <cpi:offlineImage cpi:source="wim:d:/minikubewindowscontainers/install.wim#Windows Server 2022 SERVERDATACENTERCORE" xmlns:cpi="urn:schemas-microsoft-com:cpi" /> -</unattend> + <cpi:offlineImage cpi:source="wim:c:/wims/install.wim#Windows Server 2022 SERVERDATACENTER" xmlns:cpi="urn:schemas-microsoft-com:cpi" /> +</unattend> \ No newline at end of file From 7ae051c9ce544f750e893489de73b437ea5ebaff Mon Sep 17 00:00:00 2001 From: Bob Sira <bosira@microsoft.com> Date: Wed, 31 Jan 2024 00:41:14 -0800 Subject: [PATCH 33/52] setup file to test the configuration --- automation/SetUp.ps1 | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 automation/SetUp.ps1 diff --git a/automation/SetUp.ps1 b/automation/SetUp.ps1 new file mode 100644 index 0000000..b8615d5 --- /dev/null +++ b/automation/SetUp.ps1 @@ -0,0 +1,17 @@ +$SwitchName = "External VM Switch" +$ISOFile = "C:\Users\bosira\Downloads\SERVER_EVAL_x64FRE_en-us-uni.iso" +$VMName = 'minikube-m05' +$VM = @{ + Name = $VMName; + MemoryStartupBytes = 1GB; + NewVHDPath = "${env:homepath}\.minikube\machines\$VMName\VHD.vhdx"; + NewVHDSizeBytes = 10GB; + BootDevice = "VHD"; + Path = "${env:homepath}\.minikube\machines\"; + SwitchName = $SwitchName +} +New-VM @VM +Set-VM -Name $VMName -ProcessorCount 2 -AutomaticCheckpointsEnabled $false +Set-VMProcessor -VMName $VMName -ExposeVirtualizationExtensions $true +Set-VMDvdDrive -VMName $VMName -Path $ISOFile +Start-VM -Name $VMName \ No newline at end of file From 58c3230080f976379af569e33c86cc82f6ba9a50 Mon Sep 17 00:00:00 2001 From: Bob Sira <bosira@microsoft.com> Date: Wed, 31 Jan 2024 06:10:35 -0800 Subject: [PATCH 34/52] updates for testing --- automation/SetUp.ps1 | 2 +- automation/autounattend.xml | 21 ++++++++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/automation/SetUp.ps1 b/automation/SetUp.ps1 index b8615d5..cf88047 100644 --- a/automation/SetUp.ps1 +++ b/automation/SetUp.ps1 @@ -1,5 +1,5 @@ $SwitchName = "External VM Switch" -$ISOFile = "C:\Users\bosira\Downloads\SERVER_EVAL_x64FRE_en-us-uni.iso" +$ISOFile = "$HOME\Downloads\SERVER_EVAL_x64FRE_en-us-uni.iso" $VMName = 'minikube-m05' $VM = @{ Name = $VMName; diff --git a/automation/autounattend.xml b/automation/autounattend.xml index 9d6e68b..c1610ff 100644 --- a/automation/autounattend.xml +++ b/automation/autounattend.xml @@ -47,6 +47,8 @@ <ImageInstall> <OSImage> <InstallFrom> + <!-- https://docs.microsoft.com/en-us/windows-hardware/customize/desktop/unattend/microsoft-windows-setup-imageinstall-dataimage-installfrom-metadata-key --> + <!-- Get-WindowsImage -ImagePath D:\sources\install.wim --> <MetaData wcm:action="add"> <Key>/IMAGE/INDEX </Key> <Value>2</Value> @@ -64,6 +66,8 @@ <AcceptEula>true</AcceptEula> <ProductKey> <WillShowUI>Never</WillShowUI> + <!-- Do not uncomment the Key element if you are using trial ISOs --> + <!-- You must uncomment the Key element (and optionally insert your own key) if you are using retail or volume license ISOs --> <!-- <Key>11111-22222-33333-44444-55555</Key> --> </ProductKey> </UserData> @@ -91,9 +95,10 @@ </settings> <settings pass="oobeSystem"> <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <!-- https://docs.microsoft.com/en-us/windows-hardware/customize/desktop/unattend/microsoft-windows-shell-setup --> <AutoLogon> <Password> - <Value>M@kindu.2023</Value> + <Value>Minikube@2024</Value> <PlainText>true</PlainText> </Password> <Username>Administrator</Username> @@ -137,14 +142,24 @@ <RequiresUserInput>true</RequiresUserInput> </SynchronousCommand> <SynchronousCommand wcm:action="add"> - <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -Command Restart-Computer -Force</CommandLine> + <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -Command Install-WindowsFeature -Name containers</CommandLine> <Order>7</Order> + <Description>Installs Containers feature</Description> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -Command Set-SConfig -AutoLaunch $false</CommandLine> + <Order>8</Order> + <Description>Turns off Server Configuration tool (SConfig)</Description> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -Command Restart-Computer -Force</CommandLine> + <Order>9</Order> <Description>Restart computer to apply changes</Description> </SynchronousCommand> </FirstLogonCommands> <UserAccounts> <AdministratorPassword> - <Value>M@kindu.2023</Value> + <Value>Minikube@2024</Value> <PlainText>true</PlainText> </AdministratorPassword> </UserAccounts> From 5306cf7493895211fc73f33ebc9ba483c54f6635 Mon Sep 17 00:00:00 2001 From: Ian King'ori <kingorim.ian@gmail.com> Date: Thu, 1 Feb 2024 23:56:25 +0300 Subject: [PATCH 35/52] add auto-unattend iso file --- automation/SetUp.ps1 | 3 ++- automation/auto-install.iso | Bin 0 -> 73728 bytes 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 automation/auto-install.iso diff --git a/automation/SetUp.ps1 b/automation/SetUp.ps1 index cf88047..9db2ab0 100644 --- a/automation/SetUp.ps1 +++ b/automation/SetUp.ps1 @@ -5,7 +5,7 @@ $VM = @{ Name = $VMName; MemoryStartupBytes = 1GB; NewVHDPath = "${env:homepath}\.minikube\machines\$VMName\VHD.vhdx"; - NewVHDSizeBytes = 10GB; + NewVHDSizeBytes = 15GB; BootDevice = "VHD"; Path = "${env:homepath}\.minikube\machines\"; SwitchName = $SwitchName @@ -14,4 +14,5 @@ New-VM @VM Set-VM -Name $VMName -ProcessorCount 2 -AutomaticCheckpointsEnabled $false Set-VMProcessor -VMName $VMName -ExposeVirtualizationExtensions $true Set-VMDvdDrive -VMName $VMName -Path $ISOFile +Add-VMDvdDrive -VMName $VMName -Path "$PSScriptRoot\auto-install.iso" -ControllerNumber 1 -ControllerLocation 1 Start-VM -Name $VMName \ No newline at end of file diff --git a/automation/auto-install.iso b/automation/auto-install.iso new file mode 100644 index 0000000000000000000000000000000000000000..7ed2d7be6ce4c8b5b00c47c7bf88529cb0c6569b GIT binary patch literal 73728 zcmeI5-)`H;6^H4)D3Tx-dl4*(Hd##71e<h0Q<jr7YcSd>wz6x~b_7%2WD5fUO^qzV zB!?Z6mR0nk@6b2wi?nBk6fK#OEC+R*-TY|8B8T&j-<&yf&KX8F3>+W;0w4eaAOHd& z00JNY0w4eaAOHd&00JNY0w4eaAOHd&00JNY0w4eaAOHd&00JNY0w4eaAOHd&00JNY z0w4eaAOHd&00JNY0w4eaAOHd&00JNY0w4eaAOHd&00JNY0w4eaAOHd&00JNY0w4ea zAOH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0mzJOB>ky(T1x}Ni)*U`1M{qw2NOe=>E)Lw0 z*2>=$D+1GsfHRUD3cBiu&tokjwEzC(8)jZ9bD=+2D<b``7le)yxo6+KcupcJMJhZI zu<mB(Lqw=wJPYGzDo&<Wo>ZvHn3ikZNVz&NK_ReQ>XsKEGCrV%a{Gjlr=F{pLa7Am z1%ZK5Dh`*Y6mUBvTW4_i%1wNanc9$J563>AHgT3*+=~SxugIl3$>UU}2959XBS+pW zMs7TEw8uimn;xX`I()S?+@TtD95~n4WEZIcSF?>&i5TizJwFM@FXE^>ePu=u*b%2G z$mzu&?}X+b*_0jy9}<?^a>?=o`WypV>hfZ5V!VU(n%={p_nivW?1_k?;k0fN+{;Hf zpCo@?40qC;E80#N?K>9juzucwO9u0oXLu=<=j8jVWFIN7)}?Kc0ee{N5iN`N#qxN& z^io~IM88k^R;m?iYI~RF6)l&Ki$0OvH90cB0!w$F)4rTcm7wbw<rQ3xT#&z8o^;U` z^Tur{Z5GF5b$SDOxsG3^n=Th;dLQHxFJFfpXxmR@Q93ICFcplLAHC2%*Y$=@mgq?y zEU7+CCAeFO_j$3uK_VZJ*2;I|RYJZ8uU-}nH@ppcjUY@c+748&GN}FdKaS1SVxCZ_ zsKK1}{!i`wtyZ_S+1~56_s6eXQhkeFSEbuEX3-n2<(ml2&-GnkJU0k{z~@Eae`cU{ AF8}}l literal 0 HcmV?d00001 From c758048b31822480e28e09ac4aae4ed0142af15e Mon Sep 17 00:00:00 2001 From: bosira <sbobfitz2@gmail.com> Date: Fri, 2 Feb 2024 17:10:44 +0000 Subject: [PATCH 36/52] flannel and kube-proxy networking config addition@ --- automation/Run.ps1 | 15 +++- flannel-overlay.yaml | 142 +++++++++++++++++++++++++++++++++ kube-flannel.yml | 184 ++++++++++++++++++++++++++++++++++++++++++- kube-proxy.yml | 9 ++- 4 files changed, 344 insertions(+), 6 deletions(-) create mode 100644 flannel-overlay.yaml diff --git a/automation/Run.ps1 b/automation/Run.ps1 index f281bc1..973254f 100644 --- a/automation/Run.ps1 +++ b/automation/Run.ps1 @@ -10,6 +10,12 @@ function Run { [string]$Pass ) + # configure Flannel CNI for Windows + # make sure the flannel daemon set is restarted to reflect the new Windows-specific configuration + & kubectl apply -f "..\kube-flannel.yml" + & kubectl rollout restart ds kube-flannel-ds -n kube-flannel + & kubectl get pods -A + $SecurePassword = ConvertTo-SecureString -String $Pass -AsPlainText -Force $Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $Username, $SecurePassword @@ -102,7 +108,14 @@ function Run { Invoke-Command -VMName $VMName -Credential $Credential -ScriptBlock $ScriptBlock -ArgumentList $JoinCommand - # windows node successfully joined in the cluster + # validate windows node successfully join + & kubectl get nodes -o wide + + # configure flannel and kube-proxy on the windows node + & kubectl apply -f "..\fannel-overlay.yml" + & kubectl apply -f "..\kube-proxy.yml" + + # check the status of the windows node & kubectl get nodes -o wide } \ No newline at end of file diff --git a/flannel-overlay.yaml b/flannel-overlay.yaml new file mode 100644 index 0000000..20c46a9 --- /dev/null +++ b/flannel-overlay.yaml @@ -0,0 +1,142 @@ +--- +kind: ConfigMap +apiVersion: v1 +metadata: + name: kube-flannel-windows-cfg + namespace: kube-flannel + labels: + tier: node + app: flannel +data: + cni-conf-containerd.json: | + { + "name": "flannel.4096", + "cniVersion": "0.3.0", + "type": "flannel", + "capabilities": { + "portMappings": true, + "dns": true + }, + "delegate": { + "type": "sdnoverlay", + "AdditionalArgs": [ + { + "Name": "EndpointPolicy", + "Value": { + "Type": "OutBoundNAT", + "Settings" : { + "Exceptions": [] + } + } + }, + { + "Name": "EndpointPolicy", + "Value": { + "Type": "SDNROUTE", + "Settings": { + "DestinationPrefix": "", + "NeedEncap": true + } + } + }, + { + "Name":"EndpointPolicy", + "Value":{ + "Type":"ProviderAddress", + "Settings":{ + "ProviderAddress":"" + } + } + } + ] + } + } +--- +apiVersion: apps/v1 +kind: DaemonSet +metadata: + name: kube-flannel-ds-windows-amd64 + labels: + tier: node + app: flannel + namespace: kube-flannel +spec: + selector: + matchLabels: + app: flannel + template: + metadata: + labels: + tier: node + app: flannel + spec: + affinity: + nodeAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + nodeSelectorTerms: + - matchExpressions: + - key: kubernetes.io/os + operator: In + values: + - windows + - key: kubernetes.io/arch + operator: In + values: + - amd64 + securityContext: + windowsOptions: + hostProcess: true + runAsUserName: "NT AUTHORITY\\system" + hostNetwork: true + serviceAccountName: flannel + tolerations: + - operator: Exists + effect: NoSchedule + # Mark the pod as a critical add-on for rescheduling. + - key: CriticalAddonsOnly + operator: Exists + - effect: NoExecute + operator: Exists + containers: + - name: kube-flannel + image: syck0/flannel:v0.21.5-hostprocess + imagePullPolicy: Always + volumeMounts: + - name: flannel-cfg + mountPath: /mounts/kube-flannel/ + - name: flannel-windows-cfg + mountPath: /mounts/kube-flannel-windows/ + env: + - name: CNI_BIN_PATH + value: C:\\opt\\cni\\bin + - name: CNI_CONFIG_PATH + value: C:\\etc\\cni\\net.d + - name: SERVICE_SUBNET + value: 10.96.0.0/12 + # As of now with the currently used flannel version (last checked with v0.21.5) we need to overwrite KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT + # in order to be able to reach the kubernetes api server. Under windows it's currently not possible to reach it over the service created by kubernetes + # For more context and details check the corresponding PR: https://github.com/kubernetes-sigs/sig-windows-tools/pull/314 + # Especially the comments in this review: https://github.com/kubernetes-sigs/sig-windows-tools/pull/314#discussion_r1238815189 + # There is also a follow up issue on the flannel side: https://github.com/flannel-io/flannel/issues/1772 + # Once this issue is solved we should be able to remove the custom host and port to the kubernetes api server + - name: KUBERNETES_SERVICE_HOST + value: control-plane.minikube.internal # KUBERNETES_SERVICE_HOST_VALUE + - name: KUBERNETES_SERVICE_PORT + value: "8443" # replace with your "KUBERNETES_SERVICE_PORT_VALUE" + - name: POD_NAME + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: metadata.name + - name: POD_NAMESPACE + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: metadata.namespace + volumes: + - name: flannel-cfg + configMap: + name: kube-flannel-cfg + - name: flannel-windows-cfg + configMap: + name: kube-flannel-windows-cfg diff --git a/kube-flannel.yml b/kube-flannel.yml index 0fc8995..dc0f934 100644 --- a/kube-flannel.yml +++ b/kube-flannel.yml @@ -1,3 +1,70 @@ +--- +kind: Namespace +apiVersion: v1 +metadata: + name: kube-flannel + labels: + k8s-app: flannel + pod-security.kubernetes.io/enforce: privileged +--- +kind: ClusterRole +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + labels: + k8s-app: flannel + name: flannel +rules: +- apiGroups: + - "" + resources: + - pods + verbs: + - get +- apiGroups: + - "" + resources: + - nodes + verbs: + - get + - list + - watch +- apiGroups: + - "" + resources: + - nodes/status + verbs: + - patch +- apiGroups: + - networking.k8s.io + resources: + - clustercidrs + verbs: + - list + - watch +--- +kind: ClusterRoleBinding +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + labels: + k8s-app: flannel + name: flannel +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: flannel +subjects: +- kind: ServiceAccount + name: flannel + namespace: kube-flannel +--- +apiVersion: v1 +kind: ServiceAccount +metadata: + labels: + k8s-app: flannel + name: flannel + namespace: kube-flannel +--- kind: ConfigMap apiVersion: v1 metadata: @@ -5,6 +72,7 @@ metadata: namespace: kube-flannel labels: tier: node + k8s-app: flannel app: flannel data: cni-conf.json: | @@ -35,4 +103,118 @@ data: "VNI": 4096, "Port": 4789 } - } \ No newline at end of file + } +--- +apiVersion: apps/v1 +kind: DaemonSet +metadata: + name: kube-flannel-ds + namespace: kube-flannel + labels: + tier: node + app: flannel + k8s-app: flannel +spec: + selector: + matchLabels: + app: flannel + template: + metadata: + labels: + tier: node + app: flannel + spec: + affinity: + nodeAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + nodeSelectorTerms: + - matchExpressions: + - key: kubernetes.io/os + operator: In + values: + - linux + hostNetwork: true + priorityClassName: system-node-critical + tolerations: + - operator: Exists + effect: NoSchedule + serviceAccountName: flannel + initContainers: + - name: install-cni-plugin + image: docker.io/flannel/flannel-cni-plugin:v1.1.2 + #image: docker.io/rancher/mirrored-flannelcni-flannel-cni-plugin:v1.1.2 + command: + - cp + args: + - -f + - /flannel + - /opt/cni/bin/flannel + volumeMounts: + - name: cni-plugin + mountPath: /opt/cni/bin + - name: install-cni + image: docker.io/flannel/flannel:v0.22.0 + #image: docker.io/rancher/mirrored-flannelcni-flannel:v0.22.0 + command: + - cp + args: + - -f + - /etc/kube-flannel/cni-conf.json + - /etc/cni/net.d/10-flannel.conflist + volumeMounts: + - name: cni + mountPath: /etc/cni/net.d + - name: flannel-cfg + mountPath: /etc/kube-flannel/ + containers: + - name: kube-flannel + image: docker.io/flannel/flannel:v0.22.0 + #image: docker.io/rancher/mirrored-flannelcni-flannel:v0.22.0 + command: + - /opt/bin/flanneld + args: + - --ip-masq + - --kube-subnet-mgr + resources: + requests: + cpu: "100m" + memory: "50Mi" + securityContext: + privileged: false + capabilities: + add: ["NET_ADMIN", "NET_RAW"] + env: + - name: POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + - name: POD_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + - name: EVENT_QUEUE_DEPTH + value: "5000" + volumeMounts: + - name: run + mountPath: /run/flannel + - name: flannel-cfg + mountPath: /etc/kube-flannel/ + - name: xtables-lock + mountPath: /run/xtables.lock + volumes: + - name: run + hostPath: + path: /run/flannel + - name: cni-plugin + hostPath: + path: /opt/cni/bin + - name: cni + hostPath: + path: /etc/cni/net.d + - name: flannel-cfg + configMap: + name: kube-flannel-cfg + - name: xtables-lock + hostPath: + path: /run/xtables.lock + type: FileOrCreate diff --git a/kube-proxy.yml b/kube-proxy.yml index d7dbfeb..19f1771 100644 --- a/kube-proxy.yml +++ b/kube-proxy.yml @@ -21,7 +21,7 @@ spec: runAsUserName: "NT AUTHORITY\\system" hostNetwork: true containers: - - image: sigwindowstools/kube-proxy:v1.23.3-flannel-hostprocess + - image: sigwindowstools/kube-proxy:v1.27.3-flannel-hostprocess name: kube-proxy imagePullPolicy: Always env: @@ -29,6 +29,8 @@ spec: # https://github.com/kubernetes/kubernetes/blob/b0bc8adbc2178e15872f9ef040355c51c45d04bb/pkg/proxy/winkernel/proxier.go#L155-L158 - name: KUBE_NETWORK value: "flannel.4096" + - name: CNI_BIN_PATH + value: C:\\opt\\cni\\bin - name: NODE_NAME valueFrom: fieldRef: @@ -39,7 +41,7 @@ spec: fieldRef: fieldPath: status.podIP volumeMounts: - - mountPath: /var/lib/kube-proxy + - mountPath: /mounts/var/lib/kube-proxy name: kube-proxy nodeSelector: kubernetes.io/os: windows @@ -50,7 +52,6 @@ spec: volumes: - configMap: name: kube-proxy - item: name: kube-proxy updateStrategy: - type: RollingUpdate + type: RollingUpdate \ No newline at end of file From 1ffcce44dfa8cd27341389f9dfb9cc6ea2256c91 Mon Sep 17 00:00:00 2001 From: bosira <sbobfitz2@gmail.com> Date: Sun, 4 Feb 2024 22:23:35 +0000 Subject: [PATCH 37/52] changed from yml to recommended yaml extension --- automation/Install-Windows.psm1 | 13 +++++++++++++ automation/Run.ps1 | 6 +++--- kube-flannel.yml => kube-flannel.yaml | 0 kube-proxy.yml => kube-proxy.yaml | 0 4 files changed, 16 insertions(+), 3 deletions(-) rename kube-flannel.yml => kube-flannel.yaml (100%) rename kube-proxy.yml => kube-proxy.yaml (100%) diff --git a/automation/Install-Windows.psm1 b/automation/Install-Windows.psm1 index e69de29..6b36053 100644 --- a/automation/Install-Windows.psm1 +++ b/automation/Install-Windows.psm1 @@ -0,0 +1,13 @@ +# Define the paths to the ISO and the Autounattend.xml file +$isoPath = "D:\MinikubeWindowsContainers\SERVER_EVAL_x64FRE_en-us.iso" +$answerFilePath = "D:\MinikubeWindowsContainers\automation\autounattend.xml" + +# Mount the ISO +$iso = Mount-DiskImage -ImagePath $isoPath -PassThru +$driveLetter = ($iso | Get-Volume).DriveLetter + +# Copy the Autounattend.xml file to the root of the ISO +Copy-Item -Path $answerFilePath -Destination "$($driveLetter):\" -Force + +# Start the installation +Start-Process -FilePath "$($driveLetter):\setup.exe" -ArgumentList "/unattend:$($driveLetter):\Autounattend.xml" diff --git a/automation/Run.ps1 b/automation/Run.ps1 index 973254f..88bbfb2 100644 --- a/automation/Run.ps1 +++ b/automation/Run.ps1 @@ -12,7 +12,7 @@ function Run { # configure Flannel CNI for Windows # make sure the flannel daemon set is restarted to reflect the new Windows-specific configuration - & kubectl apply -f "..\kube-flannel.yml" + & kubectl apply -f "..\kube-flannel.yaml" & kubectl rollout restart ds kube-flannel-ds -n kube-flannel & kubectl get pods -A @@ -112,8 +112,8 @@ function Run { & kubectl get nodes -o wide # configure flannel and kube-proxy on the windows node - & kubectl apply -f "..\fannel-overlay.yml" - & kubectl apply -f "..\kube-proxy.yml" + & kubectl apply -f "..\flannel-overlay.yaml" + & kubectl apply -f "..\kube-proxy.yaml" # check the status of the windows node & kubectl get nodes -o wide diff --git a/kube-flannel.yml b/kube-flannel.yaml similarity index 100% rename from kube-flannel.yml rename to kube-flannel.yaml diff --git a/kube-proxy.yml b/kube-proxy.yaml similarity index 100% rename from kube-proxy.yml rename to kube-proxy.yaml From b4aae2e4721d8366e01f120b5992303db1137e97 Mon Sep 17 00:00:00 2001 From: Bob Sira <bosira@microsoft.com> Date: Mon, 5 Feb 2024 07:05:29 -0800 Subject: [PATCH 38/52] generic computer name --- automation/autounattend.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automation/autounattend.xml b/automation/autounattend.xml index c1610ff..08e796d 100644 --- a/automation/autounattend.xml +++ b/automation/autounattend.xml @@ -84,7 +84,7 @@ </component> <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <!-- https://docs.microsoft.com/en-us/windows-hardware/customize/desktop/unattend/microsoft-windows-shell-setup --> - <ComputerName>minikube-m05</ComputerName> + <ComputerName>MINIKUBE-WINDOWS</ComputerName> <TimeZone>Central Standard Time</TimeZone> <CopyProfile>true</CopyProfile> </component> From 4aa93e99c2b79ae3724fcae7997fc02553ae8db0 Mon Sep 17 00:00:00 2001 From: Bob Sira <bosira@microsoft.com> Date: Mon, 5 Feb 2024 09:39:48 -0800 Subject: [PATCH 39/52] computer name changes --- automation/SetUp.ps1 | 2 +- automation/autounattend.xml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/automation/SetUp.ps1 b/automation/SetUp.ps1 index 9db2ab0..80a929c 100644 --- a/automation/SetUp.ps1 +++ b/automation/SetUp.ps1 @@ -1,6 +1,6 @@ $SwitchName = "External VM Switch" $ISOFile = "$HOME\Downloads\SERVER_EVAL_x64FRE_en-us-uni.iso" -$VMName = 'minikube-m05' +$VMName = 'minikube-ws22' $VM = @{ Name = $VMName; MemoryStartupBytes = 1GB; diff --git a/automation/autounattend.xml b/automation/autounattend.xml index 08e796d..51d9d00 100644 --- a/automation/autounattend.xml +++ b/automation/autounattend.xml @@ -51,7 +51,7 @@ <!-- Get-WindowsImage -ImagePath D:\sources\install.wim --> <MetaData wcm:action="add"> <Key>/IMAGE/INDEX </Key> - <Value>2</Value> + <Value>3</Value> </MetaData> </InstallFrom> <InstallTo> @@ -84,7 +84,7 @@ </component> <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <!-- https://docs.microsoft.com/en-us/windows-hardware/customize/desktop/unattend/microsoft-windows-shell-setup --> - <ComputerName>MINIKUBE-WINDOWS</ComputerName> + <ComputerName>minikube-ws22</ComputerName> <TimeZone>Central Standard Time</TimeZone> <CopyProfile>true</CopyProfile> </component> From a2e9063d3fcdb061fbd998a3ade6d1c4e3123a0a Mon Sep 17 00:00:00 2001 From: bosira <sbobfitz2@gmail.com> Date: Mon, 5 Feb 2024 18:11:39 +0000 Subject: [PATCH 40/52] configuring linux nodes --- automation/Run.ps1 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/automation/Run.ps1 b/automation/Run.ps1 index 88bbfb2..18be317 100644 --- a/automation/Run.ps1 +++ b/automation/Run.ps1 @@ -10,6 +10,11 @@ function Run { [string]$Pass ) + # Prepare the Linux nodes for Windows-specific Flannel CNI configuration + # at the moment we are assuming that you only have two linux nodes named minikube and minikube-m02 + & minikube ssh "sudo sysctl net.bridge.bridge-nf-call-iptables=1 && exit" + & minikube ssh -n minikube-m02 "sudo sysctl net.bridge.bridge-nf-call-iptables=1 && exit" + # configure Flannel CNI for Windows # make sure the flannel daemon set is restarted to reflect the new Windows-specific configuration & kubectl apply -f "..\kube-flannel.yaml" From cd16c12e212c58cbe209aa356f3c89680072f2d8 Mon Sep 17 00:00:00 2001 From: bosira <sbobfitz2@gmail.com> Date: Tue, 6 Feb 2024 01:22:08 +0000 Subject: [PATCH 41/52] better logging to the console --- automation/InitNode.ps1 | 3 +++ automation/MinikubeTools.psm1 | 15 ++++++++------- automation/NSSMTools.psm1 | 4 ++-- automation/Run.ps1 | 16 ++++++++++------ automation/k8Tools.psm1 | 14 +++++++------- 5 files changed, 30 insertions(+), 22 deletions(-) diff --git a/automation/InitNode.ps1 b/automation/InitNode.ps1 index 9fba52c..a205be5 100644 --- a/automation/InitNode.ps1 +++ b/automation/InitNode.ps1 @@ -6,6 +6,9 @@ Import-Module -Name "$PSScriptRoot\NSSMTools.psm1" -Force Install-Containerd Initialize-ContainerdService Start-ContainerdService +Write-Output "* Containerd is installed and the service is started ..." Install-NSSM +Write-Output "* NSSM is installed ..." Install-Kubelet +Write-Output "* Kubelet is installed and the service is started ..." Set-Port diff --git a/automation/MinikubeTools.psm1 b/automation/MinikubeTools.psm1 index 7e48401..a85e316 100644 --- a/automation/MinikubeTools.psm1 +++ b/automation/MinikubeTools.psm1 @@ -34,23 +34,24 @@ function Get-JoinCommand { [ValidateNotNullOrEmpty()] $Version = "v1.27.3" ) - $JoinCommand = (minikube ssh "cd /var/lib/minikube/binaries/v1.27.3/ && sudo ./kubeadm token create --print-join-command") + $JoinCommand = (minikube ssh "cd /var/lib/minikube/binaries/v1.27.3/ && sudo ./kubeadm token create --print-join-command") >> logs $outputString = $JoinCommand -replace 'kubeadm', '.\kubeadm' $outputString += ' --cri-socket "npipe:////./pipe/containerd-containerd"' $outputString += ' --v=5' - Write-Host $outputString + # Write-Host $outputString + # write this to a log file return $outputString } function Set-MinikubeFolderError { if (!(Test-Path -Path c:\var\lib\minikube\certs)) { - mkdir c:\var\lib\minikube\certs + mkdir c:\var\lib\minikube\certs | Out-Null } if (Test-Path -Path C:\etc\kubernetes\pki\ca.crt) { - Copy-Item C:\etc\kubernetes\pki\ca.crt -Destination C:\var\lib\Minikube\Certs - Remove-Item C:\etc\kubernetes\pki\ca.crt + Copy-Item C:\etc\kubernetes\pki\ca.crt -Destination C:\var\lib\Minikube\Certs | Out-Null + Remove-Item C:\etc\kubernetes\pki\ca.crt | Out-Null } else { Write-Output "File C:\etc\kubernetes\pki\ca.crt does not exist." } @@ -68,9 +69,9 @@ function Add-Host { $entry = "`t$IP`tcontrol-plane.minikube.internal" - $hostsContent = Get-Content -Path $Path -Raw + $hostsContent = Get-Content -Path $Path -Raw -ErrorAction SilentlyContinue if ($hostsContent -notmatch [regex]::Escape($entry)) { - Add-Content -Path $Path -Value "$entry" -Force + Add-Content -Path $Path -Value "$entry" -Force | Out-Null } } diff --git a/automation/NSSMTools.psm1 b/automation/NSSMTools.psm1 index e8c6765..fefca33 100644 --- a/automation/NSSMTools.psm1 +++ b/automation/NSSMTools.psm1 @@ -9,8 +9,8 @@ function Install-NSSM { mkdir "c:\k" | Out-Null } $arch = "win64" - curl.exe -L https://k8stestinfrabinaries.blob.core.windows.net/nssm-mirror/nssm-2.24.zip -o nssm.zip - tar.exe C c:\k\ -xvf .\nssm.zip --strip-components 2 */$arch/*.exe + curl.exe -L https://k8stestinfrabinaries.blob.core.windows.net/nssm-mirror/nssm-2.24.zip -o nssm.zip | Out-Null + tar.exe C c:\k\ -xvf .\nssm.zip --strip-components 2 */$arch/*.exe | Out-Null } Export-ModuleMember -Function Install-NSSM \ No newline at end of file diff --git a/automation/Run.ps1 b/automation/Run.ps1 index 18be317..06bf802 100644 --- a/automation/Run.ps1 +++ b/automation/Run.ps1 @@ -12,14 +12,17 @@ function Run { # Prepare the Linux nodes for Windows-specific Flannel CNI configuration # at the moment we are assuming that you only have two linux nodes named minikube and minikube-m02 - & minikube ssh "sudo sysctl net.bridge.bridge-nf-call-iptables=1 && exit" - & minikube ssh -n minikube-m02 "sudo sysctl net.bridge.bridge-nf-call-iptables=1 && exit" + & minikube ssh "sudo sysctl net.bridge.bridge-nf-call-iptables=1 && exit" > logs + & minikube ssh -n minikube-m02 "sudo sysctl net.bridge.bridge-nf-call-iptables=1 && exit" >> logs + Write-Output "* Linux nodes are ready for Windows-specific Flannel CNI configuration ..." + # configure Flannel CNI for Windows # make sure the flannel daemon set is restarted to reflect the new Windows-specific configuration - & kubectl apply -f "..\kube-flannel.yaml" - & kubectl rollout restart ds kube-flannel-ds -n kube-flannel - & kubectl get pods -A + & kubectl apply -f "..\kube-flannel.yaml" >> logs + & kubectl rollout restart ds kube-flannel-ds -n kube-flannel >> logs + & kubectl get pods -A >> logs + Write-Output "* Flannel CNI for Windows is configured and the daemon set is restarted ..." $SecurePassword = ConvertTo-SecureString -String $Pass -AsPlainText -Force $Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $Username, $SecurePassword @@ -65,7 +68,7 @@ function Run { $commandString = "minikube ip" - $IP = Invoke-Expression -Command $commandString + $IP = Invoke-Expression -Command $commandString | Out-Null $ScriptBlock = { [CmdletBinding()] @@ -122,5 +125,6 @@ function Run { # check the status of the windows node & kubectl get nodes -o wide + Write-Output "* Windows node is successfully joined and configured ..." } \ No newline at end of file diff --git a/automation/k8Tools.psm1 b/automation/k8Tools.psm1 index 51ab05d..9040861 100644 --- a/automation/k8Tools.psm1 +++ b/automation/k8Tools.psm1 @@ -16,7 +16,7 @@ function Install-Kubelet { $KubeletUrl = "https://dl.k8s.io/$KubernetesVersion/bin/windows/amd64/kubelet.exe" # Download kubelet - Invoke-WebRequest -Uri $KubeletUrl -OutFile "c:\k\kubelet.exe" + Invoke-WebRequest -Uri $KubeletUrl -OutFile "c:\k\kubelet.exe" | Out-Null # Create the Start-kubelet.ps1 script @" @@ -38,9 +38,9 @@ Invoke-Expression `$kubeletCommandLine "@ | Set-Content -Path "c:\k\Start-kubelet.ps1" # Install kubelet as a Windows service - c:\k\nssm.exe install kubelet Powershell -ExecutionPolicy Bypass -NoProfile c:\k\Start-kubelet.ps1 - c:\k\nssm.exe set Kubelet AppStdout C:\k\kubelet.log - c:\k\nssm.exe set Kubelet AppStderr C:\k\kubelet.err.log + c:\k\nssm.exe install kubelet Powershell -ExecutionPolicy Bypass -NoProfile c:\k\Start-kubelet.ps1 | Out-Null + c:\k\nssm.exe set Kubelet AppStdout C:\k\kubelet.log | Out-Null + c:\k\nssm.exe set Kubelet AppStderr C:\k\kubelet.err.log | Out-Null } function Set-Port { @@ -50,7 +50,7 @@ function Set-Port { return } - New-NetFirewallRule -Name 'kubelet' -DisplayName 'kubelet' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 10250 + New-NetFirewallRule -Name 'kubelet' -DisplayName 'kubelet' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 10250 | Out-Null } function Get-Kubeadm { @@ -59,8 +59,8 @@ function Get-Kubeadm { [ValidateNotNullOrEmpty()] $KubernetesVersion = "v1.27.3" ) - curl.exe -L https://dl.k8s.io/$KubernetesVersion/bin/windows/amd64/kubeadm.exe -o c:\k\kubeadm.exe - Set-Location c:\k + curl.exe -L https://dl.k8s.io/$KubernetesVersion/bin/windows/amd64/kubeadm.exe -o c:\k\kubeadm.exe | Out-Null + Set-Location c:\k | Out-Null } From 956beaf32c32a7415529c592bea5c35278d228f5 Mon Sep 17 00:00:00 2001 From: bosira <sbobfitz2@gmail.com> Date: Tue, 6 Feb 2024 03:09:36 +0000 Subject: [PATCH 42/52] fixing broken changes --- automation/ContainerdTools.psm1 | 14 +++++++------- automation/MinikubeTools.psm1 | 2 +- automation/Run.ps1 | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/automation/ContainerdTools.psm1 b/automation/ContainerdTools.psm1 index caa214a..be2e85e 100644 --- a/automation/ContainerdTools.psm1 +++ b/automation/ContainerdTools.psm1 @@ -29,7 +29,7 @@ function Install-Containerd { $containerdTarFile = "containerd-${version}-windows-amd64.tar.gz" try { $Uri = "https://github.com/containerd/containerd/releases/download/v$version/$($containerdTarFile)" - Invoke-WebRequest -Uri $Uri -OutFile $DownloadPath\$containerdTarFile -Verbose + Invoke-WebRequest -Uri $Uri -OutFile $DownloadPath\$containerdTarFile -Verbose | Out-Null } catch { Throw "Containerd download failed. $_" @@ -49,7 +49,7 @@ function Install-Containerd { Install-RequiredFeature @params Write-Output "Containerd v$version successfully installed at $InstallPath" - containerd.exe -v + containerd.exe -v | Out-Null Write-Output "For containerd usage: run 'containerd -h'" } @@ -140,9 +140,9 @@ function Initialize-ContainerdService { if ($replacementsMade) { $containerdConfigContent | Set-Content -Path $containerdConfigFile # Output a message indicating the changes - Write-Host "Changes applied to $containerdConfigFile" + # Write-Host "Changes applied to $containerdConfigFile" } else { - Write-Host "No changes needed in $containerdConfigFile" + # Write-Host "No changes needed in $containerdConfigFile" } # Create the folders if they do not exist @@ -151,12 +151,12 @@ function Initialize-ContainerdService { if (!(Test-Path $binDir)) { mkdir $binDir | Out-Null - Write-Host "Created $binDir" + # Write-Host "Created $binDir" } if (!(Test-Path $confDir)) { mkdir $confDir | Out-Null - Write-Host "Created $confDir" + # Write-Host "Created $confDir" } @@ -177,7 +177,7 @@ function Initialize-ContainerdService { Write-Host "Containerd service is already registered." } - Get-Service *containerd* | Select-Object Name, DisplayName, ServiceName, ServiceType, StartupType, Status, RequiredServices, ServicesDependedOn + Get-Service *containerd* | Select-Object Name, DisplayName, ServiceName, ServiceType, StartupType, Status, RequiredServices, ServicesDependedOn | Out-Null } function Uninstall-Containerd { diff --git a/automation/MinikubeTools.psm1 b/automation/MinikubeTools.psm1 index a85e316..77b18bb 100644 --- a/automation/MinikubeTools.psm1 +++ b/automation/MinikubeTools.psm1 @@ -34,7 +34,7 @@ function Get-JoinCommand { [ValidateNotNullOrEmpty()] $Version = "v1.27.3" ) - $JoinCommand = (minikube ssh "cd /var/lib/minikube/binaries/v1.27.3/ && sudo ./kubeadm token create --print-join-command") >> logs + $JoinCommand = (minikube ssh "cd /var/lib/minikube/binaries/v1.27.3/ && sudo ./kubeadm token create --print-join-command") $outputString = $JoinCommand -replace 'kubeadm', '.\kubeadm' $outputString += ' --cri-socket "npipe:////./pipe/containerd-containerd"' $outputString += ' --v=5' diff --git a/automation/Run.ps1 b/automation/Run.ps1 index 06bf802..81d87ad 100644 --- a/automation/Run.ps1 +++ b/automation/Run.ps1 @@ -68,7 +68,7 @@ function Run { $commandString = "minikube ip" - $IP = Invoke-Expression -Command $commandString | Out-Null + $IP = Invoke-Expression -Command $commandString $ScriptBlock = { [CmdletBinding()] @@ -117,11 +117,11 @@ function Run { Invoke-Command -VMName $VMName -Credential $Credential -ScriptBlock $ScriptBlock -ArgumentList $JoinCommand # validate windows node successfully join - & kubectl get nodes -o wide + & kubectl get nodes -o wide >> logs # configure flannel and kube-proxy on the windows node - & kubectl apply -f "..\flannel-overlay.yaml" - & kubectl apply -f "..\kube-proxy.yaml" + & kubectl apply -f "..\flannel-overlay.yaml" >> logs + & kubectl apply -f "..\kube-proxy.yaml" >> logs # check the status of the windows node & kubectl get nodes -o wide From 936eb03ccb446c281f3c85520e1f218f2ba58301 Mon Sep 17 00:00:00 2001 From: "Bob Sira (from Dev Box)" <bosira@microsoft.com> Date: Tue, 20 Feb 2024 08:51:16 +0000 Subject: [PATCH 43/52] draft changes to merge remote and auto-install work --- automation/Install-Windows.psm1 | 13 -------- automation/SetUp.ps1 | 59 ++++++++++++++++++++++++++++++--- 2 files changed, 55 insertions(+), 17 deletions(-) delete mode 100644 automation/Install-Windows.psm1 diff --git a/automation/Install-Windows.psm1 b/automation/Install-Windows.psm1 deleted file mode 100644 index 6b36053..0000000 --- a/automation/Install-Windows.psm1 +++ /dev/null @@ -1,13 +0,0 @@ -# Define the paths to the ISO and the Autounattend.xml file -$isoPath = "D:\MinikubeWindowsContainers\SERVER_EVAL_x64FRE_en-us.iso" -$answerFilePath = "D:\MinikubeWindowsContainers\automation\autounattend.xml" - -# Mount the ISO -$iso = Mount-DiskImage -ImagePath $isoPath -PassThru -$driveLetter = ($iso | Get-Volume).DriveLetter - -# Copy the Autounattend.xml file to the root of the ISO -Copy-Item -Path $answerFilePath -Destination "$($driveLetter):\" -Force - -# Start the installation -Start-Process -FilePath "$($driveLetter):\setup.exe" -ArgumentList "/unattend:$($driveLetter):\Autounattend.xml" diff --git a/automation/SetUp.ps1 b/automation/SetUp.ps1 index 80a929c..2801fe5 100644 --- a/automation/SetUp.ps1 +++ b/automation/SetUp.ps1 @@ -1,6 +1,20 @@ -$SwitchName = "External VM Switch" -$ISOFile = "$HOME\Downloads\SERVER_EVAL_x64FRE_en-us-uni.iso" -$VMName = 'minikube-ws22' +param( + [Parameter(Mandatory=$true)] + [string]$SwitchName, + + [Parameter(Mandatory=$true)] + [string]$ISOFilePath, + + [Parameter(Mandatory=$true)] + [string]$VMName, + + [Parameter(Mandatory=$true)] + [string]$UserName, + + [Parameter(Mandatory=$true)] + [string]$Pass +) + $VM = @{ Name = $VMName; MemoryStartupBytes = 1GB; @@ -10,9 +24,46 @@ $VM = @{ Path = "${env:homepath}\.minikube\machines\"; SwitchName = $SwitchName } + New-VM @VM Set-VM -Name $VMName -ProcessorCount 2 -AutomaticCheckpointsEnabled $false Set-VMProcessor -VMName $VMName -ExposeVirtualizationExtensions $true Set-VMDvdDrive -VMName $VMName -Path $ISOFile Add-VMDvdDrive -VMName $VMName -Path "$PSScriptRoot\auto-install.iso" -ControllerNumber 1 -ControllerLocation 1 -Start-VM -Name $VMName \ No newline at end of file +Start-VM -Name $VMName + + +# Wait for the VM to have a Heartbeat status of OK +$timeout = 300 # 5 minutes +$elapsedTime = 0 + +do { + Start-Sleep -Seconds 5 # wait for 5 seconds before checking again + $heartbeat = Get-VMIntegrationService -VMName $VMName -Name "Heartbeat" + $elapsedTime += 5 + + if ($elapsedTime -ge $timeout) { + Write-Output "Timeout reached. Exiting the script." + exit + } +} while ($heartbeat.PrimaryStatusDescription -ne "OK") + +# Check if Windows is installed only if the Heartbeat status is OK +if ($heartbeat.PrimaryStatusDescription -eq "OK") { + try { + $SecurePassword = ConvertTo-SecureString -String $Pass -AsPlainText -Force + $Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $UserName, $SecurePassword + + $os = Invoke-Command -VMName $VMName -Credential $Credential -ScriptBlock { Get-WmiObject -Query "SELECT * FROM Win32_OperatingSystem" } -ErrorAction Stop + if ($os) { + Write-Output "Windows is installed on $VMName" + # Call Run.ps1 + . .\Run.ps1 + Invoke-Expression "Run -VMName $VMName -UserName $UserName -Pass $Pass" + } else { + Write-Output "Windows is not installed on $VMName" + } + } catch { + Write-Output "An error occurred while checking if Windows is installed on ${VMName}: $_" + } +} \ No newline at end of file From 2411d0e186e312ca9a71ad02327c34d280afa02d Mon Sep 17 00:00:00 2001 From: "Bob Sira (from Dev Box)" <bosira@microsoft.com> Date: Tue, 5 Mar 2024 03:12:18 +0000 Subject: [PATCH 44/52] initial setup to combine the two work --- automation/Run.ps1 | 9 ++++-- automation/SetUp.ps1 | 69 +++++++++++++++++++++++++++++--------------- 2 files changed, 51 insertions(+), 27 deletions(-) diff --git a/automation/Run.ps1 b/automation/Run.ps1 index 81d87ad..0b87816 100644 --- a/automation/Run.ps1 +++ b/automation/Run.ps1 @@ -7,9 +7,14 @@ function Run { param ( [string]$VMName, [string]$UserName, - [string]$Pass + [string]$Pass, + [System.Management.Automation.PSCredential]$Credential ) + # create and configure a new minikube cluster + & minikube start --driver=hyperv --hyperv-virtual-switch=$SwitchName --nodes=2 --cni=flannel --container-runtime=containerd + # & minikube start --driver=hyperv --hyperv-virtual-switch=$SwitchName --memory=4096 --cpus=2 --kubernetes-version=v1.20.2 --network-plugin=cni --cni=flannel --container-runtime=containerd --disk-size=15GB --wait=false >> logs + Write-Output "* Minikube cluster is created and configured ..." # Prepare the Linux nodes for Windows-specific Flannel CNI configuration # at the moment we are assuming that you only have two linux nodes named minikube and minikube-m02 & minikube ssh "sudo sysctl net.bridge.bridge-nf-call-iptables=1 && exit" > logs @@ -24,8 +29,6 @@ function Run { & kubectl get pods -A >> logs Write-Output "* Flannel CNI for Windows is configured and the daemon set is restarted ..." - $SecurePassword = ConvertTo-SecureString -String $Pass -AsPlainText -Force - $Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $Username, $SecurePassword Enter-PSSession -VMName $VMName -Credential $Credential diff --git a/automation/SetUp.ps1 b/automation/SetUp.ps1 index 2801fe5..7b3c00e 100644 --- a/automation/SetUp.ps1 +++ b/automation/SetUp.ps1 @@ -17,6 +17,7 @@ param( $VM = @{ Name = $VMName; + Generation = 1; MemoryStartupBytes = 1GB; NewVHDPath = "${env:homepath}\.minikube\machines\$VMName\VHD.vhdx"; NewVHDSizeBytes = 15GB; @@ -28,19 +29,20 @@ $VM = @{ New-VM @VM Set-VM -Name $VMName -ProcessorCount 2 -AutomaticCheckpointsEnabled $false Set-VMProcessor -VMName $VMName -ExposeVirtualizationExtensions $true -Set-VMDvdDrive -VMName $VMName -Path $ISOFile +Set-VMDvdDrive -VMName $VMName -Path $ISOFilePath Add-VMDvdDrive -VMName $VMName -Path "$PSScriptRoot\auto-install.iso" -ControllerNumber 1 -ControllerLocation 1 -Start-VM -Name $VMName +Start-VM -Name $VMName | Out-Null -# Wait for the VM to have a Heartbeat status of OK -$timeout = 300 # 5 minutes + +$timeout = 600 +$retryInterval = 15 $elapsedTime = 0 do { - Start-Sleep -Seconds 5 # wait for 5 seconds before checking again + Start-Sleep -Seconds $retryInterval $heartbeat = Get-VMIntegrationService -VMName $VMName -Name "Heartbeat" - $elapsedTime += 5 + $elapsedTime += $retryInterval if ($elapsedTime -ge $timeout) { Write-Output "Timeout reached. Exiting the script." @@ -48,22 +50,41 @@ do { } } while ($heartbeat.PrimaryStatusDescription -ne "OK") -# Check if Windows is installed only if the Heartbeat status is OK -if ($heartbeat.PrimaryStatusDescription -eq "OK") { - try { - $SecurePassword = ConvertTo-SecureString -String $Pass -AsPlainText -Force - $Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $UserName, $SecurePassword - - $os = Invoke-Command -VMName $VMName -Credential $Credential -ScriptBlock { Get-WmiObject -Query "SELECT * FROM Win32_OperatingSystem" } -ErrorAction Stop - if ($os) { - Write-Output "Windows is installed on $VMName" - # Call Run.ps1 - . .\Run.ps1 - Invoke-Expression "Run -VMName $VMName -UserName $UserName -Pass $Pass" - } else { - Write-Output "Windows is not installed on $VMName" + +$SecurePassword = ConvertTo-SecureString -String $Pass -AsPlainText -Force +$Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $UserName, $SecurePassword + +$VMStatus = Get-VM -Name $VMName | Select-Object -ExpandProperty State + +if ($VMStatus -eq 'Running') { + + Write-Output "The VM $VMName is running" + + $retryInterval = 45 + $timeout = 120 + $elapsedTime = 0 + + do { + + try { + $os = Invoke-Command -VMName $VMName -Credential $Credential -ScriptBlock { Get-WmiObject -Query "SELECT * FROM Win32_OperatingSystem" } -ErrorAction Stop + + if ($os) { + Write-Output "Windows is installed on $VMName" + . .\Run.ps1 + # . "$PSScriptRoot\Run.ps1" === this also works + RUN -VMName $VMName -UserName $UserName -Pass $Pass -Credential $Credential + break + } else { + Write-Output "Windows is not installed on $VMName" + } + } catch { + Write-Output "An error occurred while checking if Windows is installed on ${VMName}: $_" } - } catch { - Write-Output "An error occurred while checking if Windows is installed on ${VMName}: $_" - } -} \ No newline at end of file + Start-Sleep -Seconds $retryInterval + $elapsedTime += $retryInterval + } while ($elapsedTime -lt $timeout) + +} else { + Write-Output "The VM $VMName is not running" +} From 81a2cd43eb4d72bf21cba13c35a81d1c282a267d Mon Sep 17 00:00:00 2001 From: "Bob Sira (from Dev Box)" <bosira@microsoft.com> Date: Mon, 11 Mar 2024 03:26:21 +0000 Subject: [PATCH 45/52] final setup to merge auto-install and remote config --- automation/ContainerdTools.psm1 | 20 ++++++--- automation/InitNode.ps1 | 14 ------ automation/MinikubeTools.psm1 | 43 ++---------------- automation/NSSMTools.psm1 | 13 +++++- automation/Run.ps1 | 78 ++++++++++++++++++++++++--------- automation/SetUp.ps1 | 44 ++++++++++++++----- automation/SetUpUtilities.psm1 | 4 +- automation/k8Tools.psm1 | 48 +++++++++++++++----- 8 files changed, 157 insertions(+), 107 deletions(-) delete mode 100644 automation/InitNode.ps1 diff --git a/automation/ContainerdTools.psm1 b/automation/ContainerdTools.psm1 index be2e85e..4b1ec28 100644 --- a/automation/ContainerdTools.psm1 +++ b/automation/ContainerdTools.psm1 @@ -22,14 +22,15 @@ function Install-Containerd { $Version = Get-ContainerdLatestVersion $Version = $Version.TrimStart('v') - Write-Output "Downloading and installing Containerd v$version at $InstallPath" + Write-Output "* Downloading and installing Containerd v$version at $InstallPath" + "Downloading and installing Containerd v$version at $InstallPath" >> logs # Download file from repo $containerdTarFile = "containerd-${version}-windows-amd64.tar.gz" try { $Uri = "https://github.com/containerd/containerd/releases/download/v$version/$($containerdTarFile)" - Invoke-WebRequest -Uri $Uri -OutFile $DownloadPath\$containerdTarFile -Verbose | Out-Null + Invoke-WebRequest -Uri $Uri -OutFile $DownloadPath\$containerdTarFile | Out-Null } catch { Throw "Containerd download failed. $_" @@ -46,12 +47,13 @@ function Install-Containerd { } - Install-RequiredFeature @params + Install-RequiredFeature @params | Out-Null - Write-Output "Containerd v$version successfully installed at $InstallPath" - containerd.exe -v | Out-Null + Write-Output "* Containerd v$version successfully installed at $InstallPath" + "Containerd v$version successfully installed at $InstallPath" >> logs + containerd.exe -v >> logs - Write-Output "For containerd usage: run 'containerd -h'" + "For containerd usage: run 'containerd -h'" >> logs } function Start-ContainerdService { @@ -66,12 +68,16 @@ function Start-ContainerdService { Throw "Couldn't start Containerd service. $_" } + Write-Output "* Containerd is installed and the service is started ..." + "Containerd is installed and the service is started" >> logs + } function Stop-ContainerdService { $containerdStatus = Get-Service containerd -ErrorAction SilentlyContinue if (!$containerdStatus) { Write-Warning "Containerd service does not exist as an installed service." + "Containerd service does not exist as an installed service." >> logs return } @@ -93,7 +99,7 @@ function Initialize-ContainerdService { $ContainerdPath = "$Env:ProgramFiles\containerd" ) - Write-Output "Configuring the containerd service" + "Configuring the containerd service" >> logs #Configure containerd service $containerdConfigFile = "$ContainerdPath\config.toml" diff --git a/automation/InitNode.ps1 b/automation/InitNode.ps1 deleted file mode 100644 index a205be5..0000000 --- a/automation/InitNode.ps1 +++ /dev/null @@ -1,14 +0,0 @@ -Import-Module -Name "$PSScriptRoot\ContainerdTools.psm1" -Force -Import-Module -Name "$PSScriptRoot\k8Tools.psm1" -Force -Import-Module -Name "$PSScriptRoot\MinikubeTools.psm1" -Force -Import-Module -Name "$PSScriptRoot\NSSMTools.psm1" -Force - -Install-Containerd -Initialize-ContainerdService -Start-ContainerdService -Write-Output "* Containerd is installed and the service is started ..." -Install-NSSM -Write-Output "* NSSM is installed ..." -Install-Kubelet -Write-Output "* Kubelet is installed and the service is started ..." -Set-Port diff --git a/automation/MinikubeTools.psm1 b/automation/MinikubeTools.psm1 index 77b18bb..ae606ea 100644 --- a/automation/MinikubeTools.psm1 +++ b/automation/MinikubeTools.psm1 @@ -1,45 +1,15 @@ -function Start-Minikube { - param ( - [string] - [ValidateNotNullOrEmpty()] - $SwitchName = "External VM Switch" - ) - - minikube start --driver=hyperv --hyperv-virtual-switch=$SwitchName --nodes=2 --cni=flannel --container-runtime=containerd -} - -function Get-LinuxMasterNodeIP { - $IP = minikube ip - return $IP - -} - -function Set-Flannel { - param ( - [string] - $NodeName - ) - - if ($NodeName) { - minikube ssh "sudo sysctl net.bridge.bridge-nf-call-iptables=1 && exit" - } else { - minikube ssh -n $NodeName "sudo sysctl net.bridge.bridge-nf-call-iptables=1 && exit" - } - -} +Import-Module -Name "$PSScriptRoot\k8Tools.psm1" -Force function Get-JoinCommand { param ( [string] - [ValidateNotNullOrEmpty()] - $Version = "v1.27.3" + $KubernetesVersion ) - $JoinCommand = (minikube ssh "cd /var/lib/minikube/binaries/v1.27.3/ && sudo ./kubeadm token create --print-join-command") + $JoinCommand = (minikube ssh "cd /var/lib/minikube/binaries/v$KubernetesVersion/ && sudo ./kubeadm token create --print-join-command") + Write-Output "Join command: $JoinCommand" $outputString = $JoinCommand -replace 'kubeadm', '.\kubeadm' $outputString += ' --cri-socket "npipe:////./pipe/containerd-containerd"' $outputString += ' --v=5' - # Write-Host $outputString - # write this to a log file return $outputString } @@ -75,11 +45,6 @@ function Add-Host { } } - -Export-ModuleMember -Function Start-Minikube -Export-ModuleMember -Function Get-LinuxMasterNodeIP -Export-ModuleMember -Function Set-Flannel Export-ModuleMember -Function Get-JoinCommand -Export-ModuleMember -Function Invoke-RunCommand Export-ModuleMember -Function Set-MinikubeFolderError Export-ModuleMember -Function Add-Host \ No newline at end of file diff --git a/automation/NSSMTools.psm1 b/automation/NSSMTools.psm1 index fefca33..b168f10 100644 --- a/automation/NSSMTools.psm1 +++ b/automation/NSSMTools.psm1 @@ -9,8 +9,17 @@ function Install-NSSM { mkdir "c:\k" | Out-Null } $arch = "win64" - curl.exe -L https://k8stestinfrabinaries.blob.core.windows.net/nssm-mirror/nssm-2.24.zip -o nssm.zip | Out-Null - tar.exe C c:\k\ -xvf .\nssm.zip --strip-components 2 */$arch/*.exe | Out-Null + $nssmZipFile = "nssm-2.24.zip" + $nssmUri = "https://k8stestinfrabinaries.blob.core.windows.net/nssm-mirror/$nssmZipFile" + try { + Invoke-WebRequest -Uri $nssmUri -OutFile "c:\k\$nssmZipFile" | Out-Null + } + catch { + Throw "NSSM download failed. $_" + } + tar.exe C c:\k\ -xf "c:\k\$nssmZipFile" --strip-components 2 */$arch/*.exe | Out-Null + + Write-Output "* NSSM is installed ..." } Export-ModuleMember -Function Install-NSSM \ No newline at end of file diff --git a/automation/Run.ps1 b/automation/Run.ps1 index 0b87816..68c5842 100644 --- a/automation/Run.ps1 +++ b/automation/Run.ps1 @@ -1,5 +1,5 @@ -Import-Module -Name "$PSScriptRoot\ContainerdTools.psm1" -Force Import-Module -Name "$PSScriptRoot\k8Tools.psm1" -Force +Import-Module -Name "$PSScriptRoot\ContainerdTools.psm1" -Force Import-Module -Name "$PSScriptRoot\MinikubeTools.psm1" -Force Import-Module -Name "$PSScriptRoot\NSSMTools.psm1" -Force @@ -8,16 +8,18 @@ function Run { [string]$VMName, [string]$UserName, [string]$Pass, - [System.Management.Automation.PSCredential]$Credential + [System.Management.Automation.PSCredential]$Credential, + [string]$KubernetesVersion ) # create and configure a new minikube cluster - & minikube start --driver=hyperv --hyperv-virtual-switch=$SwitchName --nodes=2 --cni=flannel --container-runtime=containerd + Write-Output "* Creating and configuring a new minikube cluster ..." + & minikube start --driver=hyperv --hyperv-virtual-switch=$SwitchName --nodes=2 --cni=flannel --container-runtime=containerd --kubernetes-version=$KubernetesVersion # & minikube start --driver=hyperv --hyperv-virtual-switch=$SwitchName --memory=4096 --cpus=2 --kubernetes-version=v1.20.2 --network-plugin=cni --cni=flannel --container-runtime=containerd --disk-size=15GB --wait=false >> logs Write-Output "* Minikube cluster is created and configured ..." # Prepare the Linux nodes for Windows-specific Flannel CNI configuration # at the moment we are assuming that you only have two linux nodes named minikube and minikube-m02 - & minikube ssh "sudo sysctl net.bridge.bridge-nf-call-iptables=1 && exit" > logs + & minikube ssh "sudo sysctl net.bridge.bridge-nf-call-iptables=1 && exit" >> logs & minikube ssh -n minikube-m02 "sudo sysctl net.bridge.bridge-nf-call-iptables=1 && exit" >> logs Write-Output "* Linux nodes are ready for Windows-specific Flannel CNI configuration ..." @@ -52,23 +54,47 @@ function Run { Expand-Archive -Path $CompressedFilePath -DestinationPath $UncompressedFolderPath -Force } - Invoke-Command -VMName $VMName -Credential $Credential -ScriptBlock $ScriptBlock + Invoke-Command -VMName $VMName -Credential $Credential -ScriptBlock $ScriptBlock $ScriptBlock = { $UncompressedFolderPath = "C:\Users\Administrator\Documents\MinikubeWindowsContainers" - Import-Module -Name "$UncompressedFolderPath\automation\ContainerdTools.psm1" -Force - Import-Module -Name "$UncompressedFolderPath\automation\k8Tools.psm1" -Force - Import-Module -Name "$UncompressedFolderPath\automation\MinikubeTools.psm1" -Force - Import-Module -Name "$UncompressedFolderPath\automation\NSSMTools.psm1" -Force - - . "$UncompressedFolderPath\automation\InitNode.ps1" + + Install-Containerd + Initialize-ContainerdService + Start-ContainerdService Exit-PSSession } + Invoke-Command -VMName $VMName -Credential $Credential -ScriptBlock $ScriptBlock + + $ScriptBlock = { + $UncompressedFolderPath = "C:\Users\Administrator\Documents\MinikubeWindowsContainers" + Import-Module -Name "$UncompressedFolderPath\automation\NSSMTools.psm1" -Force + Install-NSSM + + Exit-PSSession + } Invoke-Command -VMName $VMName -Credential $Credential -ScriptBlock $ScriptBlock + $ScriptBlock = { + [CmdletBinding()] + param ( + [Parameter()] + [string] + $KubernetesVersion + ) + $UncompressedFolderPath = "C:\Users\Administrator\Documents\MinikubeWindowsContainers" + Import-Module -Name "$UncompressedFolderPath\automation\k8Tools.psm1" -Force + + Install-Kubelet -KubernetesVersion $KubernetesVersion + Set-Port + + Exit-PSSession + } + Invoke-Command -VMName $VMName -Credential $Credential -ScriptBlock $ScriptBlock -ArgumentList $KubernetesVersion + $commandString = "minikube ip" $IP = Invoke-Expression -Command $commandString @@ -92,40 +118,52 @@ function Run { Invoke-Command -VMName $VMName -Credential $Credential -ScriptBlock $ScriptBlock -ArgumentList $IP - $JoinCommand = Get-JoinCommand + $JoinCommand = Get-JoinCommand -Version $KubernetesVersion $ScriptBlock = { [CmdletBinding()] param ( [Parameter()] [string] - $JoinCommand + $JoinCommand, + + [Parameter()] + [string] + $KubernetesVersion ) $UncompressedFolderPath = "C:\Users\Administrator\Documents\MinikubeWindowsContainers" Import-Module -Name "$UncompressedFolderPath\automation\MinikubeTools.psm1" -Force Import-Module -Name "$UncompressedFolderPath\automation\k8Tools.psm1" -Force - Get-Kubeadm + Write-Output "* Get-Kubeadm ..." + Get-Kubeadm -KubernetesVersion $KubernetesVersion + + + Set-Location -Path "C:\k" - Invoke-Expression $JoinCommand + Write-Output "* Joining the Windows node to the cluster ..." + Invoke-Expression "$JoinCommand >> logs 2>&1" Set-MinikubeFolderError - Invoke-Expression $JoinCommand + Invoke-Expression "$JoinCommand >> logs 2>&1" Exit-PSSession } - Invoke-Command -VMName $VMName -Credential $Credential -ScriptBlock $ScriptBlock -ArgumentList $JoinCommand - - # validate windows node successfully join - & kubectl get nodes -o wide >> logs + Invoke-Command -VMName $VMName -Credential $Credential -ScriptBlock $ScriptBlock -ArgumentList $JoinCommand, $KubernetesVersion # configure flannel and kube-proxy on the windows node & kubectl apply -f "..\flannel-overlay.yaml" >> logs & kubectl apply -f "..\kube-proxy.yaml" >> logs + Write-Output "* Waiting for the node to come to a ready state ..." + Start-Sleep -Seconds 30 + + # validate windows node successfully join + & kubectl get nodes -o wide >> logs + # check the status of the windows node & kubectl get nodes -o wide Write-Output "* Windows node is successfully joined and configured ..." diff --git a/automation/SetUp.ps1 b/automation/SetUp.ps1 index 7b3c00e..fdecfc5 100644 --- a/automation/SetUp.ps1 +++ b/automation/SetUp.ps1 @@ -1,6 +1,5 @@ param( - [Parameter(Mandatory=$true)] - [string]$SwitchName, + [string]$SwitchName = "Default Switch", [Parameter(Mandatory=$true)] [string]$ISOFilePath, @@ -12,9 +11,24 @@ param( [string]$UserName, [Parameter(Mandatory=$true)] - [string]$Pass + [string]$Pass, + + [string]$KubernetesVersion ) +Import-Module -Name "$PSScriptRoot\k8Tools.psm1" -Force + + +if ([string]::IsNullOrEmpty($KubernetesVersion)) { + $KubernetesVersion = Get-k8LatestVersion + Write-Output "* The latest Kubernetes version is $KubernetesVersion" + $KubernetesVersion = $KubernetesVersion.TrimStart('v') +} + + +"* Starting the $VMName Virtual Machine ..." > logs +Write-Output "* Starting the $VMName Virtual Machine ..." + $VM = @{ Name = $VMName; Generation = 1; @@ -26,11 +40,12 @@ $VM = @{ SwitchName = $SwitchName } -New-VM @VM +Write-Output "* Please wait as we set up the $VMName Virtual Machine ..." +New-VM @VM | Out-Null Set-VM -Name $VMName -ProcessorCount 2 -AutomaticCheckpointsEnabled $false Set-VMProcessor -VMName $VMName -ExposeVirtualizationExtensions $true Set-VMDvdDrive -VMName $VMName -Path $ISOFilePath -Add-VMDvdDrive -VMName $VMName -Path "$PSScriptRoot\auto-install.iso" -ControllerNumber 1 -ControllerLocation 1 +# Add-VMDvdDrive -VMName $VMName -Path "$PSScriptRoot\auto-install.iso" -ControllerNumber 1 -ControllerLocation 1 Start-VM -Name $VMName | Out-Null @@ -41,15 +56,21 @@ $elapsedTime = 0 do { Start-Sleep -Seconds $retryInterval + "Waiting for the VM to start ..." >> logs $heartbeat = Get-VMIntegrationService -VMName $VMName -Name "Heartbeat" $elapsedTime += $retryInterval if ($elapsedTime -ge $timeout) { - Write-Output "Timeout reached. Exiting the script." + Write-Output "* Timeout reached. Unable to start the VM ..." + Write-Output "* Exiting the script ..." + "Timeout reached. Exiting the script ..." >> logs + "Exiting the script ..." >> logs exit } } while ($heartbeat.PrimaryStatusDescription -ne "OK") +Write-Output "* The $VMName Virtual Machine is started ..." + $SecurePassword = ConvertTo-SecureString -String $Pass -AsPlainText -Force $Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $UserName, $SecurePassword @@ -58,7 +79,7 @@ $VMStatus = Get-VM -Name $VMName | Select-Object -ExpandProperty State if ($VMStatus -eq 'Running') { - Write-Output "The VM $VMName is running" + "The $VMName Virtual Machine is running" >> logs $retryInterval = 45 $timeout = 120 @@ -70,16 +91,17 @@ if ($VMStatus -eq 'Running') { $os = Invoke-Command -VMName $VMName -Credential $Credential -ScriptBlock { Get-WmiObject -Query "SELECT * FROM Win32_OperatingSystem" } -ErrorAction Stop if ($os) { - Write-Output "Windows is installed on $VMName" + Write-Output "* Windows is successfully installed on $VMName" + "Windows is successfully installed on $VMName" >> logs . .\Run.ps1 # . "$PSScriptRoot\Run.ps1" === this also works - RUN -VMName $VMName -UserName $UserName -Pass $Pass -Credential $Credential + RUN -VMName $VMName -UserName $UserName -Pass $Pass -Credential $Credential -KubernetesVersion $KubernetesVersion break } else { - Write-Output "Windows is not installed on $VMName" + Write-Output "* Windows is not installed on $VMName" } } catch { - Write-Output "An error occurred while checking if Windows is installed on ${VMName}: $_" + Write-Output "* An error occurred while checking if Windows is installed on ${VMName}: $_" } Start-Sleep -Seconds $retryInterval $elapsedTime += $retryInterval diff --git a/automation/SetUpUtilities.psm1 b/automation/SetUpUtilities.psm1 index f771c74..801d1d9 100644 --- a/automation/SetUpUtilities.psm1 +++ b/automation/SetUpUtilities.psm1 @@ -90,7 +90,7 @@ function Add-FeatureToPath { $currPath = (Get-ItemProperty -Path $envPathRegKey -Name path).path $currPath = ParsePathString -PathString $currPath if (!($currPath -like "*$feature*")) { - Write-Information -InformationAction Continue -MessageData "Adding $feature to Environment Path RegKey" + # Write-Information -InformationAction Continue -MessageData "Adding $feature to Environment Path RegKey" # Add to reg key Set-ItemProperty -Path $envPathRegKey -Name PATH -Value "$currPath;$path" @@ -98,7 +98,7 @@ function Add-FeatureToPath { $currPath = ParsePathString -PathString $env:Path if (!($currPath -like "*$feature*")) { - Write-Information -InformationAction Continue -MessageData "Adding $feature to env path" + # Write-Information -InformationAction Continue -MessageData "Adding $feature to env path" # Add to env path [Environment]::SetEnvironmentVariable("Path", "$($env:path);$path", [System.EnvironmentVariableTarget]::Machine) $env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") diff --git a/automation/k8Tools.psm1 b/automation/k8Tools.psm1 index 9040861..c7f214a 100644 --- a/automation/k8Tools.psm1 +++ b/automation/k8Tools.psm1 @@ -1,8 +1,14 @@ +Import-Module -Name "$PSScriptRoot\SetUpUtilities.psm1" -Force + +function Get-k8LatestVersion { + $latestVersion = Get-LatestToolVersion -Repository "kubernetes/kubernetes" + return $latestVersion +} + function Install-Kubelet { param ( [string] - [ValidateNotNullOrEmpty()] - $KubernetesVersion = "v1.27.3" + $KubernetesVersion ) # Check if kubelet service is already installed @@ -13,10 +19,14 @@ function Install-Kubelet { } # Define the URL for kubelet download - $KubeletUrl = "https://dl.k8s.io/$KubernetesVersion/bin/windows/amd64/kubelet.exe" + $KubeletUrl = "https://dl.k8s.io/v$KubernetesVersion/bin/windows/amd64/kubelet.exe" # Download kubelet - Invoke-WebRequest -Uri $KubeletUrl -OutFile "c:\k\kubelet.exe" | Out-Null + try { + Invoke-WebRequest -Uri $KubeletUrl -OutFile "c:\k\kubelet.exe" | Out-Null + } catch { + Write-Error "Failed to download kubelet: $_" + } # Create the Start-kubelet.ps1 script @" @@ -41,6 +51,8 @@ Invoke-Expression `$kubeletCommandLine c:\k\nssm.exe install kubelet Powershell -ExecutionPolicy Bypass -NoProfile c:\k\Start-kubelet.ps1 | Out-Null c:\k\nssm.exe set Kubelet AppStdout C:\k\kubelet.log | Out-Null c:\k\nssm.exe set Kubelet AppStderr C:\k\kubelet.err.log | Out-Null + + Write-Output "* Kubelet is installed and the service is started ..." } function Set-Port { @@ -50,21 +62,33 @@ function Set-Port { return } - New-NetFirewallRule -Name 'kubelet' -DisplayName 'kubelet' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 10250 | Out-Null + $ruleParams = @{ + Name = 'kubelet' + DisplayName = 'kubelet' + Enabled = "True" + Direction = 'Inbound' + Protocol = 'TCP' + Action = 'Allow' + LocalPort = 10250 + } + + New-NetFirewallRule @ruleParams | Out-Null } function Get-Kubeadm { param ( [string] - [ValidateNotNullOrEmpty()] - $KubernetesVersion = "v1.27.3" + $KubernetesVersion ) - curl.exe -L https://dl.k8s.io/$KubernetesVersion/bin/windows/amd64/kubeadm.exe -o c:\k\kubeadm.exe | Out-Null - Set-Location c:\k | Out-Null + try { + Invoke-WebRequest -Uri "https://dl.k8s.io/v$KubernetesVersion/bin/windows/amd64/kubeadm.exe" -OutFile "c:\k\kubeadm.exe" | Out-Null + } catch { + Write-Error "Failed to download kubeadm: $_" + } } - -# Example usage: Install-Kubelet -KubernetesVersion "v1.27.3" +Export-ModuleMember -Function Get-k8LatestVersion Export-ModuleMember -Function Install-Kubelet Export-ModuleMember -Function Set-Port -Export-ModuleMember -Function Get-Kubeadm \ No newline at end of file +Export-ModuleMember -Function Get-Kubeadm +Export-ModuleMember -Function Get-k8LatestVersion From 59a7270b26e29509abdc04e2c6e5ccb30fde0c0f Mon Sep 17 00:00:00 2001 From: "Bob Sira (from Dev Box)" <bosira@microsoft.com> Date: Mon, 11 Mar 2024 22:20:52 +0000 Subject: [PATCH 46/52] final changes, kalkikubes --- automation/ContainerdTools.psm1 | 2 +- automation/MinikubeTools.psm1 | 3 +-- automation/Run.ps1 | 7 ++++--- automation/SetUpUtilities.psm1 | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/automation/ContainerdTools.psm1 b/automation/ContainerdTools.psm1 index 4b1ec28..d06493c 100644 --- a/automation/ContainerdTools.psm1 +++ b/automation/ContainerdTools.psm1 @@ -105,7 +105,7 @@ function Initialize-ContainerdService { $containerdConfigFile = "$ContainerdPath\config.toml" $containerdDefault = containerd.exe config default $containerdDefault | Out-File $ContainerdPath\config.toml -Encoding ascii - Write-Information -InformationAction Continue -MessageData "Review containerd configutations at $containerdConfigFile" + Write-Information -InformationAction Continue -MessageData "* Review containerd configutations at $containerdConfigFile ..." Add-MpPreference -ExclusionProcess "$ContainerdPath\containerd.exe" diff --git a/automation/MinikubeTools.psm1 b/automation/MinikubeTools.psm1 index ae606ea..314b568 100644 --- a/automation/MinikubeTools.psm1 +++ b/automation/MinikubeTools.psm1 @@ -6,8 +6,7 @@ function Get-JoinCommand { $KubernetesVersion ) $JoinCommand = (minikube ssh "cd /var/lib/minikube/binaries/v$KubernetesVersion/ && sudo ./kubeadm token create --print-join-command") - Write-Output "Join command: $JoinCommand" - $outputString = $JoinCommand -replace 'kubeadm', '.\kubeadm' + $outputString = $JoinCommand -replace 'kubeadm', '.\kubeadm.exe' $outputString += ' --cri-socket "npipe:////./pipe/containerd-containerd"' $outputString += ' --v=5' return $outputString diff --git a/automation/Run.ps1 b/automation/Run.ps1 index 68c5842..fbe5a3a 100644 --- a/automation/Run.ps1 +++ b/automation/Run.ps1 @@ -118,7 +118,7 @@ function Run { Invoke-Command -VMName $VMName -Credential $Credential -ScriptBlock $ScriptBlock -ArgumentList $IP - $JoinCommand = Get-JoinCommand -Version $KubernetesVersion + $JoinCommand = Get-JoinCommand -KubernetesVersion $KubernetesVersion $ScriptBlock = { [CmdletBinding()] @@ -136,13 +136,14 @@ function Run { Import-Module -Name "$UncompressedFolderPath\automation\MinikubeTools.psm1" -Force Import-Module -Name "$UncompressedFolderPath\automation\k8Tools.psm1" -Force - Write-Output "* Get-Kubeadm ..." + Get-Kubeadm -KubernetesVersion $KubernetesVersion Set-Location -Path "C:\k" Write-Output "* Joining the Windows node to the cluster ..." + Invoke-Expression "$JoinCommand >> logs 2>&1" Set-MinikubeFolderError @@ -159,7 +160,7 @@ function Run { & kubectl apply -f "..\kube-proxy.yaml" >> logs Write-Output "* Waiting for the node to come to a ready state ..." - Start-Sleep -Seconds 30 + Start-Sleep -Seconds 40 # validate windows node successfully join & kubectl get nodes -o wide >> logs diff --git a/automation/SetUpUtilities.psm1 b/automation/SetUpUtilities.psm1 index 801d1d9..b9b30a6 100644 --- a/automation/SetUpUtilities.psm1 +++ b/automation/SetUpUtilities.psm1 @@ -35,7 +35,7 @@ function Install-RequiredFeature { ) # Create the directory to untar to - Write-Information -InformationAction Continue -MessageData "Extracting $Feature to $InstallPath" + Write-Information -InformationAction Continue -MessageData "* Extracting $Feature to $InstallPath ..." if (!(Test-Path $InstallPath)) { New-Item -ItemType Directory -Force -Path $InstallPath | Out-Null } From e6fbbed861c20099212f1e46e7a814b2b653c075 Mon Sep 17 00:00:00 2001 From: "Bob Sira (from Dev Box)" <bosira@microsoft.com> Date: Tue, 19 Mar 2024 23:46:46 +0000 Subject: [PATCH 47/52] final polish --- .../auto-install.iso => auto-install.iso | Bin 73728 -> 73728 bytes automation/Remote.psm1 | 89 ------------------ automation/Run.ps1 | 4 +- automation/SetUp.ps1 | 2 +- 4 files changed, 4 insertions(+), 91 deletions(-) rename automation/auto-install.iso => auto-install.iso (98%) delete mode 100644 automation/Remote.psm1 diff --git a/automation/auto-install.iso b/auto-install.iso similarity index 98% rename from automation/auto-install.iso rename to auto-install.iso index 7ed2d7be6ce4c8b5b00c47c7bf88529cb0c6569b..3222d08c0913892442541fcc3c094211f7559bbf 100644 GIT binary patch delta 428 zcmZoTz|wGlWrIcotD!}_f$?PBh9-VyA#ol>1||juMj&Ej*nF^|mT|Im(|1{8LklBg zLnC8j0|N#l10xdyWP#28&9_)M4H+yL;u#DWj3*m))S{a-`D2&(q;8JEfF|2^eI?|d z?js>=z_8$FWtc4aKt=<?gar$u5rZ597|4lggJ^Bh8fF$D4ikpWu@APf!!^FZ(CCC) k<BLdPM&s%8I2dIoJA7l?eCxLs2TOUek<oT`7RDda0C|sX(f|Me delta 429 zcmZoTz|wGlWrIcotASCxf#GD`h9-U{Mll&Z9wr6`Mj&Ej*nF^|mT|Im(|1`T14APt zBMTEV0|Oo-10xdyWP#28&9_)M4H%3V;u#DW3@00P)S{a-`D2&(q;8JEfF|2^eI?|d z?js>=z_5@N;F&D>Kt=<?gar$u5rZ597|4legJ^A$8lVbkHlEF~54N$xHNL>m=!9G2 ki%4Ncqv`WG7-c6rd}G^u>$esMbFP8ub`BQCAJU8r08ou>%K!iX diff --git a/automation/Remote.psm1 b/automation/Remote.psm1 deleted file mode 100644 index 1abfbf9..0000000 --- a/automation/Remote.psm1 +++ /dev/null @@ -1,89 +0,0 @@ -function Get-HyperV { - $hyperv = Get-WindowsOptionalFeature -FeatureName Microsoft-Hyper-V-All -Online - if($hyperv.State -eq "Enabled") { - Write-Host "Hyper-V is enabled." - } else { - Write-Host "Hyper-V is disabled." - } - -} - -function Set-VmSwitch { - param ( - [String] - [ValidateNotNullOrEmpty()] - $SwitchName = 'External VM Switch' - ) - $Switch = Get-VMSwitch -Name $SwitchName -ErrorAction SilentlyContinue - if ($Switch -eq $null) { - New-VMSwitch -Name $SwitchName -AllowManagementOS $True -NetAdapterName (Get-NetAdapter | Where-Object {$_.Status -eq 'Up' -and $_.Name -notlike '*vEthernet*'}).Name - } - # assign the switch created to a variable and return it from the function - $Switch = Get-VMSwitch -Name $SwitchName - return $Switch -} - -# pass switch as parameter -function Start-VirtualMachine { - param ( - [String] - [ValidateNotNullOrEmpty()] - $VMName, - - [String] - [ValidateNotNullOrEmpty()] - $SwitchName, - - [String] - [ValidateNotNullOrEmpty()] - $ISOFile - ) - - # set the vm switch first - $Switch = Set-VmSwitch -SwitchName $SwitchName - - $VM = @{ - Name = $VMName - MemoryStartupBytes = 1GB - NewVHDPath = "${env:homepath}\.minikube\machines\$VMName\VHD.vhdx" - NewVHDSizeBytes = 10GB - BootDevice = "VHD" - Path = "${env:homepath}\.minikube\machines\" - SwitchName = $Switch.Name - } - - New-VM @VM - - Set-VM -Name $VMName -ProcessorCount 2 -AutomaticCheckpointsEnabled $false - Set-VMProcessor -VMName $VMName -ExposeVirtualizationExtensions $true - Set-VMDvdDrive -VMName $VMName -Path $ISOFile - Start-VM -Name $VMName -} - -function Set-NodeForMinikube { - param( - [string] - [ValidateNotNullOrEmpty()] - $NewName = "minikube-m03" - ) - - Set-SConfig -AutoLaunch $false - Restart-Computer -Force - Install-WindowsFeature -Name containers - Restart-Computer -Force - -} - - -function Remove-VirtualMachine { - param ( - [String] - [ValidateNotNullOrEmpty()] - $VMName - ) - - Stop-VM -Name $VMName -TurnOff - Remove-VM -Name $VMName -Force - Remove-Item -Path ${env:homepath}\.minikube\machines\$VMName -Force -Recurse - -} \ No newline at end of file diff --git a/automation/Run.ps1 b/automation/Run.ps1 index fbe5a3a..abcb667 100644 --- a/automation/Run.ps1 +++ b/automation/Run.ps1 @@ -40,7 +40,9 @@ function Run { $LocalScriptsPath = Split-Path -Path $CurrrentDirectory -Parent $CompressedFilePath = "$LocalScriptsPath\MinikubeWindowsContainers.zip" - Compress-Archive -Path $LocalScriptsPath -DestinationPath $CompressedFilePath -Force + # 'auto-install.iso' is not being compressed since another process will be using it + # hack way of compressing the error but it works, needs exploration + Compress-Archive -Path $LocalScriptsPath -DestinationPath $CompressedFilePath -Force 2>$null $RemoteScriptsPath = "C:\Users\Administrator\Documents" diff --git a/automation/SetUp.ps1 b/automation/SetUp.ps1 index fdecfc5..977e461 100644 --- a/automation/SetUp.ps1 +++ b/automation/SetUp.ps1 @@ -45,7 +45,7 @@ New-VM @VM | Out-Null Set-VM -Name $VMName -ProcessorCount 2 -AutomaticCheckpointsEnabled $false Set-VMProcessor -VMName $VMName -ExposeVirtualizationExtensions $true Set-VMDvdDrive -VMName $VMName -Path $ISOFilePath -# Add-VMDvdDrive -VMName $VMName -Path "$PSScriptRoot\auto-install.iso" -ControllerNumber 1 -ControllerLocation 1 +Add-VMDvdDrive -VMName $VMName -Path "..\auto-install.iso" -ControllerNumber 1 -ControllerLocation 1 Start-VM -Name $VMName | Out-Null From 62e42bf646b2a0b4531eb9964bc79aff8d9ab556 Mon Sep 17 00:00:00 2001 From: Bob Sira <sbobfitz2@gmail.com> Date: Sat, 21 Sep 2024 16:51:41 +0100 Subject: [PATCH 48/52] added SSH setup during auto-install --- automation/autounattend.xml | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/automation/autounattend.xml b/automation/autounattend.xml index 51d9d00..c45e7ce 100644 --- a/automation/autounattend.xml +++ b/automation/autounattend.xml @@ -151,9 +151,31 @@ <Order>8</Order> <Description>Turns off Server Configuration tool (SConfig)</Description> </SynchronousCommand> + <!-- SSH Install Commands --> <SynchronousCommand wcm:action="add"> - <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -Command Restart-Computer -Force</CommandLine> + <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -Command "Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0"</CommandLine> + <Description>Install OpenSSH Server</Description> <Order>9</Order> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -Command "Start-Service sshd"</CommandLine> + <Description>Start SSH Service</Description> + <Order>10</Order> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -Command "Set-Service -Name sshd -StartupType 'Automatic'"</CommandLine> + <Description>Set SSH Service to Automatic</Description> + <Order>11</Order> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -Command "New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22"</CommandLine> + <Description>Open Firewall Port for SSH</Description> + <Order>12</Order> + </SynchronousCommand> + <!-- --> + <SynchronousCommand wcm:action="add"> + <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -Command Restart-Computer -Force</CommandLine> + <Order>13</Order> <Description>Restart computer to apply changes</Description> </SynchronousCommand> </FirstLogonCommands> From 2fa904f36f3c07b4388ab58ba7e38ecceea526fd Mon Sep 17 00:00:00 2001 From: Bob Sira <sbobfitz2@gmail.com> Date: Sat, 21 Sep 2024 17:34:41 +0100 Subject: [PATCH 49/52] bundled the new xml answer file into an iso --- automation/auto-install.iso | Bin 0 -> 75776 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 automation/auto-install.iso diff --git a/automation/auto-install.iso b/automation/auto-install.iso new file mode 100644 index 0000000000000000000000000000000000000000..f8ef58d1a6b2e0498c7686ea3ffdcc74c99353bf GIT binary patch literal 75776 zcmeI5e{b8y8OQ0Ne<b;<1KMHO+U}|~NHTz;BqwR&G3sPnX^q*AV98B87$|7!WDzEL z9Di8WFbsPSdr5sKdn4O($CE6X`kBpf+I$(rCXdIv<L91xevy(50~-i{00@8p2!H?x zfB*=900@8p2!H?xfB*=900@8p2!H?xfB*=900@8p2!H?xfB*=900@8p2!H?xfB*=9 z00@8p2!H?xfB*=900@8p2!H?xfB*=900@8p2!H?xfB*=900@8p2!H?xfB*=900@8p z2!H?xfB*=900@8p2!H?xfB*=900@8p2!H?xfB*=900@8p2!H?xfB*=900@8p2!H?x zfB*=900@8p2!H?xfB*=900@8p2!O!G&Tger-7sEz;bx7^-)hw#D$jqYRceoC*BOz# zpYP~jqtfE<4a3-w|BX9$jC=X%dmmj@`<2`+8K2}OpBQ)K&K=|LcR&8+N5A{v7xF@R zJ;QdZ1RCLRJB!0x9m8AfT#A3?d97OgvR2uwRw^G93M$t&<JxgW3NAJf009tq7YO`9 z+kfM=;TfT^Y19lh^Iy%V8b25n<2n7T(eIk^c&eVhnUVd!Z#5U*9;v|%`G3;>|N82R z-^ksP@o8T2={);CHG<jWM(IrwXpqbdjcp?{V%odOp5DCem4>xarGmLH6co&Tp<v@m z$gu|kAOHflN#H*t`+u8*K;Iw$0w4eaAOHeyl|bY0`|abSL&n}}ujmW}KmY_l00cnb zHVJH~XY5Ey-sT*jZx8?h5C8!X009sH0T2KI5C8!XxM>0^^8ds@0^p`WqkRwn0T2KI z5C8!X009sH0T2KI5V%DG8|pK52>)+!3eYtOfB*=900@8p2!H?xfB*=900`VT0Tuaw zis%0~4jLVR00@8p2!H?xfB*=900@8p2!OyX5}5rR`yc=D>O1zA*4U^SpXGP(*^gDZ z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Ky%+e{Lba70JNgIwN z>37%WteQ}gs+(CIag|=knBxxooES@Wr3vS5y5vmpykwt6^0hDaK&ml%W65(LtUm!f zoy0GV{J6C>=3@T4c|W7Mm>F)V&?%pjsmN<ub5M+>Q;V!aFZIbNEv8qRWq7j}o{Eg( z{Hf51OjCZgp?tB4FsoKudyeH$*eFP3Dp->t6luyeW_W(`X2ltnCh46uKiWQ0oSZ17 zM#t)j+8X(>To+ZB<R>PLjP8uNqt2x79YvHQar^WxIA7*TF9%PrFD}VRt0XzSr9vW@ z&PrELrOxN)+Lh_M*+l;eBgs?y#k(myiYz>xawBhx95m@m<S&oOg8Y>+`PqhG%iW^4 z-h#yP^4E;y>tnwkC0BBHgVBSH8f!O?zHJ`uHad-+=3%FKH2Q=9wYTWg6?D49Ec!sk X_{F*U`})xp+&2h-00@A<|3KiskhOc_ literal 0 HcmV?d00001 From ed08391d61f4db9d3a670f5bfbb2cf8d4fe980f4 Mon Sep 17 00:00:00 2001 From: Bob Sira <sbobfitz2@gmail.com> Date: Sat, 21 Sep 2024 17:58:33 +0100 Subject: [PATCH 50/52] fixed the path mismatch value --- auto-install.iso | Bin 73728 -> 75776 bytes automation/auto-install.iso | Bin 75776 -> 0 bytes 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 automation/auto-install.iso diff --git a/auto-install.iso b/auto-install.iso index 3222d08c0913892442541fcc3c094211f7559bbf..f8ef58d1a6b2e0498c7686ea3ffdcc74c99353bf 100644 GIT binary patch delta 1109 zcmd5)&ubGw6y6D|Z4S~_j7e)-pOunQnC<K|P(tyL{tyLeV-xUH;&yk$h0V^gyD<s) zV^I&%p6Y`61H5@s0(w>IQ9-YQ(qpeZ*n$_`A4x3~$<^6mci8vd_r33X<GmNXFXHPd z?-Z3QB=2MIa{r_dt;uZ!e#4s^NT!C)T@(|7fP#&L_6P3)^5-8Pj^(K=&rvcf6CzSV zbL9As_Ue;wBBg>XR0JaAgEtMnRLBW%?1`y_F6HFR@-`at8_!O#`um&d=Ue^%!}hOi z{_LfF>tp$J;9F{5^oMsxr{ZJRLPUk}Sorvk93JGI`^nUxbU|#d@4oFjD%?9!xbW}7 zy_YkYOBh3`bPcYXj;k03Eb?kqF*V2k`YYA?okmY9%MGU1T%DUmZs=+g7MhmgIDk8u zFj3Gnd`mYqUUwE1OWDv3-E9J1H4WWlfLD|%gH?-}0gY5*_C01l3>J}yBuiwXb^9zL zE$KY!8|Y?1oYmSNMANNL88q@Dg<j=)_EB;b+r?q6t}<|(yIKrB6a^xconVBVkct1} zU^v9S*&CbvMUEAP_<$qmnpJLE46=oq%d3j3tJ#=%w8Y%wwBT|$%87bFvj6=clJ}@* z3oERSSD1TMw^==y)LPBxnj5#Wq&t?OG$XsS9ltwHW&tmo%7(!-DBHE5Y$*Uy!<hzi z-{3V<gK1o}xyw~<KzXqUxDba6hQaHAZ*WyHirjXA(pcL_$N=4DAd21Lb||;wF73FR e6~jB$y-%ML@@x<oYk6sO=G|ciCHvkCuAx6Xk5G01 delta 491 zcmZp;z|wGlWrIcotD!}_f$?PB24xNv1~5>W$fz*6qQRV>SxB5mk%5VUff0xp88#nm zsAZgN-Sl17*wDhr*wDz>*ua3n$iT?N09jzOfAcLCBSQuYhIj@824f&;1f-1^Oc)f9 zAjB#Ln3byft`iw$Cs%Y}*gE-Rm-wV^j=_K?+je~=<oE6)A#A{K<7Z`<Ecrl21Hyy_ zA)^t49K_>tqS_#awrCAAix7ti!{*or+t}e6Utnl-!maVeV*Tm;VvOC>E#w&;r#DD4 VN=<h7#yVYAhLLCcQh7#Bb^u^mbB6!` diff --git a/automation/auto-install.iso b/automation/auto-install.iso deleted file mode 100644 index f8ef58d1a6b2e0498c7686ea3ffdcc74c99353bf..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 75776 zcmeI5e{b8y8OQ0Ne<b;<1KMHO+U}|~NHTz;BqwR&G3sPnX^q*AV98B87$|7!WDzEL z9Di8WFbsPSdr5sKdn4O($CE6X`kBpf+I$(rCXdI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9%PrFD}VRt0XzSr9vW@ z&PrELrOxN)+Lh_M*+l;eBgs?y#k(myiYz>xawBhx95m@m<S&oOg8Y>+`PqhG%iW^4 z-h#yP^4E;y>tnwkC0BBHgVBSH8f!O?zHJ`uHad-+=3%FKH2Q=9wYTWg6?D49Ec!sk X_{F*U`})xp+&2h-00@A<|3KiskhOc_ From e3beabb956bcebec9e5673c7f945d9819fe9f0d0 Mon Sep 17 00:00:00 2001 From: Bob Sira <sbobfitz2@gmail.com> Date: Mon, 23 Sep 2024 18:17:14 +0100 Subject: [PATCH 51/52] swapped the SSH configuration ordering --- auto-install.iso | Bin 75776 -> 73728 bytes automation/autounattend.xml | 391 +++++++++++++++++++----------------- 2 files changed, 203 insertions(+), 188 deletions(-) diff --git a/auto-install.iso b/auto-install.iso index f8ef58d1a6b2e0498c7686ea3ffdcc74c99353bf..0128b38e897e5c6f5104809396d16c68d49a7362 100644 GIT binary patch literal 73728 zcmeI5{cqdG8OQ0OKg9WAD28DhhPJqBDdG&EDa%Qg7>qjER$60z5iGfB2LlC7oh-s6 zkK>DF4a2biVgKR&k?pzTQ6?=~_PWMSlP`nV)ZOuT_qpeuH!_N0-~a&-009sH0T2KI z5C8!X009sH0T2KI5C8!X009sH0T2KI5C8!X009sH0T2KI5C8!X009sH0T2KI5C8!X z009sH0T2KI5C8!X009sH0T2KI5C8!X009sH0T2KI5C8!X009sH0T2KI5C8!X009sH z0T2KI5C8!X009sH0T2KI5C8!X009sH0T2KI5C8!X009sH0T2KI5C8!X009sH0T2KI z5C8!X009sH0T2KI5C8!X009sH0T5W)+HN-2mW(%ExZYydAFcHtnlFE7HCs>X+Y}@p z<tO@AQ9A#7$uO4WU*o|8<6&O?@K=}3el1TM#;1A7r^W+$^1%4}@^3y_|LEh7<c0Ej zhT~odbi(Oo7KisbhC95u6#wSS*81A>XKT$?v-$B{LG#LCT>0FTf{OzLKmY{Z1p*&w z`)|B4JR>yLjh4Y`|Fo#?2cv1cq@OMN-7=n5+Udy@_Ww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attend.xml +++ b/automation/autounattend.xml @@ -1,191 +1,206 @@ <?xml version="1.0" encoding="utf-8"?> -<unattend xmlns="urn:schemas-microsoft-com:unattend"> - <settings pass="windowsPE"> - <component name="Microsoft-Windows-International-Core-WinPE" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <SetupUILanguage> - <UILanguage>en-US</UILanguage> - </SetupUILanguage> +<unattend + xmlns="urn:schemas-microsoft-com:unattend"> + <settings pass="windowsPE"> + <component name="Microsoft-Windows-International-Core-WinPE" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" + xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <SetupUILanguage> + <UILanguage>en-US</UILanguage> + </SetupUILanguage> <InputLocale>en-US</InputLocale> - <SystemLocale>en-US</SystemLocale> - <UILanguage>en-US</UILanguage> - <UserLocale>en-US</UserLocale> - </component> - <component name="Microsoft-Windows-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <DiskConfiguration> - <Disk wcm:action="add"> - <CreatePartitions> - <CreatePartition wcm:action="add"> - <Size>250</Size> - <Order>1</Order> - <Type>Primary</Type> - </CreatePartition> - <CreatePartition wcm:action="add"> - <Order>2</Order> - <Extend>true</Extend> - <Type>Primary</Type> - </CreatePartition> - </CreatePartitions> - <ModifyPartitions> - <ModifyPartition wcm:action="add"> - <Order>1</Order> - <PartitionID>1</PartitionID> - <Format>NTFS</Format> - <Label>Boot</Label> - <Active>true</Active> - </ModifyPartition> - <ModifyPartition wcm:action="add"> - <Order>2</Order> - <PartitionID>2</PartitionID> - <Format>NTFS</Format> - <Label>System</Label> - </ModifyPartition> - </ModifyPartitions> - <DiskID>0</DiskID> - <WillWipeDisk>true</WillWipeDisk> - </Disk> - </DiskConfiguration> - <ImageInstall> - <OSImage> - <InstallFrom> - <!-- https://docs.microsoft.com/en-us/windows-hardware/customize/desktop/unattend/microsoft-windows-setup-imageinstall-dataimage-installfrom-metadata-key --> - <!-- Get-WindowsImage -ImagePath D:\sources\install.wim --> - <MetaData wcm:action="add"> - <Key>/IMAGE/INDEX </Key> - <Value>3</Value> - </MetaData> - </InstallFrom> - <InstallTo> - <DiskID>0</DiskID> - <PartitionID>2</PartitionID> - </InstallTo> - <WillShowUI>OnError</WillShowUI> - <InstallToAvailablePartition>false</InstallToAvailablePartition> - </OSImage> - </ImageInstall> - <UserData> - <AcceptEula>true</AcceptEula> - <ProductKey> - <WillShowUI>Never</WillShowUI> - <!-- Do not uncomment the Key element if you are using trial ISOs --> - <!-- You must uncomment the Key element (and optionally insert your own key) if you are using retail or volume license ISOs --> - <!-- <Key>11111-22222-33333-44444-55555</Key> --> - </ProductKey> - </UserData> - </component> - </settings> - <settings pass="specialize"> - <component name="Microsoft-Windows-International-Core" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <!-- https://docs.microsoft.com/en-us/windows-hardware/customize/desktop/unattend/microsoft-windows-international-core --> - <InputLocale>en-US</InputLocale> - <SystemLocale>en-US</SystemLocale> - <UILanguage>en-US</UILanguage> - <UILanguageFallback>en-US</UILanguageFallback> - <UserLocale>en-US</UserLocale> - </component> - <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <!-- https://docs.microsoft.com/en-us/windows-hardware/customize/desktop/unattend/microsoft-windows-shell-setup --> - <ComputerName>minikube-ws22</ComputerName> - <TimeZone>Central Standard Time</TimeZone> - <CopyProfile>true</CopyProfile> - </component> - <component name="Microsoft-Windows-Security-SPP-UX" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <!-- https://docs.microsoft.com/en-us/windows-hardware/customize/desktop/unattend/microsoft-windows-security-spp-ux --> - <SkipAutoActivation>true</SkipAutoActivation> - </component> - </settings> - <settings pass="oobeSystem"> - <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <!-- https://docs.microsoft.com/en-us/windows-hardware/customize/desktop/unattend/microsoft-windows-shell-setup --> - <AutoLogon> - <Password> - <Value>Minikube@2024</Value> - <PlainText>true</PlainText> - </Password> - <Username>Administrator</Username> - <Enabled>true</Enabled> - </AutoLogon> - <FirstLogonCommands> - <SynchronousCommand wcm:action="add"> - <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -Command New-SelfSignedCertificate -CertstoreLocation Cert:\LocalMachine\My -DnsName "WinRMCertificate"</CommandLine> - <Description>Certificate for WinRM</Description> - <Order>1</Order> - <RequiresUserInput>true</RequiresUserInput> - </SynchronousCommand> - <SynchronousCommand wcm:action="add"> - <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -Command Enable-PSRemoting -SkipNetworkProfileCheck -Force</CommandLine> - <Description>Enable WinRM</Description> - <Order>2</Order> - <RequiresUserInput>true</RequiresUserInput> - </SynchronousCommand> - <SynchronousCommand wcm:action="add"> - <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -Command ($cert = gci Cert:\LocalMachine\My\) -and (New-Item -Path WSMan:\LocalHost\Listener -Transport HTTPS -Address * -CertificateThumbPrint $cert.Thumbprint –Force)</CommandLine> - <Description>Add HTTPS WinRM listener with previously generated certificate</Description> - <Order>3</Order> - <RequiresUserInput>true</RequiresUserInput> - </SynchronousCommand> - <SynchronousCommand wcm:action="add"> - <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -Command New-NetFirewallRule -DisplayName 'Windows Remote Management (HTTPS-In)' -Name 'Windows Remote Management (HTTPS-In)' -Profile Any -LocalPort 5986 -Protocol TCP</CommandLine> - <Description>Add firewall exception to TCP port 5986 for WinRM over HTTPS</Description> - <Order>4</Order> - <RequiresUserInput>true</RequiresUserInput> - </SynchronousCommand> - <SynchronousCommand wcm:action="add"> - <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -Command Set-Item WSMan:\localhost\Service\Auth\Basic -Value $true</CommandLine> - <Description>Enable Basic authentication</Description> - <Order>5</Order> - <RequiresUserInput>true</RequiresUserInput> - </SynchronousCommand> - <SynchronousCommand wcm:action="add"> - <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -Command Stop-Service WinRM</CommandLine> - <Description>Stop the WinRM service to allow the dism process to finish before packer executes scripts</Description> - <Order>6</Order> - <RequiresUserInput>true</RequiresUserInput> - </SynchronousCommand> - <SynchronousCommand wcm:action="add"> - <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -Command Install-WindowsFeature -Name containers</CommandLine> - <Order>7</Order> - <Description>Installs Containers feature</Description> - </SynchronousCommand> - <SynchronousCommand wcm:action="add"> - <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -Command Set-SConfig -AutoLaunch $false</CommandLine> - <Order>8</Order> - <Description>Turns off Server Configuration tool (SConfig)</Description> - </SynchronousCommand> - <!-- SSH Install Commands --> - <SynchronousCommand wcm:action="add"> - <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -Command "Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0"</CommandLine> - <Description>Install OpenSSH Server</Description> - <Order>9</Order> - </SynchronousCommand> - <SynchronousCommand wcm:action="add"> - <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -Command "Start-Service sshd"</CommandLine> - <Description>Start SSH Service</Description> - <Order>10</Order> - </SynchronousCommand> - <SynchronousCommand wcm:action="add"> - <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -Command "Set-Service -Name sshd -StartupType 'Automatic'"</CommandLine> - <Description>Set SSH Service to Automatic</Description> - <Order>11</Order> - </SynchronousCommand> - <SynchronousCommand wcm:action="add"> - <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -Command "New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22"</CommandLine> - <Description>Open Firewall Port for SSH</Description> - <Order>12</Order> - </SynchronousCommand> - <!-- --> + <SystemLocale>en-US</SystemLocale> + <UILanguage>en-US</UILanguage> + <UserLocale>en-US</UserLocale> + </component> + <component name="Microsoft-Windows-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" + xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <DiskConfiguration> + <Disk wcm:action="add"> + <CreatePartitions> + <CreatePartition wcm:action="add"> + <Size>250</Size> + <Order>1</Order> + <Type>Primary</Type> + </CreatePartition> + <CreatePartition wcm:action="add"> + <Order>2</Order> + <Extend>true</Extend> + <Type>Primary</Type> + </CreatePartition> + </CreatePartitions> + <ModifyPartitions> + <ModifyPartition wcm:action="add"> + <Order>1</Order> + <PartitionID>1</PartitionID> + <Format>NTFS</Format> + <Label>Boot</Label> + <Active>true</Active> + </ModifyPartition> + <ModifyPartition wcm:action="add"> + <Order>2</Order> + <PartitionID>2</PartitionID> + <Format>NTFS</Format> + <Label>System</Label> + </ModifyPartition> + </ModifyPartitions> + <DiskID>0</DiskID> + <WillWipeDisk>true</WillWipeDisk> + </Disk> + </DiskConfiguration> + <ImageInstall> + <OSImage> + <InstallFrom> + <!-- https://docs.microsoft.com/en-us/windows-hardware/customize/desktop/unattend/microsoft-windows-setup-imageinstall-dataimage-installfrom-metadata-key --> + <!-- Get-WindowsImage -ImagePath D:\sources\install.wim --> + <MetaData wcm:action="add"> + <Key>/IMAGE/INDEX </Key> + <Value>3</Value> + </MetaData> + </InstallFrom> + <InstallTo> + <DiskID>0</DiskID> + <PartitionID>2</PartitionID> + </InstallTo> + <WillShowUI>OnError</WillShowUI> + <InstallToAvailablePartition>false</InstallToAvailablePartition> + </OSImage> + </ImageInstall> + <UserData> + <AcceptEula>true</AcceptEula> + <ProductKey> + <WillShowUI>Never</WillShowUI> + <!-- Do not uncomment the Key element if you are using trial ISOs --> + <!-- You must uncomment the Key element (and optionally insert your own key) if you are using retail or volume license ISOs --> + <!-- <Key>11111-22222-33333-44444-55555</Key> --> + </ProductKey> + </UserData> + </component> + </settings> + <settings pass="specialize"> + <component name="Microsoft-Windows-International-Core" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" + xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <!-- https://docs.microsoft.com/en-us/windows-hardware/customize/desktop/unattend/microsoft-windows-international-core --> + <InputLocale>en-US</InputLocale> + <SystemLocale>en-US</SystemLocale> + <UILanguage>en-US</UILanguage> + <UILanguageFallback>en-US</UILanguageFallback> + <UserLocale>en-US</UserLocale> + </component> + <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" + xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <!-- https://docs.microsoft.com/en-us/windows-hardware/customize/desktop/unattend/microsoft-windows-shell-setup --> + <ComputerName>minikube-ws22</ComputerName> + <TimeZone>Central Standard Time</TimeZone> + <CopyProfile>true</CopyProfile> + </component> + <component name="Microsoft-Windows-Security-SPP-UX" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" + xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <!-- https://docs.microsoft.com/en-us/windows-hardware/customize/desktop/unattend/microsoft-windows-security-spp-ux --> + <SkipAutoActivation>true</SkipAutoActivation> + </component> + </settings> + <settings pass="oobeSystem"> + <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" + xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <!-- https://docs.microsoft.com/en-us/windows-hardware/customize/desktop/unattend/microsoft-windows-shell-setup --> + <AutoLogon> + <Password> + <Value>Minikube@2024</Value> + <PlainText>true</PlainText> + </Password> + <Username>Administrator</Username> + <Enabled>true</Enabled> + </AutoLogon> + <FirstLogonCommands> + <SynchronousCommand wcm:action="add"> + <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -Command New-SelfSignedCertificate -CertstoreLocation Cert:\LocalMachine\My -DnsName "WinRMCertificate"</CommandLine> + <Description>Certificate for WinRM</Description> + <Order>1</Order> + <RequiresUserInput>true</RequiresUserInput> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -Command Enable-PSRemoting -SkipNetworkProfileCheck -Force</CommandLine> + <Description>Enable WinRM</Description> + <Order>2</Order> + <RequiresUserInput>true</RequiresUserInput> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -Command ($cert = gci Cert:\LocalMachine\My\) -and (New-Item -Path WSMan:\LocalHost\Listener -Transport HTTPS -Address * -CertificateThumbPrint $cert.Thumbprint –Force)</CommandLine> + <Description>Add HTTPS WinRM listener with previously generated certificate</Description> + <Order>3</Order> + <RequiresUserInput>true</RequiresUserInput> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -Command New-NetFirewallRule -DisplayName 'Windows Remote Management (HTTPS-In)' -Name 'Windows Remote Management (HTTPS-In)' -Profile Any -LocalPort 5986 -Protocol TCP</CommandLine> + <Description>Add firewall exception to TCP port 5986 for WinRM over HTTPS</Description> + <Order>4</Order> + <RequiresUserInput>true</RequiresUserInput> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -Command Set-Item WSMan:\localhost\Service\Auth\Basic -Value $true</CommandLine> + <Description>Enable Basic authentication</Description> + <Order>5</Order> + <RequiresUserInput>true</RequiresUserInput> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -Command Stop-Service WinRM</CommandLine> + <Description>Stop the WinRM service to allow the dism process to finish before packer executes scripts</Description> + <Order>6</Order> + <RequiresUserInput>true</RequiresUserInput> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -Command Install-WindowsFeature -Name containers</CommandLine> + <Order>7</Order> + <Description>Installs Containers feature</Description> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -Command Set-SConfig -AutoLaunch $false</CommandLine> + <Order>8</Order> + <Description>Turns off Server Configuration tool (SConfig)</Description> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -Command "Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0"</CommandLine> + <Description>Install OpenSSH Server</Description> + <Order>9</Order> + </SynchronousCommand> + + <SynchronousCommand wcm:action="add"> + <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -Command Restart-Computer -Force</CommandLine> + <Order>10</Order> + <Description>Restart computer to apply changes</Description> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> - <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -Command Restart-Computer -Force</CommandLine> - <Order>13</Order> - <Description>Restart computer to apply changes</Description> - </SynchronousCommand> - </FirstLogonCommands> - <UserAccounts> - <AdministratorPassword> - <Value>Minikube@2024</Value> - <PlainText>true</PlainText> - </AdministratorPassword> - </UserAccounts> - </component> - </settings> - <cpi:offlineImage cpi:source="wim:c:/wims/install.wim#Windows Server 2022 SERVERDATACENTER" xmlns:cpi="urn:schemas-microsoft-com:cpi" /> -</unattend> \ No newline at end of file + <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -Command "Start-Service sshd"</CommandLine> + <Description>Start SSH Service</Description> + <Order>11</Order> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -Command "Set-Service -Name sshd -StartupType 'Automatic'"</CommandLine> + <Description>Set SSH Service to Automatic</Description> + <Order>12</Order> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -Command "New-NetFirewallRule -Name 'OpenSSH-Server-In-TCP' -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22"</CommandLine> + <Description>Create Firewall Rule for OpenSSH-Server-In-TCP</Description> + <Order>13</Order> + </SynchronousCommand> + + </FirstLogonCommands> + <UserAccounts> + <AdministratorPassword> + <Value>Minikube@2024</Value> + <PlainText>true</PlainText> + </AdministratorPassword> + </UserAccounts> + </component> + </settings> + <cpi:offlineImage cpi:source="wim:c:/wims/install.wim#Windows Server 2022 SERVERDATACENTER" + xmlns:cpi="urn:schemas-microsoft-com:cpi" /> + </unattend> \ No newline at end of file From 8398aefcd836a20b9fdae913e8e4acd4675e9956 Mon Sep 17 00:00:00 2001 From: Bob Sira <sbobfitz2@gmail.com> Date: Mon, 30 Sep 2024 23:47:23 +0100 Subject: [PATCH 52/52] OpenSSH installation in the VM --- auto-install.iso | Bin 73728 -> 73728 bytes automation/autounattend.xml | 34 +++++++++++++++++++++------------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/auto-install.iso b/auto-install.iso index 0128b38e897e5c6f5104809396d16c68d49a7362..87e8b75f5c296a4c7006d5948062e209e22bdd5e 100644 GIT binary patch delta 377 zcmZoTz|wGlWrN=XJ|`^(AkcEE;gl0sW!oI{;1fHV*y5NM8q-e-F}6+D5Ms2N-X_S% zH~k(Tkf;}8j0soN)m2bP%P&$W&d*I%C{N8SN>M0EO)SpOQz*&EELO<R%c)c-PEE~K zD9KkS&o9bW$V^l4RLDpyOI64$QAkWHNi71ZOa*ExE=epZQAo-x(bcsBS-5QaHvvW+ zLFb&z)Vz{9ATZD~&@<FCn7*EkQBle>52!vT2dvk>AT=*I*h2xLbh-i$qco?XfsMX@ zQA%pj^oOjBQ>Xh2Gb(`0vjywsM$$b!Mvzf!`UPP|Rj{Q(!60Yo2B#L4WhSR86c=Zt zOy4iUs5E`4Fr&_N2~ozq)B8mj^+95h(;tg5s!X52!&nJ1|C%V{La_PMXNoa;ahM>v MKxR9eIHMjr0P|{h<NyEw delta 254 zcmZoTz|wGlWrN=XzA_C4AkZkQ;S?8Q<l7wc;1fHV*y5NM8q+86Fjh`i5M@+gRGL0f zh*4)cp9rHMkPRe6r{}OT@=SLSVdR+ZBf_XTT}F_RZ~8h>MycujJd91#UkNZ8F&P?6 zzsScZJ>5c(F=l$60AmT*FcGETlEk7C-Qd)svdrXEh2r9j6l61tMHzLcmx(Z{px7TP x#;A{C^;$7Ti|GqQ8TSH37l|`2M3Us4o+`oUIsK^^qssQn5{$a+8wJiV0sxooL4W`N diff --git a/automation/autounattend.xml b/automation/autounattend.xml index a6a67d7..67acd53 100644 --- a/automation/autounattend.xml +++ b/automation/autounattend.xml @@ -164,34 +164,42 @@ <Order>8</Order> <Description>Turns off Server Configuration tool (SConfig)</Description> </SynchronousCommand> - <SynchronousCommand wcm:action="add"> - <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -Command "Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0"</CommandLine> - <Description>Install OpenSSH Server</Description> + + <SynchronousCommand wcm:action="add"> + <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -Command Restart-Computer -Force</CommandLine> <Order>9</Order> + <Description>Restart computer to apply changes</Description> </SynchronousCommand> - - <SynchronousCommand wcm:action="add"> - <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -Command Restart-Computer -Force</CommandLine> + + <!-- for some weird reason this only seem to work if I have it after the restart bit--> + <SynchronousCommand wcm:action="add"> + <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -Command Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0</CommandLine> + <Description>Install the OpenSSH Client</Description> <Order>10</Order> - <Description>Restart computer to apply changes</Description> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -Command Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0</CommandLine> + <Description>Install the OpenSSH Server</Description> + <Order>11</Order> </SynchronousCommand> <SynchronousCommand wcm:action="add"> - <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -Command "Start-Service sshd"</CommandLine> + <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -Command Start-Service sshd</CommandLine> <Description>Start SSH Service</Description> - <Order>11</Order> + <Order>12</Order> </SynchronousCommand> <SynchronousCommand wcm:action="add"> - <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -Command "Set-Service -Name sshd -StartupType 'Automatic'"</CommandLine> + <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -Command Set-Service -Name sshd -StartupType 'Automatic'</CommandLine> <Description>Set SSH Service to Automatic</Description> - <Order>12</Order> + <Order>13</Order> </SynchronousCommand> <SynchronousCommand wcm:action="add"> - <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -Command "New-NetFirewallRule -Name 'OpenSSH-Server-In-TCP' -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22"</CommandLine> + <CommandLine>%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -Command New-NetFirewallRule -Name 'OpenSSH-Server-In-TCP' -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22</CommandLine> <Description>Create Firewall Rule for OpenSSH-Server-In-TCP</Description> - <Order>13</Order> + <Order>14</Order> </SynchronousCommand> + </FirstLogonCommands> <UserAccounts> <AdministratorPassword>