AlmaLinux 9.5 Minikube单节点K8s部署指南

1. 加载内核模块和设置内核参数

cat <<EOF | tee /etc/modules-load.d/k8s.conf
overlay
br_netfilter
EOF

modprobe overlay
modprobe br_netfilter

cat <<EOF | tee /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.ipv4.ip_forward = 1
EOF

sysctl --system

2. 安装docker

dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
dnf install -y docker-ce docker-ce-cli containerd.io

mkdir -p /etc/docker
cat <<EOF | tee /etc/docker/daemon.json
{
    "registry-mirrors": [
        "https://docker.registry.cyou",
        "https://docker-cf.registry.cyou",
        "https://dockercf.jsdelivr.fyi",
        "https://docker.jsdelivr.fyi",
        "https://dockertest.jsdelivr.fyi",
        "https://mirror.aliyuncs.com",
        "https://dockerproxy.com",
        "https://mirror.baidubce.com",
        "https://docker.m.daocloud.io",
        "https://docker.nju.edu.cn",
        "https://docker.mirrors.sjtug.sjtu.edu.cn",
        "https://docker.mirrors.ustc.edu.cn",
        "https://mirror.iscas.ac.cn",
        "https://docker.rainbond.cc"
    ]
}
EOF

systemctl enable docker --now

3. 安装cri-dockerd

wget https://github.com/Mirantis/cri-dockerd/releases/download/v0.3.4/cri-dockerd-0.3.4.amd64.tgz
tar -xvf cri-dockerd-0.3.4.amd64.tgz
install -o root -g root -m 0755 cri-dockerd/cri-dockerd /usr/local/bin/

wget https://raw.githubusercontent.com/Mirantis/cri-dockerd/master/packaging/systemd/cri-docker.service
wget https://raw.githubusercontent.com/Mirantis/cri-dockerd/master/packaging/systemd/cri-docker.socket
sed -i 's|/usr/bin/cri-dockerd|/usr/local/bin/cri-dockerd|' cri-docker.service
mv cri-docker.* /etc/systemd/system/

systemctl daemon-reload
systemctl enable cri-docker.service --now

4.安装crictl与cni-plugins

wget https://github.com/kubernetes-sigs/cri-tools/releases/download/v1.28.0/crictl-v1.28.0-linux-amd64.tar.gz
tar -xvf crictl-v1.28.0-linux-amd64.tar.gz
install -o root -g root -m 0755 crictl /usr/local/bin/

CNI_PLUGIN_VERSION="v1.6.0"
CNI_PLUGIN_TAR="cni-plugins-linux-amd64-$CNI_PLUGIN_VERSION.tgz"
CNI_PLUGIN_INSTALL_DIR="/opt/cni/bin"
curl -LO "https://github.com/containernetworking/plugins/releases/download/$CNI_PLUGIN_VERSION/$CNI_PLUGIN_TAR"
sudo mkdir -p "$CNI_PLUGIN_INSTALL_DIR"
sudo tar -xf "$CNI_PLUGIN_TAR" -C "$CNI_PLUGIN_INSTALL_DIR"

5. 安装kubectl和minikube

curl -LO https://dl.k8s.io/release/v1.28.0/bin/linux/amd64/kubectl
install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl

curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
install -o root -g root -m 0755 minikube-linux-amd64 /usr/local/bin/minikube

kubectl version --client
minikube version

6. 解决containerd硬编码pause镜像的问题

docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/pause:3.6
docker tag  registry.cn-hangzhou.aliyuncs.com/google_containers/pause:3.6 registry.k8s.io/pause:3.6
docker save registry.k8s.io/pause -o pause.tar
ctr images import pause.tar

7. 启动minikube集群

minikube start --kubernetes-version=v1.28.0 --driver=none \
--container-runtime=docker \
--cri-socket=/var/run/cri-dockerd.sock \
--image-mirror-country='cn'

minikube status
kubectl get nodes -o wide

8. 其他

minikube addons enable dashboard

yum install bash-completion -y
source /usr/share/bash-completion/bash_completion
kubectl completion bash > /etc/bash_completion.d/kubectl
source /etc/bash_completion.d/kubectl
posted @ 2025-03-29 01:18  wanghongwei-dev  阅读(118)  评论(0)    收藏  举报