Last active
March 19, 2023 21:15
-
-
Save knabben/2482cb672aeb3fbfe32d14fe3cbd70a0 to your computer and use it in GitHub Desktop.
Installer helper for Windows Kubernetes nodes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright (c) 2023 - Amim Knabben | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http:#www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
<# | |
.DESCRIPTION | |
The script enables and install tools used to manage a Windows node. | |
NOTE: Do not use in production. | |
#> | |
Param( | |
[parameter(Mandatory = $false)] $EnableAccess=$false, | |
[parameter(Mandatory = $false)] $SkipInstalls=$false | |
) | |
function CheckServices() { | |
Write-Host "Checking running services..." -ForegroundColor blue | |
Get-Service -name antrea-agent | |
Get-Service -name ovsdb-server | |
Get-Service -name ovs-vswitchd | |
Get-Service -name kubelet | |
Get-Service -name kube-proxy | |
} | |
function EnableAccess() { | |
Write-Host "Enabling RDP and resetting capv user password..." -ForegroundColor blue | |
# Enable Remote Desktop | |
Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' -name "fDenyTSConnections" -value 0 | |
Enable-NetFirewallRule -DisplayGroup "Remote Desktop" | |
# Reset Password | |
$Password = Read-Host "Enter the new CAPV user password" -AsSecureString | |
$UserAccount = Get-LocalUser -Name "capv" | Set-LocalUser -Password $Password | |
} | |
function InstallChocoPackages() { | |
Write-Host "Installing Choco and packages..." -ForegroundColor blue | |
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) | |
Write-Host "Installing vim..." -ForegroundColor blue | |
choco install --accept-licenses --yes vim | |
Write-Host "YOU NEED to install $PWD\winpcap.exe manually via RDP..." -ForegroundColor red | |
Invoke-WebRequest -URI https://www.winpcap.org/install/bin/WinPcap_4_1_3.exe -Out winpcap.exe | |
Write-Host "Installing Wireshark..." -ForegroundColor blue | |
choco install --accept-licenses --yes wireshark | |
Write-Host "Installing grep..." -ForegroundColor blue | |
choco install --accept-licenses --pre --yes grep | |
Write-Host "Installing nerdctl..." -ForegroundColor blue | |
Invoke-WebRequest -URI https://github.com/containerd/nerdctl/releases/download/v1.2.0/nerdctl-1.2.0-windows-amd64.tar.gz -Out nerdctl.tar.gz | |
tar xvf nerdctl.tar.gz | |
mv nerdctl.exe c:\k\ | |
} | |
function InstallDebugScripts() { | |
Write-Host "Running Debug scripts in the host..." -ForegroundColor blue | |
Invoke-WebRequest -URI https://raw.githubusercontent.com/microsoft/SDN/master/Kubernetes/windows/debug/collectlogs.ps1 -Out collectlogs.ps1 | |
.\collectlogs.ps1 | |
Get-WindowsFeature > c:\k\debug\enabled-features.txt | |
} | |
function CheckNTPServer() { | |
Write-Host "Checking time service..." -ForegroundColor blue | |
w32tm /query /source | |
} | |
function InstallSysInternals() { | |
Invoke-WebRequest -URI https://download.sysinternals.com/files/SysinternalsSuite.zip -Out SysinternalsSuite.zip | |
Expand-Archive -Path .\SysinternalsSuite.zip | |
} | |
# Enable access via RDP and password reset | |
if ([bool]$EnableAccess) { | |
EnableAccess | |
Write-Host "Use the following IP Address for RDP access..." -ForegroundColor blue | |
(Get-NetIPAddress -InterfaceAlias br-int -AddressFamily IPv4).IPAddress | |
} | |
if (![bool]$SkipInstalls) { | |
# Install Choco and packages | |
InstallChocoPackages | |
# Install SIG-Windows debug packages | |
InstallDebugScripts | |
} | |
# Check NTP Servers installed on system. | |
CheckNTPServer | |
# Check all services installed status | |
CheckServices | |
# Install sysinternals | |
InstallSysInternals |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment