$ brew cask install multipass
$ sh-keygen -b 2048 -f ~/.ssh/multipass -t rsa -q -N ""
cloud-init.yaml:
#cloud-config
ssh_authorized_keys:
- ssh-rsa AAA..the-output-of-multipass.pub.. user@host
runcmd:
- apt update && apt upgrade -y
Find a image:
$ multipass find
16.04 (or: x, xenial)
18.04 (or: b, bionic, default, lts)
Launch a VM with bionic and passing the cloud-init:
$ multipass launch bionic --name k3s-master --cloud-init=./cloud-init.yaml
View the VM's info:
$ multipass info k3s-master
Name: k3s-master
State: RUNNING
IPv4: 192.168.64.3
Release: Ubuntu 18.04.3 LTS
Image hash: 6afb97af96b6 (Ubuntu 18.04 LTS)
Load: 0.37 0.62 0.33
Disk usage: 1.4G out of 4.7G
Memory usage: 144.2M out of 986.0M
SSH to the VM:
$ ssh -i ~/.ssh/multipass multipass@$(multipass info k3s-master | grep 'IPv4' | awk '{print $2}')
Exec to the VM:
$ multipass exec k3s-master -- /bin/bash
Delete the VM:
$ multipass delete k3s-master
$ multipass purge