Tip: If you have any problem, pls contact wechat yuanxi2314
and note your problem
1.Official FlashTools
2. Raspi 4B install RaspiOS
选择树莓派操作系统,并在右下角进行wifi及用户名配置
修改树莓派配置文件
在boot目录下新建sshd空白文件,使得linux允许ssh登录
3.set up root password and allow login by root
# 修改该文件添加 PermitRootLogin yes,如下图
nano /etc/ssh/sshd_config
# 修改root密码
sudo passwd root
systemctl restart sshd
# 重新登录即可使用root账户登录
4.connect your raspi through VNServer
vncserver
5. Raspi 4B install CentOS 7.9
5.1. download Raspi4B Image
5.2. Writing CentOS 7.9 Image into SD Card
then choose the SD Card and flash!
5.3. throwing error(if not, skip)
Solution:
Replace start4.elf and fixup4.dat
you can find here
download start4.elf and fixup4.elf
replace them in your SD Card
5.4. Start CentOS
默认账号: root
默认密码:centos
5.6 Expand Disk Space
rootfs-expand
df -h
5.5. Connect to Wifi
# syntax_error: 为wifi名称
nmcli dev wifi con "syntax_error" password "${password}"
nmcli con mod syntax_error ipv4.addresses 192.168.31.175/24
nmcli con mod syntax_error ipv4.gateway 192.168.31.1
nmcli con mod syntax_error ipv4.dns "192.168.31.1"
nmcli con mod syntax_error ipv4.method maunal
nmcli con up syntax_error
6. Raspi 4B install Kubernetes1.19.0
Question Found: Raspi armv71 CentOS7.9 cannot add kubernetes software source from aliyun or other source
key: armv71 兼容 arm32
6.1.Installing docker
yum install docker
6.2. Network Configuration
cat <<EOF | sudo tee /etc/modules-load.d/k8s.conf
overlay
br_netfilter
EOF
sudo modprobe overlay
sudo modprobe br_netfilter
# 设置所需的 sysctl 参数,参数在重新启动后保持不变
cat <<EOF | sudo 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 参数而不重新启动
sudo sysctl --system
yum install conntrack
6.3.Installing CNI plugin
Github CNI Plugins
Choose a cni that fit your system, like
curl https://github.com/containernetworking/plugins/releases/download/v1.1.1/cni-plugins-linux-arm-v1.1.1.tgz
rm -rf /opt/cni/bin
cd /opt/cni/bin
tar -zxvf cni-plugins-linux-arm-v1.1.1.tgz
6.4.Configuring Cgroup_memory and switch off swap
vim /boot/cmdline.txt
reboot
# wait for about 3-4minutes and relogin
swapoff -a
# annotate the swap part, see below
vim /etc/fstab
6.5.Download kubeadm kubelet kubectl
You can find your kubernetes version 1.19.0 tools in
Sotrage Google
or you can modify the kubernetes version to what you want.
# arm
wget https://storage.googleapis.com/kubernetes-release/release/v1.19.0/kubernetes-server-linux-arm.tar.gz
# amd64
wget https://storage.googleapis.com/kubernetes-release/release/v1.19.0/kubernetes-server-linux-amd64.tar.gz
# arm64
wget https://storage.googleapis.com/kubernetes-release/release/v1.19.0/kubernetes-server-linux-arm64.tar.gz
# ppc641e
wget https://storage.googleapis.com/kubernetes-release/release/v1.19.0/kubernetes-server-linux-ppc64le.tar.gz
# s390x
wget https://storage.googleapis.com/kubernetes-release/release/v1.19.0/kubernetes-server-linux-s390x.tar.gz
# for arm
tar -zxvf kubernetes-server-linux-arm.tar.gz
cp kubectl /usr/bin/
cp kubeadm /usr/bin/
cp kubelet /usr/bin/
kubectl version
kubeadm version
kubelet version
6.6.Configure kubelet
# create a system service for kubelet
cd /usr/lib/systemd/system
vim kubelet.service
[Unit]
Description=kubelet: The Kubernetes Node Agent
Documentation=https://kubernetes.io/docs/
Wants=network-online.target
After=network-online.target
[Service]
ExecStart=/usr/bin/kubelet
Restart=on-failure
[Install]
WantedBy=multi-user.target
# this dir will automatically recoginized as configuraion dir for kubelet.service
mkdir kubelet.service.d
cd kubelet.service.d
vim 10-kubeadm.conf
# Note: This dropin only works with kubeadm and kubelet v1.11+
[Service]
Environment="KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf"
Environment="KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml"
# This is a file that "kubeadm init" and "kubeadm join" generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically
EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env
# This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use
# the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file.
EnvironmentFile=-/etc/sysconfig/kubelet
ExecStart=
ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS
vim /var/lib/kubelet/kubeadm-flags.env
KUBELET_KUBEADM_ARGS="--network-plugin=cni --pod-infra-container-image=registry.aliyuncs.com/google_containers/pause:3.2 --cgroup-driver=systemd"
6.7. Start Kubeadm
kubeadm init --kubernetes-version=v1.19.0 --service-cidr=10.1.0.0/16 --pod-network-cidr=10.244.0.0/16 --v=10 --image-repository="registry.aliyuncs.com/google_containers
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
kubectl get node
wget https://raw.githubusercontent.com/flannel-io/flannel/master/Documentation/kube-flannel.yml -O flannel.yaml
docker pull docker.io/rancher/mirrored-flannelcni-flannel-cni-plugin:v1.1.0
kubectl apply -f flannel.yaml
7.Reference
Running CentOS on the Raspberry Pi
Raspberry Pi 4B 安装 CentOS 8(64bit)
CentOS-7 | Raspberry Pi 4 Install w/ Docker
安装和配置Kubernetes先决条件
Step 3: Installing CNI plugins
K8S 二进制安装文档