Create create-vm.sh:
#!/bin/sh dist='bionic' if [ -z "$1" ] ; then echo Specify a virtual-machine name. exit 1 fi sudo virt-install \ --name $1 \ --ram 4096 \ --disk path=/mnt/A/images/$1.img,size=30 \ --vcpus 2 \ --os-type linux \ --os-variant ubuntu18.04 \ --network bridge:br0,model=virtio \ --location "http://gb.archive.ubuntu.com/ubuntu/dists/${dist}/main/installer-amd64/" \ --graphics vnc,listen=192.168.2.13 \ --noautoconsole \ --extra-args "ip=192.168.2.30::192.168.2.1:255.255.255.0:${1}.internal.stroila.net:eth0:none"
Run create-vm.sh
./create-vm.sh k8s-master
Get the vnc display
virsh vncdisplay k8s-master
Turn off swap (edit /etc/fstab) and comment out the line that says swap.
and...
swapoff -a
Set static ip
$ cat /etc/netplan/01-netcfg.yaml # This file describes the network interfaces available on your system # For more information, see netplan(5). network: version: 2 renderer: networkd ethernets: ens3: dhcp4: no dhcp6: no addresses: [192.168.2.30/24, '2001:1::1/64'] gateway4: 192.168.2.1 nameservers: addresses: [192.168.2.1]
Clone the vm
virt-clone --original k8s-master --name k8s-w1 --auto-clone virt-clone --original k8s-master --name k8s-w2 --auto-clone virt-clone --original k8s-master --name k8s-w3 --auto-clone ...