Update arch_install.sh
This commit is contained in:
parent
a20a91b086
commit
427c7b2c27
|
|
@ -1,44 +1,83 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
# Update system and install Docker stack from official Arch repos
|
# Update system
|
||||||
sudo pacman -Syu --noconfirm
|
sudo pacman -Syu --noconfirm
|
||||||
|
|
||||||
|
# Switch from legacy iptables to nft backend if needed
|
||||||
|
if pacman -Q iptables >/dev/null 2>&1; then
|
||||||
|
sudo pacman -Rns --noconfirm iptables || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Install Kubernetes prerequisites and container runtime
|
||||||
sudo pacman -S --needed --noconfirm \
|
sudo pacman -S --needed --noconfirm \
|
||||||
ca-certificates \
|
ca-certificates \
|
||||||
curl \
|
curl \
|
||||||
wget \
|
wget \
|
||||||
docker \
|
containerd \
|
||||||
docker-buildx \
|
crictl \
|
||||||
docker-compose \
|
|
||||||
kubelet \
|
kubelet \
|
||||||
kubeadm \
|
kubeadm \
|
||||||
kubectl \
|
kubectl \
|
||||||
conntrack-tools \
|
conntrack-tools \
|
||||||
socat \
|
socat \
|
||||||
ebtables \
|
ethtool \
|
||||||
ethtool
|
iptables-nft \
|
||||||
|
cni-plugins
|
||||||
|
|
||||||
# Enable and start Docker daemon
|
# Enable and start containerd
|
||||||
sudo systemctl enable --now docker.service
|
sudo systemctl enable --now containerd.service
|
||||||
|
|
||||||
# Allow current user to run docker without sudo after next login
|
# Generate default containerd config if missing
|
||||||
if ! id -nG "$USER" | grep -qw docker; then
|
if [[ ! -f /etc/containerd/config.toml ]]; then
|
||||||
sudo usermod -aG docker "$USER"
|
sudo mkdir -p /etc/containerd
|
||||||
|
containerd config default | sudo tee /etc/containerd/config.toml >/dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Install bash aliases in a user-owned, Arch-friendly way
|
# Set SystemdCgroup = true for kubelet compatibility
|
||||||
if [[ -f .bash_aliases ]]; then
|
sudo sed -i 's/SystemdCgroup = false/SystemdCgroup = true/' /etc/containerd/config.toml
|
||||||
install -Dm644 .bash_aliases "$HOME/.bash_aliases"
|
sudo systemctl restart containerd
|
||||||
|
|
||||||
# Ensure ~/.bashrc loads ~/.bash_aliases
|
# Kernel modules for Kubernetes networking
|
||||||
if [[ -f "$HOME/.bashrc" ]] && ! grep -qF '.bash_aliases' "$HOME/.bashrc"; then
|
sudo tee /etc/modules-load.d/k8s.conf >/dev/null <<'EOF'
|
||||||
cat >> "$HOME/.bashrc" <<'EOF'
|
overlay
|
||||||
|
br_netfilter
|
||||||
# Load user aliases if present
|
|
||||||
if [[ -f ~/.bash_aliases ]]; then
|
|
||||||
. ~/.bash_aliases
|
|
||||||
fi
|
|
||||||
EOF
|
EOF
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
sudo modprobe overlay
|
||||||
|
sudo modprobe br_netfilter
|
||||||
|
|
||||||
|
# Sysctl settings required by Kubernetes
|
||||||
|
sudo tee /etc/sysctl.d/k8s.conf >/dev/null <<'EOF'
|
||||||
|
net.bridge.bridge-nf-call-iptables = 1
|
||||||
|
net.bridge.bridge-nf-call-ip6tables = 1
|
||||||
|
net.ipv4.ip_forward = 1
|
||||||
|
EOF
|
||||||
|
|
||||||
|
sudo sysctl --system
|
||||||
|
|
||||||
|
# Disable swap now
|
||||||
|
sudo swapoff -a
|
||||||
|
|
||||||
|
# Disable swap on boot by commenting swap lines in /etc/fstab
|
||||||
|
sudo sed -i.bak '/\sswap\s/s/^/#/' /etc/fstab
|
||||||
|
|
||||||
|
# Enable kubelet
|
||||||
|
sudo systemctl enable --now kubelet.service
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "Base Kubernetes packages are installed."
|
||||||
|
echo "Next step:"
|
||||||
|
echo " sudo kubeadm init --pod-network-cidr=10.244.0.0/16"
|
||||||
|
echo
|
||||||
|
echo "Then set up kubectl for your user:"
|
||||||
|
echo " mkdir -p \$HOME/.kube"
|
||||||
|
echo " sudo cp -i /etc/kubernetes/admin.conf \$HOME/.kube/config"
|
||||||
|
echo " sudo chown \$(id -u):\$(id -g) \$HOME/.kube/config"
|
||||||
|
echo
|
||||||
|
echo "Then install Flannel:"
|
||||||
|
echo " kubectl apply -f https://raw.githubusercontent.com/flannel-io/flannel/master/Documentation/kube-flannel.yml"
|
||||||
|
echo
|
||||||
|
echo "Check status with:"
|
||||||
|
echo " systemctl status containerd kubelet --no-pager"
|
||||||
|
echo " crictl info"
|
||||||
Loading…
Reference in New Issue