VMs
Goal is to replicate a remote Ubuntu VM locally on MacOS
- brew install multipass (did not install via MacPorts as of 9/13/24)
- multipass find gives a list of images
- download an image
- use multipass and the image to create an instance
- launch the instance → now the command line switches from userA@host to userB@VMinstance
- python is natively installed with ubuntu now
- have to install pip, one of the most common python package managers: sudo apt install python3-pip
- used pip install to get another python package manager: uv
- pip installs at a specific dir location → this location is not in the system environment variables by default → add to path to use uv from command line
- uv can install either to where system’s default python libs are stored or create a virtual env and then install more libs there
- created a virtual env: ML
- source ML/bin/activate → switches the terminal command line to show venv activated
- within the venv → uv pip install numpy
Resolved 1 package in 3ms
Installed 1 package in 8ms
14. deactivate gets out of the python venv and back to the ubuntu VM
Goal: Launch multiple VMs to create a cluster managed by kube. Use a bash script.
- Configure the VM with that runs the Kubernetes Control Plane to have at least 2 GB memory and 2 CPUs, see screenshot.
- Give executable permission to bash script: chmod +x launch_vms.sh
- Run: ./launch_vms.sh

Next: install docker, run docker engine, install kube. When the docker engine is running, systemctl status docker will show:

The following commands will install kube
echo “deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.28/deb/ /” | sudo tee /etc/apt/sources.list.d/kubernetes.list
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.28/deb/Release.key | sudo gpg — -dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
sudo apt-get install -y kubelet kubeadm kubectl
sudo apt-mark hold kubelet kubeadm kubectl
sudo swapoff -a
sudo kubeadm init — pod-network-cidr=192.168.0.0/16
Note that there is a font change in Medium, so copy/paste messes. Two dashes before dearmor.
Output:

Disk space in VM is 99% used. Default 4G disk space allocated by multipass.

Delete previous VMs and launching with new config.
multipass delete vm-1 vm-2 vm-3
multipass purge
Five VM’s launched with a yaml config file a sweetly clean shell script. Install docker, kube, nginx, python, vim.
cloud-init.yaml
#cloud-config
package_update: true
package_upgrade: true
packages:
- docker.io
- kubelet
- kubeadm
- kubectl
- nginx
- python3
- vim
- apt-transport-https
- ca-certificates
- curl
runcmd:
- curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
- curl -s https://pkgs.k8s.io/core:/stable:/v1.28/deb/Release.key | apt-key add — # change
- apt-add-repository “deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable”
- apt-add-repository “deb https://apt.kubernetes.io/ kubernetes-xenial main”
- apt-get update
- apt-get install -y docker-ce docker-ce-cli containerd.io
- systemctl enable docker
- systemctl start docker
- swapoff -a # Disable swap for Kubernetes
- kubeadm init — pod-network-cidr=192.168.0.0/16
- mkdir -p /home/ubuntu/.kube
- cp /etc/kubernetes/admin.conf /home/ubuntu/.kube/config
- chown ubuntu:ubuntu /home/ubuntu/.kube/config
However. Random check on VM-3, checking docker status shows failed.

Manually sudo enabled and sudo started docker, which led to active status.
Modified cloud-init.yaml to add sudo. Five VMs launched successfully; docker had to be enabled and started manually again. :/
- Number of VMs, VM memory, and CPU’s are specified in the bash script.
- This is the current file to install packages when launching a VM(?), should also install jre and spark.

