mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 20:53:33 +00:00
Merge pull request #105999 from mauriciopoppe/windows-hyperv
KubeEnv var to enable Hyper-V in GCE Windows nodes created with kube-up
This commit is contained in:
commit
324eff5b75
@ -560,6 +560,10 @@ export WINDOWS_ENABLE_DSR="${WINDOWS_ENABLE_DSR:-false}"
|
|||||||
export WINDOWS_ENABLE_NODE_PROBLEM_DETECTOR="${WINDOWS_ENABLE_NODE_PROBLEM_DETECTOR:-none}"
|
export WINDOWS_ENABLE_NODE_PROBLEM_DETECTOR="${WINDOWS_ENABLE_NODE_PROBLEM_DETECTOR:-none}"
|
||||||
export WINDOWS_NODE_PROBLEM_DETECTOR_CUSTOM_FLAGS="${WINDOWS_NODE_PROBLEM_DETECTOR_CUSTOM_FLAGS:-}"
|
export WINDOWS_NODE_PROBLEM_DETECTOR_CUSTOM_FLAGS="${WINDOWS_NODE_PROBLEM_DETECTOR_CUSTOM_FLAGS:-}"
|
||||||
|
|
||||||
|
# Enable Windows Hyper-V
|
||||||
|
# sig-storage uses it to create Virtual Hard Disks in tests
|
||||||
|
export WINDOWS_ENABLE_HYPERV="${WINDOWS_ENABLE_HYPERV:-false}"
|
||||||
|
|
||||||
# TLS_CIPHER_SUITES defines cipher suites allowed to be used by kube-apiserver.
|
# TLS_CIPHER_SUITES defines cipher suites allowed to be used by kube-apiserver.
|
||||||
# If this variable is unset or empty, kube-apiserver will allow its default set of cipher suites.
|
# If this variable is unset or empty, kube-apiserver will allow its default set of cipher suites.
|
||||||
export TLS_CIPHER_SUITES=""
|
export TLS_CIPHER_SUITES=""
|
||||||
|
@ -1602,6 +1602,7 @@ BOOTSTRAP_KUBECONFIG_FILE: $(yaml-quote "${WINDOWS_BOOTSTRAP_KUBECONFIG_FILE}")
|
|||||||
KUBEPROXY_KUBECONFIG_FILE: $(yaml-quote "${WINDOWS_KUBEPROXY_KUBECONFIG_FILE}")
|
KUBEPROXY_KUBECONFIG_FILE: $(yaml-quote "${WINDOWS_KUBEPROXY_KUBECONFIG_FILE}")
|
||||||
WINDOWS_INFRA_CONTAINER: $(yaml-quote "${WINDOWS_INFRA_CONTAINER}")
|
WINDOWS_INFRA_CONTAINER: $(yaml-quote "${WINDOWS_INFRA_CONTAINER}")
|
||||||
WINDOWS_ENABLE_PIGZ: $(yaml-quote "${WINDOWS_ENABLE_PIGZ}")
|
WINDOWS_ENABLE_PIGZ: $(yaml-quote "${WINDOWS_ENABLE_PIGZ}")
|
||||||
|
WINDOWS_ENABLE_HYPERV: $(yaml-quote "${WINDOWS_ENABLE_HYPERV}")
|
||||||
ENABLE_NODE_PROBLEM_DETECTOR: $(yaml-quote "${WINDOWS_ENABLE_NODE_PROBLEM_DETECTOR}")
|
ENABLE_NODE_PROBLEM_DETECTOR: $(yaml-quote "${WINDOWS_ENABLE_NODE_PROBLEM_DETECTOR}")
|
||||||
NODE_PROBLEM_DETECTOR_VERSION: $(yaml-quote "${NODE_PROBLEM_DETECTOR_VERSION}")
|
NODE_PROBLEM_DETECTOR_VERSION: $(yaml-quote "${NODE_PROBLEM_DETECTOR_VERSION}")
|
||||||
NODE_PROBLEM_DETECTOR_TAR_HASH: $(yaml-quote "${NODE_PROBLEM_DETECTOR_TAR_HASH}")
|
NODE_PROBLEM_DETECTOR_TAR_HASH: $(yaml-quote "${NODE_PROBLEM_DETECTOR_TAR_HASH}")
|
||||||
|
@ -118,17 +118,32 @@ try {
|
|||||||
|
|
||||||
Dump-DebugInfoToConsole
|
Dump-DebugInfoToConsole
|
||||||
|
|
||||||
|
$kube_env = Fetch-KubeEnv
|
||||||
|
Set-EnvironmentVars
|
||||||
|
|
||||||
|
# Set to true if there's a feature that needs a reboot
|
||||||
|
$restart_computer = $false
|
||||||
|
|
||||||
|
$should_enable_hyperv = Test-ShouldEnableHyperVFeature
|
||||||
|
$hyperv_feature_enabled = Test-HyperVFeatureEnabled
|
||||||
|
if ($should_enable_hyperv -and -not ($hyperv_feature_enabled)) {
|
||||||
|
Enable-HyperVFeature
|
||||||
|
Log-Output 'Restarting computer after enabling Windows Hyper-V feature'
|
||||||
|
$restart_computer = $true
|
||||||
|
}
|
||||||
|
|
||||||
if (-not (Test-ContainersFeatureInstalled)) {
|
if (-not (Test-ContainersFeatureInstalled)) {
|
||||||
Install-ContainersFeature
|
Install-ContainersFeature
|
||||||
Log-Output 'Restarting computer after enabling Windows Containers feature'
|
Log-Output 'Restarting computer after enabling Windows Containers feature'
|
||||||
|
$restart_computer = $true
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($restart_computer) {
|
||||||
Restart-Computer -Force
|
Restart-Computer -Force
|
||||||
# Restart-Computer does not stop the rest of the script from executing.
|
# Restart-Computer does not stop the rest of the script from executing.
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
$kube_env = Fetch-KubeEnv
|
|
||||||
Set-EnvironmentVars
|
|
||||||
|
|
||||||
# Set the TCP/IP Parameters to keep idle connections alive.
|
# Set the TCP/IP Parameters to keep idle connections alive.
|
||||||
Set-WindowsTCPParameters
|
Set-WindowsTCPParameters
|
||||||
|
|
||||||
|
@ -295,6 +295,7 @@ function Set-EnvironmentVars {
|
|||||||
"MANIFESTS_DIR" = ${kube_env}['MANIFESTS_DIR']
|
"MANIFESTS_DIR" = ${kube_env}['MANIFESTS_DIR']
|
||||||
"INFRA_CONTAINER" = ${kube_env}['WINDOWS_INFRA_CONTAINER']
|
"INFRA_CONTAINER" = ${kube_env}['WINDOWS_INFRA_CONTAINER']
|
||||||
"WINDOWS_ENABLE_PIGZ" = ${kube_env}['WINDOWS_ENABLE_PIGZ']
|
"WINDOWS_ENABLE_PIGZ" = ${kube_env}['WINDOWS_ENABLE_PIGZ']
|
||||||
|
"WINDOWS_ENABLE_HYPERV" = ${kube_env}['WINDOWS_ENABLE_HYPERV']
|
||||||
"ENABLE_NODE_PROBLEM_DETECTOR" = ${kube_env}['ENABLE_NODE_PROBLEM_DETECTOR']
|
"ENABLE_NODE_PROBLEM_DETECTOR" = ${kube_env}['ENABLE_NODE_PROBLEM_DETECTOR']
|
||||||
"NODEPROBLEMDETECTOR_KUBECONFIG_FILE" = ${kube_env}['WINDOWS_NODEPROBLEMDETECTOR_KUBECONFIG_FILE']
|
"NODEPROBLEMDETECTOR_KUBECONFIG_FILE" = ${kube_env}['WINDOWS_NODEPROBLEMDETECTOR_KUBECONFIG_FILE']
|
||||||
|
|
||||||
@ -1386,6 +1387,24 @@ function Install-ContainersFeature {
|
|||||||
Install-WindowsFeature Containers
|
Install-WindowsFeature Containers
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Verifies if Hyper-V should be enabled in the node
|
||||||
|
function Test-ShouldEnableHyperVFeature {
|
||||||
|
return "${env:WINDOWS_ENABLE_HYPERV}" -eq "true"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check if Hyper-V feature is enabled
|
||||||
|
function Test-HyperVFeatureEnabled {
|
||||||
|
return ((Get-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V).State -eq 'Enabled')
|
||||||
|
}
|
||||||
|
|
||||||
|
# After this function returns, the computer must be restarted to complete
|
||||||
|
# the installation!
|
||||||
|
function Enable-HyperVFeature {
|
||||||
|
Log-Output "Enabling Windows 'HyperV' feature"
|
||||||
|
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All -NoRestart
|
||||||
|
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-Management-PowerShell -All -NoRestart
|
||||||
|
}
|
||||||
|
|
||||||
function Test-DockerIsInstalled {
|
function Test-DockerIsInstalled {
|
||||||
return ((Get-Package `
|
return ((Get-Package `
|
||||||
-ProviderName DockerMsftProvider `
|
-ProviderName DockerMsftProvider `
|
||||||
|
Loading…
Reference in New Issue
Block a user