#!/bin/bash # # Script to install a single node K8s cluster on an RX-M Lab VM # # Usage: $ curl https://raw.githubusercontent.com/RX-M/classfiles/master/k8s.sh | sh # # N.B. The script turns off swap for the K8s control plane install but does not disable swap permanently. # Please comment out any swap volumes in the /etc/fstab before rebooting the VM. # # This script will fail to run if the apt db is locked (wait 10 mins and retry or reboot and retry). # # Kubernetes single node clusters require a 4GB ram VM to run properly. # # Copyright (c) 2026 RX-M LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. set -e # Increase inotify limits sudo sysctl fs.inotify.max_user_watches=5242880 sudo sysctl fs.inotify.max_user_instances=5120 echo "fs.inotify.max_user_watches=5242880" | sudo tee -a /etc/sysctl.conf echo "fs.inotify.max_user_instances=5120" | sudo tee -a /etc/sysctl.conf sudo systemctl restart systemd-sysctl sysctl fs.inotify.max_user_watches fs.inotify.max_user_instances fs.inotify.max_queued_events # Defaults DOCKER_VERSION="${DOCKER_VERSION:-"29.1.3"}" K8S_VERSION="${K8S_VERSION:-"v1.35.0"}" K8S_REPO="https://pkgs.k8s.io/core:/stable:/${K8S_VERSION%.*}/deb" CILIUM_VERSION="${CILIUM_VERSION:-1.18.3}" CILIUM_CLI_VERSION=$(curl -s https://raw.githubusercontent.com/cilium/cilium-cli/main/stable.txt) CLI_ARCH=amd64 # Install Docker if command -v docker >/dev/null 2>&1; then echo "Docker is already installed, skipping Docker installation" else curl -fsSL https://get.docker.com -o /tmp/install-docker.sh && sh /tmp/install-docker.sh --version $DOCKER_VERSION sudo mkdir -p /etc/docker cat <> ~/.bashrc