Prepare the Hyper-V cluster
Service account
Section titled “Service account”Create a domain account for the driver, e.g. EXAMPLE\k8s-hyperv-csi (password never expires, no
interactive logon needed). It needs, on every node and on the cluster, one of:
| Option | Rights | When |
|---|---|---|
| A. Local Administrators (simplest) | Member of the local Administrators group on every node. That covers Hyper-V, the cluster (BUILTIN\Administrators has Full cluster access) and the CSV folders |
Production installations of Bare Metal Works run this way |
| B. Least privilege | Member of Hyper-V Administrators on every node, Grant-ClusterAccess -User EXAMPLE\k8s-hyperv-csi -Full once on the cluster, Modify on the volume folders |
When local admin is not acceptable |
Volume folders
Section titled “Volume folders”Choose one folder per CSV for the VHDX files, e.g. C:\ClusterStorage\VStore1\k8s-volumes. The folder
name becomes PvcFolder in the WebApi settings. The driver never writes outside these folders.
Prepare every node
Section titled “Prepare every node”Copy Install-HypervCsiHost.ps1 and Test-HypervCsiHost.ps1 to each node and run them in an elevated PowerShell:
# installs OpenSSH Server, the pwsh 7 SSH subsystem, firewall rule, group membership, folder rights.\Install-HypervCsiHost.ps1 -ServiceAccount 'EXAMPLE\k8s-hyperv-csi' ` -VolumeFolder 'C:\ClusterStorage\VStore1\k8s-volumes' ` -PowerShellMsi 'https://github.com/PowerShell/PowerShell/releases/download/v7.5.4/PowerShell-7.5.4-win-x64.msi' ` -LocalAdministrators # omit for option B
# read-only check, prints PASS/FAIL per item, exit code 1 on failure.\Test-HypervCsiHost.ps1 -ServiceAccount 'EXAMPLE\k8s-hyperv-csi' -VolumeFolder 'C:\ClusterStorage\VStore1\k8s-volumes'What the install script configures, if you prefer to do it by hand:
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0, servicesshdAutomatic and running, inbound firewall rule TCP 22.- PowerShell 7 at
C:\Program Files\PowerShell\7(MSI). - In
C:\ProgramData\ssh\sshd_config:thenSubsystem powershell c:/progra~1/powershell/7/pwsh.exe -sshs -nologo -NoProfileRestart-Service sshd. For Kerberos alsoGSSAPIAuthentication yes. - The service account in
Hyper-V Administrators(orAdministrators). Modifyfor the service account on each volume folder.
For option B, additionally once per cluster: Grant-ClusterAccess -User EXAMPLE\k8s-hyperv-csi -Full.
Kerberos
Section titled “Kerberos”Strongly recommended. The cluster configuration refresh after a drive change runs on the Hyper-V node
with the service account’s credentials, which needs a Kerberos ticket on the node (a second hop). The
WebApi obtains a ticket from a keytab and the SSH client forwards it (GSSAPIDelegateCredentials yes).
Without Kerberos (RemotingMethod: SshKey) provisioning, attach and detach still work, but every drive
change logs Update-ClusterVirtualMachineConfiguration ... could not be completed and the cluster’s copy of
the VM configuration is not refreshed until the next refresh from another source. Do not run production
that way.
Create the keytab on a domain controller (sets the account password to the one you type):
ktpass /princ k8s-hyperv-csi@EXAMPLE.COM /mapuser EXAMPLE\k8s-hyperv-csi /pass * ^ /crypto AES256-SHA1 /ptype KRB5_NT_PRINCIPAL /out csi-service.keytabkrb5.conf for the WebApi (realm and KDCs of your domain; forwardable is required for delegation):
[libdefaults] default_realm = EXAMPLE.COM dns_lookup_kdc = true forwardable = true rdns = false[realms] EXAMPLE.COM = { kdc = dc-01.example.com kdc = dc-02.example.com }[domain_realm] .example.com = EXAMPLE.COMOn every node sshd_config needs GSSAPIAuthentication yes (the check script reports it), and the node’s
SPN host/<fqdn> must exist, which is the case for domain-joined servers.
Hyper-V side checklist
Section titled “Hyper-V side checklist”- Service account created, rights per option A or B
-
Test-HypervCsiHost.ps1passes on every node - Volume folder exists on every CSV you will use
- Keytab and
krb5.confready (Kerberos), or an SSH key pair whose public key is in the service account’sauthorized_keyson every node (SshKey) - From the WebApi host:
ssh k8s-hyperv-csi@hv-01.example.comworks andssh-keyscanoutput of all nodes is saved toknown_hosts