Skip to content

Commit 9a82639

Browse files
authored
Merge pull request #35728 from codyhoag/winc-vsphere-template-updates
OSDOCS-2447 WINC vsphere golden image updates
2 parents a7858a0 + adadd91 commit 9a82639

File tree

4 files changed

+74
-67
lines changed

4 files changed

+74
-67
lines changed

modules/creating-the-vsphere-windows-vm-golden-image.adoc

Lines changed: 63 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -9,81 +9,90 @@ Create a vSphere Windows virtual machine (VM) golden image.
99

1010
.Prerequisites
1111

12-
* You have installed a cluster on vSphere configured with hybrid networking using OVN-Kubernetes.
13-
* You have defined a custom VXLAN port in your hybrid networking configuration to work around the link:https://docs.microsoft.com/en-us/virtualization/windowscontainers/kubernetes/common-problems#pod-to-pod-connectivity-between-hosts-is-broken-on-my-kubernetes-cluster-running-on-vsphere[pod-to-pod connectivity issue between hosts].
12+
* You have created a private/public key pair, which is used to configure key-based authentication in the OpenSSH server. The private key must also be configured in the Windows Machine Config Operator (WMCO) namespace. This is required to allow the WMCO to communicate with the Windows VM. See the "Configuring a secret for the Windows Machine Config Operator" section for more details.
1413

15-
.Procedure
16-
17-
. Create the VM from an updated version of the Windows Server 1909 VM image that includes the link:https://support.microsoft.com/en-us/help/4565351/windows-10-update-kb4565351[Microsoft patch KB4565351]. This patch is required to set the VXLAN UDP port, which is required for clusters installed on vSphere. This patch is not available for the `Windows Server 2019` VM image.
14+
[NOTE]
15+
====
16+
You must use link:https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell[Microsoft PowerShell] commands in several cases when creating your Windows VM. PowerShell commands in this guide are distinguished by the `PS C:\>` prefix.
17+
====
1818

19-
. Create the `C:\Users\Administrator\.ssh\authorized_keys` file in the Windows VM containing the public key that corresponds to the private key that resides in the secret you created in the `openshift-windows-machine-config-operator` namespace. The private key of the secret was created when first installing the Windows Machine Config Operator (WMCO) to give {product-title} access to Windows VMs. The `authorized_keys` file is used to configure SSH in the Windows VM.
19+
.Procedure
2020

21-
. Configure SSH on the Windows VM by running the following Powershell script:
22-
+
23-
[source,posh]
24-
----
25-
# Powershell script to configure SSH on vSphere Windows VMs
26-
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
27-
$firewallRuleName = "ContainerLogsPort"
28-
$containerLogsPort = "10250"
29-
New-NetFirewallRule -DisplayName $firewallRuleName -Direction Inbound -Action Allow -Protocol TCP -LocalPort $containerLogsPort -EdgeTraversalPolicy Allow
30-
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
31-
Install-Module -Force OpenSSHUtils
32-
Set-Service -Name ssh-agent -StartupType 'Automatic'
33-
Set-Service -Name sshd -StartupType 'Automatic'
34-
Start-Service ssh-agent
35-
Start-Service sshd
36-
$pubKeyConf = (Get-Content -path C:\ProgramData\ssh\sshd_config) -replace '#PubkeyAuthentication yes','PubkeyAuthentication yes'
37-
$pubKeyConf | Set-Content -Path C:\ProgramData\ssh\sshd_config
38-
$passwordConf = (Get-Content -path C:\ProgramData\ssh\sshd_config) -replace '#PasswordAuthentication yes','PasswordAuthentication yes'
39-
$passwordConf | Set-Content -Path C:\ProgramData\ssh\sshd_config
40-
$authFileConf = (Get-Content -path C:\ProgramData\ssh\sshd_config) -replace 'AuthorizedKeysFile __PROGRAMDATA__/ssh/administrators_authorized_keys','#AuthorizedKeysFile __PROGRAMDATA__/ssh/administrators_authorized_keys'
41-
$authFileConf | Set-Content -Path C:\ProgramData\ssh\sshd_config
42-
$pubKeyLocationConf = (Get-Content -path C:\ProgramData\ssh\sshd_config) -replace 'Match Group administrators','#Match Group administrators'
43-
$pubKeyLocationConf | Set-Content -Path C:\ProgramData\ssh\sshd_config
44-
Restart-Service sshd
45-
New-item -Path $env:USERPROFILE -Name .ssh -ItemType Directory -force
46-
----
21+
. Create a new VM in the vSphere client using the Windows Server Semi-Annual Channel (SAC): Windows Server 2004 ISO image that includes the link:https://support.microsoft.com/en-us/help/4565351/windows-10-update-kb4565351[Microsoft patch KB4565351]. This patch is required to set the VXLAN UDP port, which is required for clusters installed on vSphere. See the link:https://docs.vmware.com/en/VMware-vSphere/7.0/com.vmware.vsphere.hostclient.doc/GUID-FBEED81C-F9D9-4193-BDCC-CC4A60C20A4E.html[VMware documentation] for more information.
4722

4823
. Install and configure VMware Tools version 11.0.6 or greater on the Windows VM. See the link:https://docs.vmware.com/en/VMware-Tools/index.html[VMware Tools documentation] for more information.
4924

5025
. After installing VMware Tools on the Windows VM, verify the following:
51-
.. The `C:\ProgramData\VMware\VMware Tools\tools.conf` file has the following entry:
26+
27+
.. The `C:\ProgramData\VMware\VMware Tools\tools.conf` file exists with the following entry:
5228
+
5329
[source,ini]
5430
----
5531
exclude-nics=
5632
----
5733
+
58-
This entry ensures the following:
34+
If the `tools.conf` file does not exist, create it with the `exclude-nics` option uncommented and set as an empty value.
35+
+
36+
This entry ensures the cloned vNIC generated on the Windows VM by the hybrid-overlay is not ignored.
37+
38+
.. The Windows VM has a valid IP address in vCenter:
39+
+
40+
[source,terminal]
41+
----
42+
C:\> ipconfig
43+
----
44+
45+
.. The VMTools Windows service is running:
46+
+
47+
[source,posh]
48+
----
49+
PS C:\> Get-Service -Name VMTools | Select Status, StartType
50+
----
51+
52+
. Install and configure the OpenSSH Server on the Windows VM. See Microsoft's documentation on link:https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse[installing OpenSSH] for more details.
53+
54+
. Set up SSH access for an administrative user. See Microsoft's documentation on the link:https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_keymanagement#administrative-user[Administrative user] to do this.
5955
+
60-
* The cloned vNIC generated on the Windows VM by the hybrid-overlay is not ignored.
61-
* The VM has an IP address in vCenter.
56+
[IMPORTANT]
57+
====
58+
The public key used in the instructions must correspond to the private key you create later in the WMCO namespace that holds your secret. See the "Configuring a secret for the Windows Machine Config Operator" section for more details.
59+
====
6260

63-
.. The VMTools Windows service is running.
61+
. Install the `docker` container runtime on your Windows VM following the link:https://docs.microsoft.com/en-us/virtualization/windowscontainers/quick-start/set-up-environment?tabs=Windows-Server[Microsoft documentation].
62+
63+
. You must create a new firewall rule in the Windows VM that allows incoming connections for container logs. Run the following PowerShell command to create the firewall rule on TCP port 10250:
64+
+
65+
[source,posh]
66+
----
67+
PS C:\> New-NetFirewallRule -DisplayName "ContainerLogsPort" -LocalPort 10250 -Enabled True -Direction Inbound -Protocol TCP -Action Allow -EdgeTraversalPolicy Allow
68+
----
6469

65-
. Pull all of the required Windows container base images needed for your applications. The images you pull
66-
are dependent on the Windows kernel you are using. See Microsoft's documentation on link:https://docs.microsoft.com/en-us/virtualization/windowscontainers/manage-containers/container-base-images[pulling Windows container base images] for more information.
70+
. Clone the Windows VM so it is a reusable image. Follow the VMware documentation on how to link:https://docs.vmware.com/en/VMware-vSphere/7.0/com.vmware.vsphere.vm_admin.doc/GUID-1E185A80-0B97-4B46-A32B-3EF8F309BEED.html[clone an existing virtual machine] for more details.
6771

68-
. Run the link:+++https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/sysprep--generalize--a-windows-installation+++[Windows Sysprep tool] on the Windows VM:
72+
. In the cloned Windows VM, run the link:+++https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/sysprep--generalize--a-windows-installation+++[Windows Sysprep tool]:
6973
+
7074
[source,terminal]
7175
----
72-
C:\> sysprep.exe /generalize /oobe /shutdown /unattend:<path_to_unattend.xml>
76+
C:\> C:\Windows\System32\Sysprep\sysprep.exe /generalize /oobe /shutdown /unattend:<path_to_unattend.xml> <1>
7377
----
78+
<1> Specify the path to your `unattend.xml` file.
7479
+
75-
An example `unattend.xml` is provided, which maintains all the changes needed for the WMCO. For example, the `unattend.xml` file must ensure the Administrator's home directory stays intact with the SSH public key. You must customize the example to fit your needs.
80+
[NOTE]
81+
====
82+
There is a limit on how many times you can run the `sysprep` command on a Windows image. Consult Microsoft's link:+++https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/sysprep--generalize--a-windows-installation#limits-on-how-many-times-you-can-run-sysprep+++[documentation] for more information.
83+
====
84+
+
85+
An example `unattend.xml` is provided, which maintains all the changes needed for the WMCO. You must modify this example; it cannot be used directly.
7686
+
7787
.Example `unattend.xml`
7888
[%collapsible]
7989
====
8090
[source,xml]
8191
----
8292
<?xml version="1.0" encoding="UTF-8"?>
83-
<!--A sample unattend.xml which helps in setting admin password and running scripts on first boot-->
8493
<unattend xmlns="urn:schemas-microsoft-com:unattend">
8594
<settings pass="specialize">
86-
<component xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http:// www.w3.org/2001/XMLSchema-instance" name="Microsoft-Windows-International-Core" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
95+
<component xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Microsoft-Windows-International-Core" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
8796
<InputLocale>0409:00000409</InputLocale>
8897
<SystemLocale>en-US</SystemLocale>
8998
<UILanguage>en-US</UILanguage>
@@ -97,19 +106,13 @@ An example `unattend.xml` is provided, which maintains all the changes needed fo
97106
<CEIPEnabled>0</CEIPEnabled>
98107
</component>
99108
<component xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
100-
<ComputerName>windows-host</ComputerName>
101-
<ProductKey>My_Product_key</ProductKey>
109+
<ComputerName>winhost</ComputerName> <1>
102110
</component>
103111
</settings>
104112
<settings pass="oobeSystem">
105113
<component xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
106114
<AutoLogon>
107-
<Password>
108-
<Value>MyPassword</Value>
109-
<PlainText>true</PlainText>
110-
</Password>
111-
<Enabled>true</Enabled>
112-
<Username>Administrator</Username>
115+
<Enabled>false</Enabled> <2>
113116
</AutoLogon>
114117
<OOBE>
115118
<HideEULAPage>true</HideEULAPage>
@@ -128,20 +131,19 @@ An example `unattend.xml` is provided, which maintains all the changes needed fo
128131
<TimeZone>Eastern Standard Time</TimeZone>
129132
<UserAccounts>
130133
<AdministratorPassword>
131-
<Value>MyPassword</Value>
134+
<Value>MyPassword</Value> <3>
132135
<PlainText>true</PlainText>
133136
</AdministratorPassword>
134-
<LocalAccounts>
135-
<LocalAccount wcm:action="add">
136-
<Description>Administrator</Description>
137-
<DisplayName>Administrator</DisplayName>
138-
<Group>Administrators</Group>
139-
<Name>Administrator</Name>
140-
</LocalAccount>
141-
</LocalAccounts>
142137
</UserAccounts>
143138
</component>
144139
</settings>
145140
</unattend>
146141
----
142+
<1> Specify the `ComputerName`, which must follow the link:https://kubernetes.io/docs/concepts/overview/working-with-objects/names[Kubernetes' names specification]. These specifications also apply to Guest OS customization performed on the resulting template while creating new VMs.
143+
<2> Disable the automatic logon to avoid the security issue of leaving an open terminal with Administrator privileges at boot. This is the default value and must not be changed.
144+
<3> Replace the `MyPassword` placeholder with the password for the Administrator account. This prevents the built-in Administrator account from having a blank password by default. Follow Microsoft's link:https://docs.microsoft.com/en-us/windows/security/threat-protection/security-policy-settings/password-must-meet-complexity-requirements[best practices for choosing a password].
147145
====
146+
+
147+
After the Sysprep tool has completed, the Windows VM will power off. You must not use or power on this VM anymore.
148+
149+
. Convert the Windows VM to link:https://docs.vmware.com/en/VMware-vSphere/7.0/com.vmware.vsphere.vm_admin.doc/GUID-5B3737CC-28DB-4334-BD18-6E12011CDC9F.html[a template in vCenter].

modules/machineset-yaml-vsphere.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ $ oc get -o jsonpath='{.status.infrastructureName}{"\n"}' infrastructure cluster
130130
ifndef::infra[]
131131
<2> Specify the infrastructure ID and node label.
132132
<3> Specify the node label to add.
133-
<4> Specify the vSphere VM network to deploy the machine set to.
133+
<4> Specify the vSphere VM network to deploy the machine set to. This VM network must be where other compute machines reside in the cluster.
134134
<5> Specify the vSphere VM clone of the template to use, such as `user-5ddjd-rhcos`.
135135
+
136136
[IMPORTANT]
@@ -149,7 +149,7 @@ ifdef::infra[]
149149
<2> Specify the infrastructure ID and `<infra>` node label.
150150
<3> Specify the `<infra>` node label.
151151
<4> Specify a taint to prevent user workloads from being scheduled on infra nodes.
152-
<5> Specify the vSphere VM network to deploy the machine set to.
152+
<5> Specify the vSphere VM network to deploy the machine set to. This VM network must be where other compute machines reside in the cluster.
153153
<6> Specify the vSphere VM template to use, such as `user-5ddjd-rhcos`.
154154
<7> Specify the vCenter Datacenter to deploy the machine set on.
155155
<8> Specify the vCenter Datastore to deploy the machine set on.

modules/windows-machineset-vsphere.adoc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,12 @@ $ oc get -o jsonpath='{.status.infrastructureName}{"\n"}' infrastructure cluster
6767
<2> Specify the Windows machine set name. The machine set name cannot be more than 9 characters long, due to the way machine names are generated in vSphere.
6868
<3> Configure the machine set as a Windows machine.
6969
<4> Configure the Windows node as a compute machine.
70-
<5> Specify the vSphere VM network to deploy the machine set to.
71-
<6> Specify the full path of the Windows vSphere VM template to use, such as `/Datacenter/vm/ocp4-llplx/windows-golden-image`. The name must be unique.
70+
<5> Specify the vSphere VM network to deploy the machine set to. This VM network must be where other Linux compute machines reside in the cluster.
71+
<6> Specify the full path of the Windows vSphere VM template to use, such as `golden-images/windows-server-template`. The name must be unique.
7272
+
7373
[IMPORTANT]
7474
====
75-
Do not specify the original VM template. The VM template must remain off and must be cloned for new {op-system} machines. Starting the VM template configures the VM template as a VM on the platform, which prevents it from being used as a template that machine sets can apply configurations to.
76-
//This admonition note also appears in `modules/installation-vsphere-machines.adoc`.
75+
Do not specify the original VM template. The VM template must remain off and must be cloned for new Windows machines. Starting the VM template configures the VM template as a VM on the platform, which prevents it from being used as a template that machine sets can apply configurations to.
7776
====
7877
+
7978
<7> The `windows-user-data` is created by the WMCO when the first Windows machine is configured. After that, the `windows-user-data` is available for all subsequent machine sets to consume.

windows_containers/creating_windows_machinesets/creating-windows-machineset-vsphere.adoc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ include::modules/machine-api-overview.adoc[leveloffset=+1]
2626
You must prepare your vSphere environment for Windows container workloads by creating the vSphere Windows VM golden image and enabling communication with the internal API server for the WMCO.
2727

2828
include::modules/creating-the-vsphere-windows-vm-golden-image.adoc[leveloffset=+2]
29+
30+
[id="additional-resources_creating-windows-machineset-vsphere"]
31+
==== Additional resources
32+
33+
* xref:../../windows_containers/enabling-windows-container-workloads.adoc#configuring-secret-for-wmco_enabling-windows-container-workloads[Configuring a secret for the Windows Machine Config Operator]
34+
2935
include::modules/enabling-internal-api-server-vsphere.adoc[leveloffset=+2]
3036

3137
include::modules/windows-machineset-vsphere.adoc[leveloffset=+1]

0 commit comments

Comments
 (0)