Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pr/jrajahalme/arm64 multipass 1.11.0 rebase #352

Draft
wants to merge 21 commits into
base: master
Choose a base branch
from

Conversation

jrajahalme
Copy link
Member

@jrajahalme jrajahalme commented Jan 4, 2023

Add support for creating and configuring VMs with Canonical multipass, mainly to be able to run Cilium CI VMs on macOS on Apple Silicon.

Example use:

  1. Clone this repo onto directory named 'cilium', where you also have 'cilium' main repo. So after cloning you'll have:
    cilium/cilium (cloned from https://github.com/cilium/cilium.git)
    cilium/packer-ci-build (cloned from https://github.com/cilium/packer-ci-build.git)
  2. Change to cilium/packer-ci-build and check out this branch:
$ git checkout pr/jrajahalme/arm64-multipass-1.11.0-rebase
  1. Create VM dev using a native mount (NFS is the default mount type):
$ MOUNT=native VM_NAME=dev make multipass
  1. Shell into the new VM, check the mount type, and compile cilium:
$ multipass shell dev
$ mount -l | grep github
$ cd go/src/github.com/cilium/cilium
$ time make

@jrajahalme jrajahalme requested review from a team as code owners January 4, 2023 18:13
@jrajahalme jrajahalme requested review from qmonnet and nebril and removed request for a team January 4, 2023 18:13
@jrajahalme jrajahalme marked this pull request as draft January 4, 2023 18:13
@jrajahalme jrajahalme force-pushed the pr/jrajahalme/arm64-multipass-1.11.0-rebase branch 2 times, most recently from 1054131 to 823d593 Compare January 4, 2023 22:11
@jrajahalme jrajahalme force-pushed the pr/jrajahalme/arm64-multipass-1.11.0-rebase branch from 823d593 to 14ed4ec Compare February 19, 2023 11:54
Apply kernel-patches if they exist. This way the kernel compile script
does not need to be changed when kernel patches are added or the last one
is removed.

Signed-off-by: Jarno Rajahalme <[email protected]>
Use versions that have arm64 images available.

Signed-off-by: Jarno Rajahalme <[email protected]>
Default to "amd64", but support "arm64" as well.

Remove install of gcc-multilib, as it is not available for arm64, and
apparently not deeded with amd64 either.

Signed-off-by: Jarno Rajahalme <[email protected]>
Use $HOME_DIR exclusively instead of $HOME to refer to the target user
home directory, as sudo can override $HOME with 'root' depending on
the execution context.

Signed-off-by: Jarno Rajahalme <[email protected]>
Pass the install user name via $USERNAME, so that same scripts can be
used for different default user names (e.g., 'ubuntu' in addition to
'vagrant').

Signed-off-by: Jarno Rajahalme <[email protected]>
Make sure the home directory is owned by the target ${USERNAME} before
trying to create the 'go' directory on it.

Not sure if needed still, but failed due to this at one point.

Signed-off-by: Jarno Rajahalme <[email protected]>
Add export for GOPATH in .profile so that make targets that depend on
it being set work as expected (e.g., 'make generate-k8s-api').

Signed-off-by: Jarno Rajahalme <[email protected]>
Add -f to 'ln -s' commands so that they do not fail if executed
again. This is helpful when improving the provisioning scripts.

Signed-off-by: Jarno Rajahalme <[email protected]>
Append to SSH authorized keys instead of overwriting them to keep any
authorized keys set previously.

This allows building of local images that have local users public key
as an authorized key for local testing.

Signed-off-by: Jarno Rajahalme <[email protected]>
Only install VirtualBox guest additions if VirtualBox is detected via
"$HOME_DIR/.vbox_version".

Signed-off-by: Jarno Rajahalme <[email protected]>
Install docker only if not already installed. This allows building on
top of image stages that already install docker before these
provisioning steps.

Signed-off-by: Jarno Rajahalme <[email protected]>
Pull from sayboras/netperf that has the multiple definitions fix
(HewlettPackard/netperf#46).

Signed-off-by: Jarno Rajahalme <[email protected]>
This allows install of, say, 5.11.

Signed-off-by: Jarno Rajahalme <[email protected]>
Add an exception for the cilium repo for to fix the
"fatal: detected dubious ownership in repository at '/home/ubuntu/go/src/github.com/cilium/packer-ci-build'"
error condition when using the repo via an NFS mount as a normal user

Signed-off-by: Jarno Rajahalme <[email protected]>
Echo "Rebooting kernel" when a new kernel is about to be rebooted do that
we can scan for it from the console output.

Signed-off-by: Jarno Rajahalme <[email protected]>
…the rest

Add script provision/provision-kernel.sh for provisioning an old or new kernel, and
provision/provision.sh for provisioning everything after the kernel reboot.

Add kernel modules needed by kube-proxy 1.19.11 to provision/ubuntu/kernel-next.sh.

Signed-off-by: Jarno Rajahalme <[email protected]>
Remove also bpftool directory after install so that provioning can be
rerun without erroring out due to non-empty directory existing when `git
clone`.

Do not fail if /usr/bin/ip has already been removed.

Signed-off-by: Jarno Rajahalme <[email protected]>
Add 'multipass' target for creating Cilium Development VMs with
Canonical Multipass.

Example use:

$ VM_NAME=dev make multipass

or the same with the script:

$ VM_CPUS=8 VM_MEMORY=16G VM_DISK=100G ./provision/multipass.sh dev

Note: VM_NAME defaults to "dev".

This will launch a new Linux 5.4 VM with Ubuntu 22.04 and run the standard Cilium
VM provisioning scripts on it, followed by mounting the Cilium repos from
the host to the VM (at /home/ubuntu/go/src/github.com/cilium) using NFS.

See the Makefile and provision/multipass.sh for all the supported environment variables.

This has been tested on MacOS on Apple Silicon (arm64), but should also
work on the Intel models (amd64). Multipass should also work on Linux,
but that has not been tested.

Install the package needed (nfs-common) for mounting NFS shares to the dev VM.

Cilium directory will be mounted with NFS, define environement variable
'MOUNT=default' to use an sshfs mount instead.

Signed-off-by: Jarno Rajahalme <[email protected]>
Updates for Multipass 1.11:
- add support for MOUNT=native
- use '--recursive' option for 'multipass transfer'
- use '--memory' instead of the deprecated '--mem'

Signed-off-by: Jarno Rajahalme <[email protected]>
@jrajahalme jrajahalme force-pushed the pr/jrajahalme/arm64-multipass-1.11.0-rebase branch from 14ed4ec to 68d1112 Compare February 19, 2023 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant