Skip to content

Commit

Permalink
Support flatcar
Browse files Browse the repository at this point in the history
* Workaround scp behaviour in OpenSSH 9.0

scp in OpenSSH 9 now uses SFTP by default, which breaks the Packer /
Ansible / SSH Proxy interaction

See hashicorp/packer-plugin-ansible#100
And hashicorp/packer#11783

Adding the `-O` flag to  the `scp` command forces the old protocol to be
used.

* Initial support for building on OpenStack & Bump versions to build images for Kubernetes 1.24.2

* patch: changed deprecated floating_ip_pool to floating_ip_network

* patch: Adding new variables and os.json files to allow building of ubuntu remotely in Openstack

Added ability to override the image name to create unique images on subsequent runs.
Added option to images as public via variables.

* fix: corrected ubuntu20 variables in json file

* Support flatcar

* Fix some vars

* Enable blockstorage volume in default

* Add more flatcar vars

---------

Co-authored-by: Nick Jones <nick@dischord.org>
Co-authored-by: Drew <vilesy@gmail.com>
  • Loading branch information
3 people committed Feb 24, 2023
1 parent 353f4ea commit d92d0b7
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 88 deletions.
21 changes: 16 additions & 5 deletions images/capi/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ deps-openstack:
hack/ensure-ansible.sh
hack/ensure-packer.sh
hack/ensure-goss.sh
#TODO hack/ensure-openstack.sh

.PHONY: deps-qemu
deps-qemu: ## Installs/checks dependencies for QEMU builds
Expand Down Expand Up @@ -334,8 +333,9 @@ OCI_BUILD_NAMES ?= oci-ubuntu-1804 oci-ubuntu-2004 oci-ubuntu-2204 oci-orac

DO_BUILD_NAMES ?= do-centos-7 do-ubuntu-1804 do-ubuntu-2004

OPENSTACK_BUILD_NAMES ?= openstack-ubuntu-2004 openstack-ubuntu-2204 openstack-flatcar

OSC_BUILD_NAMES ?= osc-ubuntu-2004
OPENSTACK_BUILD_NAMES ?= openstack-ubuntu-2004 openstack-ubuntu-2204

QEMU_BUILD_NAMES ?= qemu-ubuntu-1804 qemu-ubuntu-2004 qemu-ubuntu-2204 qemu-centos-7 qemu-ubuntu-2004-efi qemu-rhel-8 qemu-rockylinux-8 qemu-flatcar
QEMU_KUBEVIRT_BUILD_NAMES := $(addprefix kubevirt-,$(QEMU_BUILD_NAMES))
Expand Down Expand Up @@ -370,6 +370,7 @@ AZURE_VALIDATE_SIG_GEN2_TARGETS := $(addprefix validate-,$(AZURE_BUILD_SIG_GEN2_
DO_BUILD_TARGETS := $(addprefix build-,$(DO_BUILD_NAMES))
DO_VALIDATE_TARGETS := $(addprefix validate-,$(DO_BUILD_NAMES))
OPENSTACK_BUILD_TARGETS := $(addprefix build-,$(OPENSTACK_BUILD_NAMES))
OPENSTACK_VALIDATE_TARGETS := $(addprefix validate-,$(OPENSTACK_BUILD_NAMES))
QEMU_BUILD_TARGETS := $(addprefix build-,$(QEMU_BUILD_NAMES))
QEMU_VALIDATE_TARGETS := $(addprefix validate-,$(QEMU_BUILD_NAMES))
QEMU_KUBEVIRT_BUILD_TARGETS := $(addprefix build-,$(QEMU_KUBEVIRT_BUILD_NAMES))
Expand Down Expand Up @@ -471,7 +472,11 @@ $(DO_VALIDATE_TARGETS): deps-do

.PHONY: $(OPENSTACK_BUILD_TARGETS)
$(OPENSTACK_BUILD_TARGETS): deps-openstack
packer build $(PACKER_NODE_FLAGS) -var-file="$(abspath packer/openstack/$(subst build-,,$@).json)" $(ABSOLUTE_PACKER_VAR_FILES) packer/openstack/packer.json
packer build $(PACKER_NODE_FLAGS) -var-file="$(abspath packer/openstack/$(subst build-openstack-,,$@).json)" $(ABSOLUTE_PACKER_VAR_FILES) packer/openstack/packer.json

.PHONY: $(OPENSTACK_VALIDATE_TARGETS)
$(OPENSTACK_VALIDATE_TARGETS): deps-openstack
packer validate $(PACKER_NODE_FLAGS) -var-file="$(abspath packer/openstack/$(subst validate-do-,,$@).json)" $(ABSOLUTE_PACKER_VAR_FILES) packer/openstack/packer.json

.PHONY: $(QEMU_BUILD_TARGETS)
$(QEMU_BUILD_TARGETS): deps-qemu
Expand Down Expand Up @@ -686,8 +691,9 @@ build-node-ova-local-base-rockylinux-8: ## Builds RockyLinux 8 Base Node OVA w l
build-node-ova-local-base-ubuntu-1804: ## Builds Ubuntu 18.04 Base Node OVA w local hypervisor
build-node-ova-local-base-ubuntu-2004: ## Builds Ubuntu 20.04 Base Node OVA w local hypervisor

build-openstack-ubuntu-2004: ## Builds OpenStack 20.04 image
build-openstack-ubuntu-2204: ## Builds OpenStack 22.04 image
build-openstack-ubuntu-2004: ## Builds Ubuntu 20.04 OpenStack image
build-openstack-ubuntu-2204: ## Builds Ubuntu 22.04 OpenStack image
build-openstack-flatcar: ## Builds Flatcar OpenStack image
build-openstack-all: $(OPENSTACK_BUILD_TARGETS)

build-qemu-flatcar: ## Builds Flatcar QEMU image
Expand Down Expand Up @@ -774,6 +780,11 @@ validate-do-ubuntu-2004: ## Validates Ubuntu 20.04 DigitalOcean Snapshot Packer
validate-do-centos-7: ## Validates Centos 7 DigitalOcean Snapshot Packer config
validate-do-all: $(DO_VALIDATE_TARGETS) ## Validates all DigitalOcean Snapshot Packer config

validate-openstack-ubuntu-2004: ## Validates Ubuntu 18.04 Openstack Image Packer config
validate-openstack-ubuntu-2204: ## Validates Ubuntu 20.04 Openstack Image Packer config
validate-openstack-flatcar: ## Validates Flatcar Openstack Image Packer config
validate-openstack-all: $(OPENSTACK_VALIDATE_TARGETS) ## Validates all Openstack Glance Image Packer config

validate-gce-ubuntu-1804: ## Validates Ubuntu 18.04 GCE Snapshot Packer config
validate-gce-ubuntu-2004: ## Validates Ubuntu 20.04 GCE Snapshot Packer config
validate-gce-ubuntu-2204: ## Validates Ubuntu 22.04 GCE Snapshot Packer config
Expand Down
4 changes: 1 addition & 3 deletions images/capi/packer/openstack/OWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

approvers:
- cluster-api-openstack-maintainers
- cluster-api-cloudstack-maintainers

reviewers:
- cluster-api-openstack-maintainers
- image-builder-openstack-reviewers
- cluster-api-cloudstack-maintainers
- image-builder-cloudstack-reviewers

11 changes: 11 additions & 0 deletions images/capi/packer/openstack/flatcar.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"build_name": "flatcar",
"source_image": "flatcar",
"systemd_prefix": "/etc/systemd",
"sysusr_prefix": "/opt",
"sysusrlocal_prefix": "/opt",
"kubernetes_cni_source_type": "http",
"kubernetes_source_type": "http",
"crictl_source_type": "http",
"ansible_extra_vars": "ansible_python_interpreter=/opt/bin/python"
}
94 changes: 14 additions & 80 deletions images/capi/packer/openstack/packer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"config_drive": "{{user `attach_config_drive`}}",
"flavor": "{{user `flavor`}}",
"floating_ip_network": "{{user `floating_ip_network`}}",
"image_disk_format": "raw",
"image_disk_format": "{{user `image_disk_format`}}",
"image_name": "{{user `image_name`}}",
"image_visibility": "{{user `image_visibility`}}",
"networks": "{{user `networks`}}",
Expand All @@ -15,9 +15,11 @@
"ssh_timeout": "2h",
"ssh_username": "{{user `ssh_username`}}",
"type": "openstack",
"use_blockstorage_volume": true,
"use_blockstorage_volume": "{{user `use_blockstorage_volume`}}",
"use_floating_ip": "{{user `use_floating_ip`}}",
"volume_size": "10"
"volume_size": "{{user `volume_size`}}",
"ssh_keypair_name": "{{user `ssh_keypair_name`}}",
"ssh_private_key_file": "{{user `ssh_private_key_file`}}"
}
],
"post-processors": [
Expand All @@ -41,37 +43,9 @@
},
{
"ansible_env_vars": [
"ANSIBLE_SSH_ARGS='{{user `existing_ansible_ssh_args`}} -oHostKeyAlgorithms=+ssh-rsa -oPubkeyAcceptedAlgorithms=+ssh-rsa -o IdentitiesOnly=yes'"
"ANSIBLE_SSH_ARGS='{{user `existing_ansible_ssh_args`}} -o IdentitiesOnly=yes'"
],
"extra_arguments": [
"--scp-extra-args",
"'-O'",
"--extra-vars",
"{{user `ansible_common_vars`}}",
"--extra-vars",
"{{user `ansible_extra_vars`}}",
"--extra-vars",
"{{user `ansible_user_vars`}}"
],
"playbook_file": "./ansible/firstboot.yml",
"type": "ansible",
"user": "builder"
},
{
"expect_disconnect": true,
"inline": [
"sudo reboot now"
],
"inline_shebang": "/bin/bash -e",
"type": "shell"
},
{
"ansible_env_vars": [
"ANSIBLE_SSH_ARGS='{{user `existing_ansible_ssh_args`}} -oHostKeyAlgorithms=+ssh-rsa -oPubkeyAcceptedAlgorithms=+ssh-rsa -o IdentitiesOnly=yes'"
],
"extra_arguments": [
"--scp-extra-args",
"'-O'",
"--extra-vars",
"{{user `ansible_common_vars`}}",
"--extra-vars",
Expand All @@ -81,61 +55,25 @@
],
"playbook_file": "./ansible/node.yml",
"type": "ansible",
"user": "builder"
},
{
"arch": "{{user `goss_arch`}}",
"format": "{{user `goss_format`}}",
"format_options": "{{user `goss_format_options`}}",
"goss_file": "{{user `goss_entry_file`}}",
"inspect": "{{user `goss_inspect_mode`}}",
"tests": [
"{{user `goss_tests_dir`}}"
],
"type": "goss",
"url": "{{user `goss_url`}}",
"use_sudo": true,
"vars_file": "{{user `goss_vars_file`}}",
"vars_inline": {
"ARCH": "amd64",
"OS": "{{user `distro_name` | lower}}",
"OS_VERSION": "{{user `os_version`}}",
"PROVIDER": "qemu",
"containerd_version": "{{user `containerd_version`}}",
"kubernetes_cni_deb_version": "{{ user `kubernetes_cni_deb_version` }}",
"kubernetes_cni_rpm_version": "{{ split (user `kubernetes_cni_rpm_version`) \"-\" 0 }}",
"kubernetes_cni_source_type": "{{user `kubernetes_cni_source_type`}}",
"kubernetes_cni_version": "{{user `kubernetes_cni_semver` | replace \"v\" \"\" 1}}",
"kubernetes_deb_version": "{{ user `kubernetes_deb_version` }}",
"kubernetes_rpm_version": "{{ split (user `kubernetes_rpm_version`) \"-\" 0 }}",
"kubernetes_source_type": "{{user `kubernetes_source_type`}}",
"kubernetes_version": "{{user `kubernetes_semver` | replace \"v\" \"\" 1}}"
},
"version": "{{user `goss_version`}}"
"user": "core"
}
],
"variables": {
"accelerator": "kvm",
"ansible_common_vars": "",
"ansible_extra_vars": "ansible_python_interpreter=/usr/bin/python3",
"floating_ip_network": "public",
"image_disk_format": "raw",
"use_blockstorage_volume": "true",
"volume_size": "10",
"ansible_common_vars": "ansible_python_interpreter=/usr/bin/python3",
"ansible_extra_vars": "",
"ansible_user_vars": "",
"attach_config_drive": "false",
"boot_wait": "10s",
"build_timestamp": "{{timestamp}}",
"containerd_sha256": null,
"containerd_url": "https://github.com/containerd/containerd/releases/download/v{{user `containerd_version`}}/cri-containerd-cni-{{user `containerd_version`}}-linux-amd64.tar.gz",
"containerd_version": null,
"cpus": "1",
"crictl_url": "https://github.com/kubernetes-sigs/cri-tools/releases/download/v{{user `crictl_version`}}/crictl-v{{user `crictl_version`}}-linux-amd64.tar.gz",
"crictl_version": null,
"disk_compression": "false",
"disk_discard": "unmap",
"disk_size": "20480",
"existing_ansible_ssh_args": "{{env `ANSIBLE_SSH_ARGS`}}",
"firmware": "",
"format": "qcow2",
"headless": "true",
"http_directory": "./packer/openstack/linux/{{user `distro_name`}}/http/",
"image_name": "{{user `build_name`}}-kube-{{user `kubernetes_semver`}}",
"image_visibility": "private",
"kubernetes_cni_deb_version": null,
Expand All @@ -155,11 +93,7 @@
"kubernetes_semver": null,
"kubernetes_series": null,
"kubernetes_source_type": null,
"machine_id_mode": "444",
"memory": "2048",
"python_path": "",
"qemu_binary": "qemu-system-x86_64",
"ssh_username": "{{user `ssh_username`}}",
"ssh_username": "core",
"use_floating_ip": "true"
}
}
5 changes: 5 additions & 0 deletions images/capi/packer/openstack/ubuntu-2004.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"build_name": "ubuntu-2004",
"source_image": "ubuntu-20-04-x64",
"ssh_username": "ubuntu"
}
5 changes: 5 additions & 0 deletions images/capi/packer/openstack/ubuntu-2204.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"build_name": "ubuntu-2204",
"source_image": "ubuntu-22-04-x64",
"ssh_username": "ubuntu"
}

0 comments on commit d92d0b7

Please sign in to comment.