kubernetes v1.24.7 + docker

1. 背景

采用containerd作为容器运行时发现集群总是不稳定,因此切换成了docker 作为容器运行时;

shell 复制代码
root@orangepi3b:~# uname -a
Linux orangepi3b 5.10.160-rockchip-rk356x #1.0.2 SMP Thu Sep 21 17:07:22 CST 2023 aarch64 aarch64 aarch64 GNU/Linux

2. 安装docker

shell 复制代码
apt-get update
    # apt-get install -y docker.io
    apt-get install -y ca-certificates curl gnupg lsb-release
    mkdir -p /etc/apt/keyrings
    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
    echo \
    "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
    $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
    apt-get update
    apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
    systemctl enable docker
    systemctl status docker
    cat /etc/docker/daemon.json 

3. 安装cri-dockerd

若发现release下没有你的cpu架构的版本,参考 自己动手打包构建编译cri-dockerd

shell 复制代码
wget https://github.com/Mirantis/cri-dockerd/releases/download/v0.3.7/cri-dockerd-0.3.7.arm64.tgz

tar -zxvf cri-dockerd-0.3.7.arm64.tgz 

install -o root -g root -m 0755 cri-dockerd/cri-dockerd /usr/bin/cri-dockerd

cri-dockerd --version
shell 复制代码
vim /etc/systemd/system/cri-docker.service
[Unit]
Description=CRI Interface for Docker Application Container Engine
Documentation=https://docs.mirantis.com
After=network-online.target firewalld.service docker.service
Wants=network-online.target
Requires=cri-docker.socket

[Service]
Type=notify
ExecStart=/usr/local/bin/cri-dockerd --pod-infra-container-image=registry.aliyuncs.com/google_containers/pause:3.8 --container-runtime-endpoint fd:// --network-plugin=cni --cni-bin-dir=/opt/cni/bin --cni-cache-dir=/var/lib/cni/cache --cni-conf-dir=/etc/cni/net.d
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutSec=0
RestartSec=2
Restart=always
StartLimitBurst=3
StartLimitInterval=60s
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
TasksMax=infinity
Delegate=yes
KillMode=process

[Install]
WantedBy=multi-user.target
shell 复制代码
vim /etc/systemd/system/cri-docker.socket
[Unit]
Description=CRI Docker Socket for the API
PartOf=cri-docker.service

[Socket]
ListenStream=%t/cri-dockerd.sock
SocketMode=0660
SocketUser=root
SocketGroup=docker

[Install]
WantedBy=sockets.target
shell 复制代码
systemctl daemon-reload && systemctl enable cri-docker --now && systemctl status cri-docker

4. 安装kubernetes

4.1. 安装critical & conntrack

shell 复制代码
wget https://github.com/kubernetes-sigs/cri-tools/releases/download/v1.28.0/crictl-v1.28.0-linux-arm64.tar.gz
tar -zxvf crictl-v1.28.0-linux-arm64.tar.gz 
ln -s $(pwd)/crictl /usr/bin/crictl

apt install conntrack
shell 复制代码
wget https://storage.googleapis.com/kubernetes-release/release/v1.24.7/kubernetes-server-linux-arm64.tar.gz
tar -zxvf kubernetes-server-linux-arm64.tar.gz

ln -s $(pwd)/kubernetes/server/bin/kubectl /usr/bin/kubectl
ln -s $(pwd)k8s/kubernetes/server/bin/kubeadm /usr/bin/kubeadm
ln -s $(pwd)k8s/kubernetes/server/bin/kubelet /usr/bin/kubelet

# 关闭交换区
swapoff -a

cat <<EOF > /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
EOF
sysctl -p /etc/sysctl.d/k8s.conf
shell 复制代码
mkdir -p /etc/systemd/system/kubelet.service.d
vim /etc/systemd/system/kubelet.service 
[Unit]
Description=kubelet: The Kubernetes Node Agent
Documentation=https://kubernetes.io/docs/home/
Wants=network-online.target
After=network-online.target

[Service]
ExecStart=/usr/bin/kubelet
Restart=always
StartLimitInterval=0
RestartSec=10

[Install]
WantedBy=multi-user.target
# 主节点指定CRI
kubeadm init --kubernetes-version=v1.24.6 --service-cidr=10.1.0.0/16 --pod-network-cidr=10.244.0.0/16 --v=10 --image-repository="registry.aliyuncs.com/google_containers" --cri-socket unix:///var/run/cri-dockerd.sock


# 从节点
kubeadm join 192.168.31.66:6443 --token tv23l5.oou0arvmwf8bk7y2  --discovery-token-ca-cert-hash sha256:80d0d1454560d3a486df4ed7eaeb530feb8c72ba9d498a56b16d65cee0b6fc39 --cri-socket unix:///var/run/cri-dockerd.sock
相关推荐
景天科技苑2 小时前
【云原生开发】K8S多集群资源管理平台架构设计
云原生·容器·kubernetes·k8s·云原生开发·k8s管理系统
wclass-zhengge3 小时前
K8S篇(基本介绍)
云原生·容器·kubernetes
颜淡慕潇3 小时前
【K8S问题系列 |1 】Kubernetes 中 NodePort 类型的 Service 无法访问【已解决】
后端·云原生·容器·kubernetes·问题解决
川石课堂软件测试5 小时前
性能测试|docker容器下搭建JMeter+Grafana+Influxdb监控可视化平台
运维·javascript·深度学习·jmeter·docker·容器·grafana
昌sit!11 小时前
K8S node节点没有相应的pod镜像运行故障处理办法
云原生·容器·kubernetes
追风林12 小时前
mac 本地docker-mysql主从复制部署
mysql·macos·docker
A ?Charis14 小时前
Gitlab-runner running on Kubernetes - hostAliases
容器·kubernetes·gitlab
城南vision14 小时前
Docker学习—Docker核心概念总结
java·学习·docker
wclass-zhengge14 小时前
Docker篇(Docker Compose)
运维·docker·容器
北漂IT民工_程序员_ZG15 小时前
k8s集群安装(minikube)
云原生·容器·kubernetes