KubeEdge部署(一)


KubeEdge部署-雲端(cloud)

一.集群環境

主機名 角色 工作負載
cloud 雲端 K8s,docker,cloudcore
edge 邊緣端 docker,edgecore

二.系統配置

2.1網絡參數配置

cat >> /etc/hosts << EOF
# GitHub Start
52.74.223.119 github.com
192.30.253.119 gist.github.com
54.169.195.247 api.github.com
185.199.111.153 assets-cdn.github.com
151.101.76.133 raw.githubusercontent.com
151.101.108.133 user-images.githubusercontent.com
151.101.76.133 gist.githubusercontent.com
151.101.76.133 cloud.githubusercontent.com
151.101.76.133 camo.githubusercontent.com
151.101.76.133 avatars0.githubusercontent.com
151.101.76.133 avatars1.githubusercontent.com
151.101.76.133 avatars2.githubusercontent.com
151.101.76.133 avatars3.githubusercontent.com
151.101.76.133 avatars4.githubusercontent.com
151.101.76.133 avatars5.githubusercontent.com
151.101.76.133 avatars6.githubusercontent.com
151.101.76.133 avatars7.githubusercontent.com
151.101.76.133 avatars8.githubusercontent.com
# GitHub End
EOF

2.2關閉防火牆並禁用開機啟動

systemctl stop firewalld & systemctl disable firewalld

2.3永久禁用SELinux

sed -i 's/SELINUX=permissive/SELINUX=disabled/' /etc/sysconfig/selinux

2.4關閉swap分區

sed -ri 's/.*swap.*/#&/' /etc/fstab

三、安裝docker

3.1添加阿里雲docker倉庫

yum -y install yum-utils
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum makecache

3.2安裝docker

yum install docker-ce -y

3.3啟動Docker服務並激活開機啟動

systemctl start docker & systemctl enable docker

3.4測試docker

docker run hello-world

3.5添加docker國內鏡像加速

創建或修改 /etc/docker/daemon.json 文件,修改為如下形式

{
  "registry-mirrors": [
    "https://registry.docker-cn.com",
    "http://hub-mirror.c.163.com",
    "https://docker.mirrors.ustc.edu.cn"
  ]
}

重啟docker
systemctl restart docker

四、安裝k8s

4.1配置主機名並重啟

hostnamectl set-hostname cloud


reboot

4.2配置k8s的yum源

cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=http://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=0
repo_gpgcheck=0
gpgkey=http://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg http://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF

4.3安裝k8s組件

yum makecache

yum install -y kubelet kubeadm kubectl

systemctl enable kubelet

配置內核參數

cat <<EOF >  /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
vm.swappiness=0
EOF

sysctl --system
modprobe br_netfilter
sysctl -p /etc/sysctl.d/k8s.conf

加載ipvs相關內核模塊

modprobe ip_vs
modprobe ip_vs_rr
modprobe ip_vs_wrr
modprobe ip_vs_sh
modprobe nf_conntrack_ipv4

五、拉取鏡像

kubeadm config print init-defaults > kubeadm.conf

sed -i "s/imageRepository: .*/imageRepository: registry.aliyuncs.com\/google_containers/g" kubeadm.conf

kubeadm config images pull --config kubeadm.conf

六、初始化集群

kubeadm init \
--image-repository registry.aliyuncs.com/google_containers  \
--pod-network-cidr=10.244.0.0/16

七、進一步配置

mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

八、安裝網絡插件

mkdir -p /etc/cni/net.d

cat >/etc/cni/net.d/10-mynet.conf <<-EOF
{
    "cniVersion": "0.3.0",
    "name": "mynet",
    "type": "bridge",
    "bridge": "cni0",
    "isGateway": true,
    "ipMasq": true,
    "ipam": {
        "type": "host-local",
        "subnet": "10.244.0.0/16",
        "routes": [
            {"dst": "0.0.0.0/0"}
        ]
    }
}
EOF

cat >/etc/cni/net.d/99-loopback.conf <<-EOF
{
    "cniVersion": "0.3.0",
    "type": "loopback"
}
EOF

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

九、安裝golang

yum install wget -y
wget https://golang.google.cn/dl/go1.15.3.linux-amd64.tar.gz
tar zxvf go1.15.3.linux-amd64.tar.gz
mv go /usr/local/

vi /etc/profile在最結尾添加

export HOME=/root
export GOROOT=/usr/local/go
export GOPATH=/opt/idcus/go
export PATH=$PATH:$GOPATH/bin:$GOROOT/bin

source /etc/profile
go version #查看是否生效

十、安裝keadm

wget https://github.com/kubeedge/kubeedge/releases/download/v1.5.0/keadm-v1.5.0-linux-amd64.tar.gz

tar zxvf keadm-v1.5.0-linux-amd64.tar.gz 
cd keadm-v1.5.0-linux-amd64/keadm/
cp keadm /usr/local/sbin

十一、創建cloud節點

keadm init --advertise-address="ip地址" --kubeedge-version=版本號

keadm gettoken


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM