Minikube: hyperv: Default to disabling dynamic memory (--hyperv-disable-dynamic-memory to driver)

Created on 28 Jul 2017  路  17Comments  路  Source: kubernetes/minikube

Is this a BUG REPORT or FEATURE REQUEST?
Feature Request

Minikube version v0.20.0

Environment:

  • OS Windows 10
  • VM Driver Hyper-V

Couple of issues already point out to problem with Hyper-V and dynamic memory:
1252 & 1762

Would it not be better to start the Hyper-V machine with dynamic memory turned off? Currently this switch in not given in to Powershell configuration, but it would be a simple thing to do:
-DynamicMemoryEnabled $true --- check here: https://technet.microsoft.com/en-us/itpro/powershell/windows/hyper-v/set-vmmemory

I would be happy to send a pull request for this.

chyperv good first issue help wanted kinfeature lifecyclfrozen prioritimportant-soon 2019q2

Most helpful comment

I am not sure I consider this as a feature and more of a bug fix. You cannot currently use Hyper-V without disabling Dynamic Memory. That seems like a bug to me.

That being said the Docker-For-Windows Hyper-V VM disables Dynamic Memory when it is booted. Seems that minikube should follow suit and do the same thing

All 17 comments

@DenisBiondic Having dynamic memory turned off or at least making it configurable would definitely help resolve some issues we are seeing with the Hyper-V driver. That would be great if you could send PR for this, thanks!

@aaron-prindle will try to do it in the next few days

The problem I was that the default setting for dynamic memory is the uncapped maximum amount. Over a couple days Hyper-V would suck up 20GB+ of RAM in to 'Driver Locker' even though the minicube was only using less than 2MB. Setting a sensible max amount for dynamic memory fixed that for me. (Windows 10 version 1703). I guess turning it off is the alternative fix!

@aaron-prindle could you give me some pointers for where the relevant code for configuring powershell flags for Hyper V is? I never did anything in Go, I will try to go through some tutorials in the meantime to try to understand the structure better...

@DenisBiondic While the VM is stopped (or before it's started you can use the following PowerShell command to set the dynamic memory flag.

$VM | Set-VMMemory -DynamicMemoryEnabled $false

or

Set-VMMemory -VMName 'minikube' -DynamicMemoryEnabled $false

https://docs.microsoft.com/en-us/powershell/module/hyper-v/set-vmmemory?view=win10-ps

I am not sure I consider this as a feature and more of a bug fix. You cannot currently use Hyper-V without disabling Dynamic Memory. That seems like a bug to me.

That being said the Docker-For-Windows Hyper-V VM disables Dynamic Memory when it is booted. Seems that minikube should follow suit and do the same thing

Agreed on this - Bumping for now!

Hello everyone,
I've been bitten by this so many times (mostly just before a demo) that I decided to take a look at this.

I'm not very experienced in Go but I think I've implemented the changes, however rather embarrassingly not sure how to build this on a Windows machine.
Any pointers ?

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

/remove-lifecycle stale

I think this is wrongly labeled as a feature request. I think it bug and AFAIK not fixed?

The required changes were made to upstream Docker Machine but not yet wired up to Minikube, there has been some questions around what the team want to do with the docker machine dependency otherwise I'm ready to implement

I disabled DynamicMemory with this change:

diff --git a/pkg/minikube/drivers/hyperv/driver.go b/pkg/minikube/drivers/hyperv/driver.go
index 2323b6383..7b2843a0e 100644
--- a/pkg/minikube/drivers/hyperv/driver.go
+++ b/pkg/minikube/drivers/hyperv/driver.go
@@ -45,6 +45,7 @@ func createHypervHost(config cfg.MachineConfig) interface{} {
    d.MemSize = config.Memory
    d.CPU = config.CPUs
    d.DiskSize = int(config.DiskSize)
+   d.DisableDynamicMemory = true
    d.SSHUser = "docker"

    return d

Then I recompiled with this (using Git Bash on Windows)

MSYS_NO_PATHCONV=1 docker run --rm -v "$(pwd)":/go/src/k8s.io/minikube -w /go/src/k8s.io/minikube golang:stretch make cross

Edit* For some reason, I would get this warning while building:

WARNING: You are building minikube outside the expected GOPATH

But if I start bash instead, then run the make command from inside, that doesn't happen:

$ MSYS_NO_PATHCONV=1 docker run -it --rm -v "$(pwd)":/go/src/k8s.io/minikube -w /go/src/k8s.io/minikube golang:stretch /bin/bash
root@d7305eb27c46:/go/src/k8s.io/minikube# make cross
GOPATH=/go ./makedepend.sh out/docker-machine-driver-kvm2 k8s.io ./cmd/drivers/kvm/  > out/docker-machine-driver-kvm2.d
...
out/minikube-windows-amd64 k8s.io/minikube/cmd/minikube
cp out/minikube-windows-amd64 out/minikube-windows-amd64.exe

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

/remove-lifecycle stale

I'd never heard of dynamic memory before, but read up a little on it:

https://blogs.technet.microsoft.com/virtualization/2015/05/26/when-to-use-hyper-v-dynamic-memory-versus-runtime-memory-resize/

I don't know much about HyperV, but I would definitely be happy to help someone implement this if they want to tackle it. It seems like the --hyperv-disable-dynamic-memory option is supported already by the hyperv driver:

https://docs.docker.com/machine/drivers/hyper-v/#4-create-the-nodes-with-docker-machine-and-the-microsoft-hyper-v-driver

Does someone mind taking this on?

specifically hammering Set-VMMemory -VMName 'minikube' -DynamicMemoryEnabled $false is what is needed while the minikube vm is creating, if you manage it before it starts, I get about 5 seconds that It can be run, it seems to go great.

This is now fixed at head, and will be part of the next minikube release.

Was this page helpful?
0 / 5 - 0 ratings