|
# Lima configuration for Ubuntu VM with containerd development setup |
|
base: template://ubuntu-24.04 |
|
|
|
cpus: 4 |
|
memory: "8GiB" |
|
disk: "100GiB" |
|
|
|
user: |
|
home: "/home/lima" |
|
|
|
mounts: |
|
- location: "{{.Home}}/go/src/github.com/containerd/containerd" |
|
mountPoint: "/home/lima/containerd" |
|
writable: true |
|
|
|
ssh: |
|
localPort: 60022 |
|
loadDotSSHPubKeys: true |
|
|
|
containerd: |
|
system: false |
|
user: false |
|
|
|
# Provisioning configuration |
|
provision: |
|
- mode: system |
|
script: | |
|
#!/bin/bash |
|
set -e |
|
|
|
echo "Starting containerd build setup..." |
|
|
|
# Install packages |
|
apt-get update -y |
|
apt-get install -y \ |
|
git \ |
|
wget \ |
|
curl \ |
|
unzip \ |
|
gcc \ |
|
g++ \ |
|
make \ |
|
pkg-config \ |
|
libc6-dev \ |
|
linux-headers-generic \ |
|
htop \ |
|
psmisc \ |
|
libsystemd-dev \ |
|
libseccomp-dev \ |
|
btrfs-progs \ |
|
libdevmapper-dev \ |
|
gperf \ |
|
which |
|
|
|
# Set up Go environment |
|
ARCH=$(uname -m); if [ "$ARCH" = "x86_64" ]; then ARCH="amd64"; elif [ "$ARCH" = "aarch64" ]; then ARCH="arm64"; fi |
|
curl -sL "https://dl.google.com/go/$(curl -s https://go.dev/VERSION?m=text | head -1).linux-${ARCH}.tar.gz" | sudo tar -C /usr/local -xzf - |
|
VERSION="v1.32.0" |
|
curl -sSL --fail --retry 5 https://storage.googleapis.com/k8s-artifacts-cri-tools/release/$VERSION/crictl-$VERSION-linux-$ARCH.tar.gz | sudo tar -xvzf - -C /usr/local/bin |
|
echo 'export PATH=/usr/local/go/bin:$PATH' >> /home/lima/.bashrc |
|
echo 'export PATH=$(go env GOPATH)/bin:$PATH' >> /home/lima/.bashrc |
|
echo 'export GOPATH=/home/lima/go' >> /home/lima/.bashrc |
|
|
|
# Set up environment for lima user |
|
echo 'export TERM=vt100' >> /home/lima/.bashrc |
|
echo 'cd /home/lima/containerd' >> /home/lima/.bashrc |
|
|
|
# Create build script for containerd |
|
cat > /home/lima/build-containerd.sh << 'BUILDEOF' |
|
#!/bin/bash |
|
set -e |
|
|
|
export PATH=/usr/local/go/bin:$PATH |
|
export PATH=$(go env GOPATH)/bin:$PATH |
|
export GOPATH=/home/lima/go |
|
|
|
echo "Go version: $(go version)" |
|
|
|
cd /home/lima/containerd |
|
echo "Building containerd from: $(pwd)" |
|
|
|
# Run the setup scripts (adapted for Ubuntu) |
|
echo "Installing dependencies..." |
|
|
|
# Install seccomp |
|
sudo -E "PATH=$PATH" script/setup/install-seccomp |
|
# Install runc |
|
sudo -E "PATH=$PATH" script/setup/install-runc |
|
# Install CNI |
|
sudo -E "PATH=$PATH" script/setup/install-cni |
|
# Install protobuf |
|
sudo rm -rf /usr/local/include/google /usr/local/readme.txt /go/src/usr/local/include/google || true |
|
sudo rm -f /usr/local/bin/protoc /go/src/usr/local/bin/protoc || true |
|
sudo -E "PATH=$PATH" script/setup/install-protobuf |
|
sudo mkdir -p /go/src/usr/local/bin /go/src/usr/local/include |
|
sudo mv /usr/local/bin/protoc /go/src/usr/local/bin/protoc |
|
sudo mv /usr/local/include/google /go/src/usr/local/include/google |
|
|
|
sudo rm -rf /home/lima/.cache/go-build/ |
|
|
|
# Build containerd |
|
echo "Building containerd binaries..." |
|
make binaries GO_BUILD_FLAGS="-mod=vendor" |
|
|
|
# Install containerd |
|
echo "Installing containerd..." |
|
sudo -E "PATH=$PATH" make install |
|
|
|
# Set up systemd service |
|
echo "Setting up containerd service..." |
|
if [ -f containerd.service ]; then |
|
sudo cp containerd.service /etc/systemd/system/containerd.service |
|
sudo systemctl daemon-reload |
|
sudo systemctl enable containerd.service |
|
sudo systemctl start containerd.service |
|
echo "Containerd service started successfully!" |
|
sudo systemctl status containerd.service --no-pager |
|
fi |
|
|
|
# for debugging convenience |
|
sudo chown $USER:$USER /run/containerd/containerd.sock |
|
echo 'runtime-endpoint: unix:///run/containerd/containerd.sock' | sudo tee /etc/crictl.yaml |
|
|
|
echo "Containerd build and installation completed!" |
|
BUILDEOF |
|
|
|
chmod +x /home/lima/build-containerd.sh |
|
chown lima:lima /home/lima/build-containerd.sh |
|
|
|
# Create kernel modules configuration |
|
tee /etc/modules-load.d/containerd.conf > /dev/null << 'MODEOF' |
|
overlay |
|
br_netfilter |
|
MODEOF |
|
|
|
# Create sysctl configuration |
|
tee /etc/sysctl.d/99-kubernetes-cri.conf > /dev/null << 'SYSCTLEOF' |
|
net.bridge.bridge-nf-call-iptables = 1 |
|
net.ipv4.ip_forward = 1 |
|
net.bridge.bridge-nf-call-ip6tables = 1 |
|
SYSCTLEOF |
|
|
|
echo "Ubuntu VM setup complete for containerd development!" |
|
echo "" |
|
echo "To build and install containerd:" |
|
echo "1. SSH into the VM: limactl shell containerd-ubuntu" |
|
echo "2. Run the build script: ./build-containerd.sh" |
|
echo "" |
|
echo "The containerd source is mounted at: /home/lima/containerd" |
|
echo "Go workspace is at: /home/lima/go" |
|
echo "" |
|
echo "Useful commands:" |
|
echo "- build-containerd: Build and install containerd" |
|
echo "- ctr: Run containerd CLI (with sudo)" |
|
echo "- systemctl status containerd: Check containerd service status" |