在线云原生边缘计算KubeEdge安装配置(一)

第一安装K8S集群(这里是单节点集群)

1. 基础优化

bash 复制代码
#添加hosts:
cat >> /etc/hosts << EOF
114.115.220.147  cloudcore
101.44.64.2    edgecore01
EOF

hostnamectl set-hostname cloudcorer  && bash
#关闭防火墙:
systemctl stop firewalld
systemctl disable firewalld
#关闭selinux:
sed -i 's/enforcing/disabled/' /etc/selinux/config # 永久
setenforce 0 # 临时
#关闭swap:
swapoff -a # 临时
sed -i 's/.*swap.*/#&/' /etc/fstab # 永久

cat > /etc/sysctl.d/k8s.conf << EOF
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-iptables=1
net.bridge.bridge-nf-call-ip6tables=1
net.ipv4.ip_forward=1
net.ipv4.tcp_tw_recycle=0
vm.swappiness=0
vm.overcommit_memory=1
vm.panic_on_oom=0
fs.inotify.max_user_instances=8192
fs.inotify.max_user_watches=1048576
fs.file-max=52706963
fs.nr_open=52706963
net.ipv6.conf.all.disable_ipv6=1
net.netfilter.nf_conntrack_max=2310720         
EOF
sysctl --system

#时间同步:
yum install ntpdate -y
ntpdate time.windows.com

2. docker安装

bash 复制代码
#(1)安装Docker
yum -y install epel-release wget
wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo -O /etc/yum.repos.d/docker-ce.repo
#yum -y install docker-ce-18.06.3.ce-3.el7 #安装docker最新版 后面安装kubernetes的v1.20.5
yum -y install docker-ce  #安装docker最新版
systemctl enable docker && systemctl start docker && systemctl status docker
docker --version
#(2)添加阿里云YUM 软件源
#设置仓库地址
cat > /etc/docker/daemon.json << EOF
{
  "registry-mirrors": ["https://qj799ren.mirror.aliyuncs.com"],
  "exec-opts": ["native.cgroupdriver=systemd"],
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "100m"
  },
  "storage-driver": "overlay2"
}
EOF

systemctl restart docker &&  systemctl status docker
docker --version

3. kubeadm kubectl kubelet安装

bash 复制代码
#添加yum 源
cat > /etc/yum.repos.d/kubernetes.repo << EOF
[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=0
repo_gpgcheck=0
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF

#安装kubeadm,kubelet 和kubectl
yum clean all && yum makecache -y
# yum list kubectl --showduplicates | sort -r #列出kubectl可用的版本


yum -y install kubelet-1.22.2-0 kubeadm-1.22.2-0 kubectl-1.22.2-0
systemctl enable kubelet

4. 部署Kubernetes k8s-master

bash 复制代码
kubeadm init --apiserver-advertise-address=114.115.220.147  --image-repository registry.aliyuncs.com/google_containers --kubernetes-version v1.22.2 --service-cidr=10.96.0.0/12  --pod-network-cidr=10.244.0.0/16 --ignore-preflight-errors=all
bash 复制代码
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

5. 安装Pod 网络插件(CNI)

bash 复制代码
kubectl apply -f  calico.yaml  #这个文件单独发你了

6. 取消污点

bash 复制代码
kubectl taint nodes --all node-role.kubernetes.io/control-plane- #执行这句就行,就是取消污点
kubectl taint nodes --all node-role.kubernetes.io/master-

kubectl get no -o yaml | grep taint -A 5  #再次查看,无显示,说明污点去除成功

7.补全命令

bash 复制代码
rpm -aq |grep completion  
yum -y install bash-completion  #安装补全命令的包
kubectl completion bash
source /usr/share/bash-completion/bash_completion
kubectl completion bash >/etc/profile.d/kubectl.sh
source /etc/profile.d/kubectl.sh
cat >> /root/.bashrc << EOF
source /etc/profile.d/kubectl.sh
EOF

8. 测试kubernetes 集群

bash 复制代码
kubectl create deployment nginx --image=nginx
kubectl expose deployment nginx --port=80 --type=NodePort
kubectl get pod,svc -o wide
# 浏览器利用IP:端口访问

第二. kubeedge安装

请继续从2步开始安装执行就行

相关推荐
伏小白白白1 小时前
【论文精度-2】求解车辆路径问题的神经组合优化算法:综合展望(Yubin Xiao,2025)
人工智能·算法·机器学习
应用市场1 小时前
OpenCV编程入门:从零开始的计算机视觉之旅
人工智能·opencv·计算机视觉
星域智链1 小时前
宠物智能用品:当毛孩子遇上 AI,是便利还是过度?
人工智能·科技·学习·宠物
taxunjishu1 小时前
DeviceNet 转 MODBUS TCP罗克韦尔 ControlLogix PLC 与上位机在汽车零部件涂装生产线漆膜厚度精准控制的通讯配置案例
人工智能·区块链·工业物联网·工业自动化·总线协议
说私域2 小时前
基于多模态AI技术的传统行业智能化升级路径研究——以开源AI大模型、AI智能名片与S2B2C商城小程序为例
人工智能·小程序·开源
囚生CY2 小时前
【速写】优化的深度与广度(Adam & Moun)
人工智能·python·算法
hqyjzsb2 小时前
2025年市场岗位能力重构与跨领域转型路径分析
c语言·人工智能·信息可视化·重构·媒体·改行学it·caie
爱学习的uu2 小时前
CURSOR最新使用指南及使用思路
人工智能·笔记·python·软件工程
早睡冠军候选人2 小时前
Ansible学习----Ansible Playbook
运维·服务器·学习·云原生·容器·ansible
叶凡要飞2 小时前
RTX5060Ti安装双系统ubuntu22.04各种踩坑点(黑屏,引导区修复、装驱动、server版本安装)
人工智能·python·yolo·ubuntu·机器学习·操作系统