Master为:联想Y7000 (安装Ubuntu 22.04) Node为:Jetson Orin NX 16G (安装Ubuntu 20.04)

  • 安装Docker步骤(Steps for Installing Docker):
sudo apt-get remove docker docker-engine docker.io
sudo apt-get update
sudo apt install docker.io
sudo snap install docker
docker --version
  • 启用Docker
sudo systemctl enable docker
sudo systemctl start docker
sudo systemctl status docker
  • 安装K8S
sudo apt-get update
sudo apt-get install -y curl
sudo apt-get install -y ca-certificates curl
# 如果你使用 Debian 9(stretch)或更早版本,则你还需要安装 apt-transport-https:
sudo apt-get install -y apt-transport-https
# 在低于 Debian 12 和 Ubuntu 22.04 的发行版本中,/etc/apt/keyrings 默认不存在。 
# 如有需要,你可以创建此目录,并将其设置为对所有人可读,但仅对管理员可写。
sudo curl -fsSLo /etc/apt/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg
# or curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add
# or sudo apt-add-repository "deb http://apt.kubernetes.io/kubernetes-xenial main"
echo "deb [signed-by=/etc/apt/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update
sudo apt-get install -y kubeadm kubelet kubectl
  • 使用以下命令验证安装成功
kubeadm version
# 设置kubelet开机自启
systemctl enable kubelet
  • Kubernetes 部署
    首先禁用每台服务器上的交换内存:
sudo swapoff –a

Jetson Orin NX 彻底禁用Swap命令:

sudo systemctl disable nvzramconfig
  • 初始化Master
kubeadm init \
	--apiserver-advertise-address=192.168.50.82 \
	--service-cidr=10.96.0.0/12 \
	--pod-network-cidr=10.244.0.0/16 \
	--skip-phases=addon/kube-proxy 

可能遇到的问题

  1. [ERROR CRI]: container runtime is not running: output: time=“2023-03-27T21:53:12+08:00” level=fatal msg=“validate service connection: CRI v1 runtime API is not implemented for endpoint “unix:///var/run/containerd/containerd.sock”: rpc error: code = Unimplemented desc = unknown service runtime.v1.RuntimeService”
sudo apt install containerd.io
sudo rm -rf rm /etc/containerd/config.toml
systemctl restart containerd
  1. [kubelet-finalize] Updating “/etc/kubernetes/kubelet.conf” to point to a rotatable kubelet client certificate and key
    error execution phase addon/coredns: unable to create/update the DNS service: the server was unable to return a response in the time allotted, but may still be processing the request (put services kube-dns)

  2. master init失败后再次init报异常

sudo kubeadm reset

初始化master可以常见一个k8s_init.sh文件,执行这个文件,完成init

#!/bin/bash

sudo swapoff -a
sudo sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
sudo ufw disable
sudo kubeadm reset
sudo kubeadm init \
	--apiserver-advertise-address=147.8.67.170 \
	--image-repository registry.aliyuncs.com/google_containers \
	--kubernetes-version v1.26.3 \
	--pod-network-cidr=10.244.0.0/16 \
	--service-cidr=10.96.0.0/12 \
	--apiserver-bind-port 6443 \
	--token-ttl 0
  • admin.conf配置文件
mkdir -p $HOME/.kube
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
chown $(id -u):$(id -g) $HOME/.kube/config
  • 验证Master节点
kubectl get nodes

注意,最新版的k8s可能需要使用kubeadm-cinfig.yaml创建

  • 待添加

  • 安装kubeflannel

wget https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
kubectl  create -f kube-flannel.yml
kubectl apply -f kube-flannel.yml

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐