Skip to content

Commit

Permalink
improvement(windows): check for Hyper-V and ask if user wants Docker
Browse files Browse the repository at this point in the history
Allows installation on machines without Hyper-V option, and avoids hard
requirement on Docker.
  • Loading branch information
edvald committed Jun 26, 2019
1 parent 1ebf457 commit 21024f8
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 9 deletions.
15 changes: 10 additions & 5 deletions docs/basics/installation.md
Expand Up @@ -49,7 +49,11 @@ To later upgrade to the newest version, simply run `brew update` and then `brew

### Windows

You can run Garden on Windows 10 Pro or Enterprise editions (the Home edition unfortunately does not work because it does not include support for virtualization).
You can run Garden on Windows 10 Home, Pro or Enterprise editions.

_Note: The Home edition doesn't support virtualization, but you can still use Garden if you're working with
[remote clusters](../using-garden/remote-clusters.md) and
[in-cluster building](../using-garden/in-cluster-building.md)._

To install the Garden CLI and its dependencies, please use our installation script. To run the script, open PowerShell as an administrator and run:

Expand All @@ -60,10 +64,11 @@ Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.We
The things the script will check for are the following:

* The [Chocolatey](https://chocolatey.org) package manager. The script installs it automatically if necessary.
* _git_, _rsync_ and _Docker for Windows_. The script will install or upgrade those via Chocolatey.
* Whether you have Hyper-V enabled. This is required for _Docker for Windows_. If you do not already have it enabled,
the script will enable it, but you will need to restart your computer before starting Docker for Windows.
* Whether you have Kubernetes enabled in your _Docker for Windows_ installation.
* _git_ and _rsync_ . The script will install or upgrade those via Chocolatey.
* Whether you have Hyper-V available and enabled. This is required for _Docker for Windows_. If it's available, the
installer will ask if you'd like to install _Docker for Windows_. If you do not already have it enabled,
the script will enable it, but you will need to restart your computer before starting Docker.
* If applicable, whether Kubernetes is enabled in your _Docker for Windows_ installation.

To later upgrade to the newest version, simply re-run the above script.

Expand Down
25 changes: 21 additions & 4 deletions support/install.ps1
Expand Up @@ -14,6 +14,15 @@
# For more information visit https://docs.garden.io/

Function CheckHyperV {
$hyperv = Get-WindowsOptionalFeature -FeatureName Microsoft-Hyper-V-All -Online
if($hyperv) {
return $true
} else {
return $false
}
}

Function EnableHyperV {
# if ((New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) -eq $false) {
# ContinueYN("To check whether Hyper-V is enabled (and enable it if necessary), please run as Administrator. If you choose to continue the Hyper-V check will be skipped.")
# return
Expand Down Expand Up @@ -102,9 +111,17 @@ choco upgrade -y git rsync docker-for-windows

[Console]::ResetColor()

# Check system configuration
CheckHyperV
CheckKubernetes
if (CheckHyperV) {
Write-Host "Hyper-V is available. Would you like to install Docker for Windows? (y/n)"
$response = Read-Host
if ( $response -eq "y" ) {
EnableHyperV
choco upgrade -y docker-for-windows
CheckKubernetes
}
} else {
Write-Host "Hyper-V is NOT available. Docker for Windows is not available on this machine." -ForegroundColor Yellow
}

# Install the garden binary
$homedir = Resolve-Path "~"
Expand Down Expand Up @@ -177,5 +194,5 @@ You can now run the garden command in your shell (you may need to restart your s
Please head over to https://docs.garden.io for more information on how to get started.
Note: Please see the logs above for any warnings. If Docker for Windows was just installed and/or
Hyper-V was just enabled, you may need to restart your computer before using Docker and Garden.
Hyper-V was just enabled, you may need to restart your computer before using Docker.
")

0 comments on commit 21024f8

Please sign in to comment.