Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KubeEnv var to enable Hyper-V in GCE Windows nodes created with kube-up #105999

Merged
merged 1 commit into from Oct 29, 2021

Conversation

mauriciopoppe
Copy link
Member

@mauriciopoppe mauriciopoppe commented Oct 29, 2021

What type of PR is this?

/kind feature

What this PR does / why we need it:

We'd like to create VHDs as part of the E2E tests of Local Volume Provisioner (kubernetes-sigs/sig-storage-local-static-provisioner#277), VHDs require Hyper-V to be enabled, this PR adds a new KubeEnv flag to enable Hyper-V in GCE Windows VMs, the feature is opt-in and disabled by default.

Testing

I created a GCE cluster with the following env vars (in addition to the common ones):

export NODE_SIZE=e2-standard-2
export WINDOWS_ENABLE_HYPERV=true

Once the Windows VM was up I SSHd to it and verified that the command New-VHD is available, I could create a VHD with it:

PS C:\Users\mauriciopoppe> New-VHD -Path C:\var\lib\kubelet\plugins\testplugin-0.csi.io\disk-0.vhdx -SizeBytes 10485760
ComputerName            : E2E-TEST-MAURIC
Path                    : C:\var\lib\kubelet\plugins\testplugin-0.csi.io\disk-0.vhdx
VhdFormat               : VHDX
VhdType                 : Dynamic
FileSize                : 4194304
Size                    : 10485760
MinimumSize             :
LogicalSectorSize       : 512
PhysicalSectorSize      : 4096
BlockSize               : 33554432
ParentPath              :
DiskIdentifier          : <REDACTED>
FragmentationPercentage : 0
Alignment               : 1
Attached                : False
DiskNumber              :
IsPMEMCompatible        : False
AddressAbstractionType  : None
Number                  :

PS C:\Users\mauriciopoppe> Mount-VHD -Path C:\var\lib\kubelet\plugins\testplugin-0.csi.io\disk-0.vhdx

PS C:\Users\mauriciopoppe> Get-Disk

Number Friendly Name                                                           Serial Number                    HealthStatus         OperationalStatus      Total Size Partition
                                                                                                                                                                       Style
------ -------------                                                           -------------                    ------------         -----------------      ---------- ----------
0      Google PersistentDisk                                                                                    Healthy              Online                     100 GB GPT
1      Msft Virtual Disk                                                                                        Healthy              Online                      10 MB RAW

Installation logs:

2021/10/29 06:42:44 GCEMetadataScripts: windows-startup-script-ps1: Enabling Windows 'HyperV' feature
2021/10/29 06:42:45 GCEInstanceSetup: Activating Windows(R), ServerDatacenter edition (REDACTED) ...
2021/10/29 06:42:46 GCEInstanceSetup: Product activated successfully.
2021/10/29 06:42:48 GCEInstanceSetup: Activation successful.
2021/10/29 06:43:03 GCEMetadataScripts: windows-startup-script-ps1: WARNING: Restart is suppressed because NoRestart is specified.
2021/10/29 06:43:03 GCEMetadataScripts: windows-startup-script-ps1:
2021/10/29 06:43:03 GCEMetadataScripts: windows-startup-script-ps1:
2021/10/29 06:43:03 GCEMetadataScripts: windows-startup-script-ps1: Path          :
2021/10/29 06:43:03 GCEMetadataScripts: windows-startup-script-ps1: Online        : True
2021/10/29 06:43:03 GCEMetadataScripts: windows-startup-script-ps1: RestartNeeded : True
2021/10/29 06:43:03 GCEMetadataScripts: windows-startup-script-ps1:
2021/10/29 06:43:08 GCEMetadataScripts: windows-startup-script-ps1: WARNING: Restart is suppressed because NoRestart is specified.
2021/10/29 06:43:08 GCEMetadataScripts: windows-startup-script-ps1: Path          :
2021/10/29 06:43:08 GCEMetadataScripts: windows-startup-script-ps1: Online        : True
2021/10/29 06:43:08 GCEMetadataScripts: windows-startup-script-ps1: RestartNeeded : True
2021/10/29 06:43:08 GCEMetadataScripts: windows-startup-script-ps1:
2021/10/29 06:43:08 GCEMetadataScripts: windows-startup-script-ps1: Restarting computer after enabling Windows Hyper-V feature
2021/10/29 06:43:21 GCEMetadataScripts: windows-startup-script-ps1: Installing Windows 'Containers' feature
2021/10/29 06:43:46 GCEMetadataScripts: windows-startup-script-ps1:
2021/10/29 06:43:46 GCEMetadataScripts: windows-startup-script-ps1: Success       : True
2021/10/29 06:43:46 GCEMetadataScripts: windows-startup-script-ps1: RestartNeeded : Yes
2021/10/29 06:43:46 GCEMetadataScripts: windows-startup-script-ps1: FeatureResult : {Containers}
2021/10/29 06:43:46 GCEMetadataScripts: windows-startup-script-ps1: ExitCode      : SuccessRestartRequired
2021/10/29 06:43:46 GCEMetadataScripts: windows-startup-script-ps1:
2021/10/29 06:43:46 GCEMetadataScripts: windows-startup-script-ps1: WARNING: You must restart this server to finish the installation process.
2021/10/29 06:43:46 GCEMetadataScripts: windows-startup-script-ps1: Restarting computer after enabling Windows Containers feature
2021/10/29 06:43:46 GCEMetadataScripts: windows-startup-script-ps1 exit status 0

Which issue(s) this PR fixes:

Fixes #

Does this PR introduce a user-facing change?

Support to enable Hyper-V in GCE Windows Nodes created with kube-up

/cc @pjh @jingxu97

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/feature Categorizes issue or PR as related to a new feature. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Oct 29, 2021
@mauriciopoppe mauriciopoppe changed the title KubeEnv var to enable Hyper-V in Windows KubeEnv var to enable Hyper-V in GCE Windows nodes created with kube-up Oct 29, 2021
@k8s-ci-robot k8s-ci-robot added area/provider/gcp Issues or PRs related to gcp provider sig/cloud-provider Categorizes an issue or PR as relevant to SIG Cloud Provider. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Oct 29, 2021
@mauriciopoppe
Copy link
Member Author

/sig windows

@k8s-ci-robot k8s-ci-robot added the sig/windows Categorizes an issue or PR as relevant to SIG Windows. label Oct 29, 2021
@mauriciopoppe
Copy link
Member Author

/test pull-kubernetes-e2e-gce-ubuntu-containerd

@@ -118,17 +118,32 @@ try {

Dump-DebugInfoToConsole

$kube_env = Fetch-KubeEnv
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why moved this part up?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the first check to see if we have to install Hyper-V is to see the value of kube_env[WINDOWS_ENABLE_HYPERV], these lines fetch kubeEnv from the instance metadata

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why -NoRestart option here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could restart after enabling each feature but instead we could batch all of the installations that require a restart to do a restart after all of them completed, what I saw is:

Install Hyper-V (requires restart but it's deferred)
Install Hyper-V PowerShell tools
Install Container support (requires restart but it's deferred)
Restart Computer

@jingxu97
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 29, 2021
@pjh
Copy link
Contributor

pjh commented Oct 29, 2021

/triage accepted
/priority important-soon

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Oct 29, 2021
@pjh
Copy link
Contributor

pjh commented Oct 29, 2021

/lgtm
/approve

Thanks for the clean code and the detailed PR description.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mauriciopoppe, pjh

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 29, 2021
@k8s-ci-robot k8s-ci-robot merged commit 324eff5 into kubernetes:master Oct 29, 2021
@k8s-ci-robot k8s-ci-robot added this to the v1.23 milestone Oct 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/provider/gcp Issues or PRs related to gcp provider cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/cloud-provider Categorizes an issue or PR as relevant to SIG Cloud Provider. sig/windows Categorizes an issue or PR as relevant to SIG Windows. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants