Skip to content

Commit c64f5ff

Browse files
authored
Merge pull request #482 from z4ce/master
Add EFI Support for OVA creation
2 parents e3c1af1 + fdde351 commit c64f5ff

File tree

9 files changed

+174
-3
lines changed

9 files changed

+174
-3
lines changed

images/capi/Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ CENTOS_VERSIONS := centos-7
207207
FLATCAR_VERSIONS := flatcar
208208
PHOTON_VERSIONS := photon-3
209209
RHEL_VERSIONS := rhel-7
210-
UBUNTU_VERSIONS := ubuntu-1804 ubuntu-2004
210+
UBUNTU_VERSIONS := ubuntu-1804 ubuntu-2004 ubuntu-2004-efi
211211
WINDOWS_VERSIONS := windows-2019 windows-2004
212212

213213
# Set Flatcar Container Linux channel and version if not supplied
@@ -303,6 +303,7 @@ $(NODE_OVA_ESX_BUILD_TARGETS): deps-ova
303303
$(NODE_OVA_VSPHERE_BUILD_TARGETS): deps-ova
304304
packer build $(if $(findstring windows,$@),$(PACKER_WINDOWS_NODE_FLAGS),$(PACKER_NODE_FLAGS)) -var-file="packer/ova/packer-common.json" -var-file="$(abspath packer/ova/$(subst build-node-ova-vsphere-,,$@).json)" -var-file="packer/ova/vsphere.json" -except=esx -except=local -only=vsphere-iso $(ABSOLUTE_PACKER_VAR_FILES) -only=vsphere packer/ova/packer-$(if $(findstring windows,$@),windows,node).json
305305

306+
306307
.PHONY: $(NODE_OVA_VSPHERE_BASE_BUILD_TARGETS)
307308
$(NODE_OVA_VSPHERE_BASE_BUILD_TARGETS): deps-ova
308309
packer build $(PACKER_NODE_FLAGS) -var-file="packer/ova/packer-common.json" -var-file="$(abspath packer/ova/$(subst build-node-ova-vsphere-base-,,$@).json)" -var-file="packer/ova/vsphere.json" -except=esx -except=local -except=manifest -except=vsphere -only=vsphere-iso-base $(ABSOLUTE_PACKER_VAR_FILES) packer/ova/packer-node.json
@@ -487,7 +488,9 @@ build-node-ova-vsphere-ubuntu-1804: ## Builds Ubuntu 18.04 Node OVA and template
487488
build-node-ova-vsphere-ubuntu-2004: ## Builds Ubuntu 20.04 Node OVA and template on vSphere
488489
build-node-ova-vsphere-windows-2019: ## Builds for Windows Server 2019 and template on vSphere
489490
build-node-ova-vsphere-windows-2004: ## Builds for Windows Server 2004 SAC and template on vSphere
491+
build-node-ova-vsphere-ubuntu-2004-efi: ## Builds Ubuntu 20.04 Node OVA and template on vSphere that EFI boots
490492
build-node-ova-vsphere-all: $(NODE_OVA_VSPHERE_BUILD_TARGETS) ## Builds all Node OVAs and templates on vSphere
493+
491494
build-haproxy-ova-vsphere-photon-3: ## Builds Photon 3 HAProxy OVA and template on vSphere
492495

493496
build-node-ova-vsphere-clone-centos-7: ## Builds CentOS 7 Node OVA and template on vSphere

images/capi/hack/image-build-ova.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ def main():
140140
'DISTRO_NAME': build_data['distro_name'],
141141
'DISTRO_VERSION': build_data['distro_version'],
142142
'DISTRO_ARCH': build_data['distro_arch'],
143-
'NESTEDHV': "false"
143+
'NESTEDHV': "false",
144+
'FIRMWARE': build_data['firmware']
144145
}
145146

146147
capv_url = "https://github.com/kubernetes-sigs/cluster-api-provider-vsphere"

images/capi/hack/ovf_template.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@
127127
<vmw:Config ovf:required="false" vmw:key="cpuHotAddEnabled" vmw:value="false"/>
128128
<vmw:Config ovf:required="false" vmw:key="cpuHotRemoveEnabled" vmw:value="false"/>
129129
<vmw:Config ovf:required="false" vmw:key="memoryHotAddEnabled" vmw:value="false"/>
130-
<vmw:Config ovf:required="false" vmw:key="firmware" vmw:value="bios"/>
130+
<vmw:Config ovf:required="false" vmw:key="firmware" vmw:value="${FIRMWARE}"/>
131131
<vmw:Config ovf:required="false" vmw:key="tools.syncTimeWithHost" vmw:value="false"/>
132132
<vmw:Config ovf:required="false" vmw:key="tools.afterPowerOn" vmw:value="true"/>
133133
<vmw:Config ovf:required="false" vmw:key="tools.afterResume" vmw:value="true"/>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright 2019 The Kubernetes Authors.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
d-i preseed/include string ../base/preseed-efi.cfg
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
# Copyright 2019 The Kubernetes Authors.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# Configure the locale
16+
d-i debian-installer/locale string en_US.utf8
17+
d-i console-setup/ask_detect boolean false
18+
d-i console-setup/layout string us
19+
20+
# Configure the clock
21+
d-i time/zone string UTC
22+
d-i clock-setup/utc-auto boolean true
23+
d-i clock-setup/utc boolean true
24+
25+
# Configure the keyboard
26+
d-i kbd-chooser/method select American English
27+
28+
# Configure networking
29+
d-i netcfg/wireless_wep string
30+
31+
# Select the kernel
32+
d-i base-installer/kernel/override-image string linux-virtual
33+
34+
# Configure a non-interactive install
35+
debconf debconf/frontend select Noninteractive
36+
37+
# Configure the base installation
38+
d-i pkgsel/install-language-support boolean false
39+
d-i pkgsel/language-packs multiselect
40+
tasksel tasksel/first multiselect # standard, ubuntu-server
41+
42+
43+
### Simple GPT configuration w/o LVM
44+
d-i partman-auto/disk string /dev/sda
45+
46+
d-i partman/alignment string cylinder
47+
d-i partman/confirm_write_new_label boolean true
48+
d-i partman-basicfilesystems/choose_label string gpt
49+
d-i partman-basicfilesystems/default_label string gpt
50+
d-i partman-partitioning/choose_label string gpt
51+
d-i partman-partitioning/default_label string gpt
52+
d-i partman/choose_label string gpt
53+
d-i partman/default_label string gpt
54+
55+
d-i partman-auto/method string regular
56+
d-i partman-auto/choose_recipe select gpt-boot-root-swap
57+
d-i partman-auto/expert_recipe string \
58+
gpt-boot-root-swap :: \
59+
1 1 1 free \
60+
$bios_boot{ } \
61+
method{ biosgrub } . \
62+
200 200 200 fat32 \
63+
$primary{ } \
64+
method{ efi } format{ } . \
65+
512 512 512 ext3 \
66+
$primary{ } $bootable{ } \
67+
method{ format } format{ } \
68+
use_filesystem{ } filesystem{ ext3 } \
69+
mountpoint{ /boot } . \
70+
1000 20000 -1 ext4 \
71+
$primary{ } \
72+
method{ format } format{ } \
73+
use_filesystem{ } filesystem{ ext4 } \
74+
mountpoint{ / } .
75+
76+
d-i partman-partitioning/confirm_write_new_label boolean true
77+
d-i partman/choose_partition select finish
78+
d-i partman/confirm boolean true
79+
d-i partman/confirm_nooverwrite boolean true
80+
81+
# Create the default user.
82+
d-i passwd/user-fullname string builder
83+
d-i passwd/username string builder
84+
d-i passwd/user-password password builder
85+
d-i passwd/user-password-again password builder
86+
d-i user-setup/encrypt-home boolean false
87+
d-i user-setup/allow-password-weak boolean true
88+
89+
# Disable upgrading packages upon installation.
90+
d-i pkgsel/upgrade select none
91+
d-i grub-installer/only_debian boolean true
92+
d-i grub-installer/with_other_os boolean true
93+
d-i finish-install/reboot_in_progress note
94+
d-i pkgsel/update-policy select none
95+
96+
# Disable use of the apt mirror during base install
97+
# This means only packages available in the ISO can be installed
98+
d-i apt-setup/use_mirror boolean false
99+
100+
# Disable the security repo as well (it's on by default)
101+
d-i apt-setup/services-select multiselect none
102+
103+
# Customize the list of packages installed.
104+
d-i pkgsel/include string openssh-server open-vm-tools
105+
106+
107+
# Ensure questions about these packages do not bother the installer.
108+
libssl1.1 libssl1.1/restart-without-asking boolean true
109+
libssl1.1:amd64 libssl1.1/restart-without-asking boolean true
110+
libssl1.1 libssl1.1/restart-services string
111+
libssl1.1:amd64 libssl1.1/restart-services string
112+
113+
114+
# This command runs after all other steps; it:
115+
# 1. Ensures the "builder" user doesn't require a password to use sudo
116+
# 2. Cleans up any packages that are no longer required
117+
# 3. Cleans the package cache
118+
# 4. Removes the cached list of packages
119+
# 5. Disables swapfiles
120+
# 6. Removes the existing swapfile
121+
# 7. Removes the swapfile entry from /etc/fstab
122+
d-i preseed/late_command string \
123+
echo 'builder ALL=(ALL) NOPASSWD: ALL' >/target/etc/sudoers.d/builder ; \
124+
in-target chmod 440 /etc/sudoers.d/builder ; \
125+
in-target swapoff -a ; \
126+
in-target rm -f /swapfile ; \
127+
in-target sed -ri '/\sswap\s/s/^#?/#/' /etc/fstab ; \
128+
in-target rm -f /etc/udev/rules.d/70-persistent-net.rules

images/capi/packer/ova/packer-common.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"disk_controller_type": "pvscsi",
55
"disk_thin_provisioned": "true",
66
"disk_type_id": "0",
7+
"firmware": "bios",
78
"format": "",
89
"guestinfo_datasource_ref": "v1.4.0",
910
"guestinfo_datasource_script": "{{user `guestinfo_datasource_slug`}}/{{user `guestinfo_datasource_ref`}}/install.sh",

images/capi/packer/ova/packer-haproxy.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
"force": true,
6363
"output_directory": "{{user `output_dir`}}"
6464
},
65+
"firmware": "{{user `firmware`}}",
6566
"folder": "{{user `folder`}}",
6667
"guest_os_type": "{{user `vsphere_guest_os_type`}}",
6768
"host": "{{user `host`}}",

images/capi/packer/ova/packer-node.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@
140140
"force": true,
141141
"output_directory": "{{user `base_output_dir`}}"
142142
},
143+
"firmware": "{{user `firmware`}}",
143144
"floppy_dirs": "{{ user `floppy_dirs`}}",
144145
"folder": "{{user `folder`}}",
145146
"guest_os_type": "{{user `vsphere_guest_os_type`}}",
@@ -194,6 +195,7 @@
194195
"manifest": "{{ user `export_manifest`}}",
195196
"output_directory": "{{user `output_dir`}}"
196197
},
198+
"firmware": "{{user `firmware`}}",
197199
"floppy_dirs": "{{ user `floppy_dirs`}}",
198200
"folder": "{{user `folder`}}",
199201
"guest_os_type": "{{user `vsphere_guest_os_type`}}",
@@ -272,6 +274,7 @@
272274
"distro_arch": "{{ user `distro_arch` }}",
273275
"distro_name": "{{ user `distro_name` }}",
274276
"distro_version": "{{ user `distro_version` }}",
277+
"firmware": "{{user `firmware`}}",
275278
"guest_os_type": "{{user `guest_os_type`}}",
276279
"ib_version": "{{user `ib_version`}}",
277280
"kubernetes_cni_semver": "{{user `kubernetes_cni_semver`}}",
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"boot_command_prefix": "<esc><wait><esc><wait><enter><wait>linux /install/vmlinuz auto console-setup/ask_detect=false console-setup/layoutcode=us console-setup/modelcode=pc105 debconf/frontend=noninteractive debian-installer=en_US fb=false kbd-chooser/method=us keyboard-configuration/layout=USA keyboard-configuration/variant=USA locale=en_US netcfg/get_domain=local netcfg/get_hostname=localhost preseed/file=",
3+
"boot_command_suffix": "/20.04/preseed-efi.cfg -- <wait><enter>initrd /install/initrd.gz<enter>boot<enter><wait>",
4+
"boot_media_path": "/media/HTTP",
5+
"build_name": "ubuntu-2004-efi",
6+
"cdrom_type": "sata",
7+
"distro_arch": "amd64",
8+
"distro_name": "ubuntu",
9+
"distro_version": "20.04",
10+
"firmware": "efi",
11+
"floppy_dirs": "./packer/ova/linux/{{user `distro_name`}}/http/",
12+
"guest_os_type": "ubuntu-64",
13+
"iso_checksum": "f11bda2f2caed8f420802b59f382c25160b114ccc665dbac9c5046e7fceaced2",
14+
"iso_checksum_type": "sha256",
15+
"iso_url": "http://cdimage.ubuntu.com/ubuntu-legacy-server/releases/20.04/release/ubuntu-20.04.1-legacy-server-amd64.iso",
16+
"os_display_name": "Ubuntu 20.04",
17+
"shutdown_command": "shutdown -P now",
18+
"vsphere_guest_os_type": "ubuntu64Guest"
19+
}

0 commit comments

Comments
 (0)