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-ok
sudo apt update
sudo apt install -y libvirt-daemon-system virtinst
check qemu
emulator is installed
qemu-system-x86_64 --version
Cloud 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.img
user-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 init
To 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/config
https://kubernetes.io/docs/concepts/cluster-administration/addons/
kubectl apply -f <POD_NETWORK>.yaml
for example:
kubectl apply -f https://github.com/weaveworks/weave/releases/download/v2.8.1/weave-daemonset-k8s.yaml
This command deploys weave net
that connects docker containers across
multiple hosts and enables their automatic discovery
kubeadm token create --print-join-command
use 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 --all
get vms addresses
virsh net-dhcp-leases --network default
shutdown vm gracefully
virsh shutdown <VM_TAG>
start a vm
virsh start --domain <VM_TAG>