在线公有云服务器-云原生边缘计算KubeEdge安装配置(一)

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

1. 基础优化

#添加hosts:
cat >> /etc/hosts << EOF
117.78.45.55  cloudcore
117.78.45.56  edge-node1
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安装

#(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-20.10.20-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://rsbud4vc.mirror.aliyuncs.com","https://registry.docker-cn.com","https://docker.mirrors.ustc.edu.cn","https://dockerhub.azk8s.cn","http://hub-mirror.c.163.com","http://qtid6917.mirror.aliyuncs.com", "https://rncxm540.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安装

#添加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.6-0 kubeadm-1.22.6-0 kubectl-1.22.6-0
systemctl enable kubelet

4. 部署Kubernetes k8s-master

kubeadm init --apiserver-advertise-address=117.78.45.55  --image-repository registry.aliyuncs.com/google_containers --kubernetes-version v1.22.6 --service-cidr=10.96.0.0/12  --pod-network-cidr=10.244.0.0/16 --ignore-preflight-errors=all #这里的117.78.44.202是主机cloudcore的公网IP,运行中出现了如下图的结果,提示超时

在这里插入图片描述

#图片中出现的问题的处理方式:
#解决办法是在卡住时,另启一个命令行窗口修改初始化生成的 etcd.yaml 中的配置成示例图一样,进程会自动重试并初始化成功。
vim /etc/kubernetes/manifests/etcd.yaml
    - --listen-client-urls=https://0.0.0.0:2379  #这行IP修改为0.0.0.0
    - --listen-metrics-urls=http://127.0.0.1:2381
    - --listen-peer-urls=https://0.0.0.0:2380    #这行IP修改为0.0.0.0

正确修改后的结果如下图:

在这里插入图片描述

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)

kubectl apply -f  calico.yaml  #这个文件单独发你了

6. 取消污点

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.补全命令

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 集群

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

9. 部署k8s dashboard(这里使用Kubepi)

部署请参考

第二. kubeedge安装

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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

qq_14910065

你的支持是我最大的努力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值