The network infrastructure will be used by kvm vms with libvirt (virsh)
ref: https://www.enkron.org/pub/entries/2.html
first check kvm (kernel-based virtual machine for Linux on x86) is enabled in system
kvm-oksudo apt update
sudo apt install -y libvirt-daemon-system virtinstcheck qemu emulator is installed
qemu-system-x86_64 --versionCloud images use cloud-init method for instance initialisation (eg. ubuntu cloud images archive https://cloud-images.ubuntu.com)
curl -fLO# http://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64.imguser-data file contains instructions for bootstrapping
kubernetes toolchains along with dependencies like containerd or cni
plugins.
NOTE: all package versions are currently hardcoded into the file, so
need to pay attention to maintenance
NOTE: change $SSH_PUBKEY variable to actual public key
kubernetes toolchains
kubeadm: bootstrap a cluster. Should be installed on all the hosts,
kubelet: component that runs on all of machines in a cluster and does
things like starting pods and containers,
kubectl: command line utility to talk to a cluster.
NOTE: kubelet won't work with a swap file
After installing each component to the control plane host cluster could initialized with the following command:
sudo kubeadm initTo start using the cluster run the following commands:
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/confighttps://kubernetes.io/docs/concepts/cluster-administration/addons/
kubectl apply -f <POD_NETWORK>.yamlfor example:
kubectl apply -f https://github.com/weaveworks/weave/releases/download/v2.8.1/weave-daemonset-k8s.yamlThis command deploys weave net that connects docker containers across
multiple hosts and enables their automatic discovery
kubeadm token create --print-join-commanduse an output from the command above to join a worker node to the cluster
virsh is a cli for virsh guest domains
list vms
virsh list --allget vms addresses
virsh net-dhcp-leases --network defaultshutdown vm gracefully
virsh shutdown <VM_TAG>start a vm
virsh start --domain <VM_TAG>