高可用K8S构建3master+3node+keepalived+haproxy (3)

高可用K8S构建3master+3node+keepalived+haproxy

 

vim data/lb/start-keepalived.sh

高可用K8S构建3master+3node+keepalived+haproxy

 

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

EOF

yum -y install kubeadm-1.15.1 kubectl-1.15.1 kubelet-1.15.1

systemctl enable kubelet.service

 

初始化主节点

mkdir images
mv * images/

cd images

kubeadm config print init-defaults > kubeadm-config.yaml

vim kubeadm-config.yaml

高可用K8S构建3master+3node+keepalived+haproxy

 

 

 

在master02 03创建目录

mkdir -p /usr/local/kubernetes/install/images

 

然后master01:

scp -r * root@k8s-master02:/usr/local/kubernetes/install/images

scp -r * root@k8s-master03:/usr/local/kubernetes/install/images

 

master01:

mv data/ /
cd /data/lb
ls

./start-haproxy.sh

netstat -antlup | grep 6444

高可用K8S构建3master+3node+keepalived+haproxy

./start-keepalived.sh

ip addr show

 

kubeadm init --config=kubeadm-config.yaml --experimental-upload-certs | tee kubeadm-init.log

高可用K8S构建3master+3node+keepalived+haproxy

 

mkdir -p $HOME/.kube

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

  

cat ~/.kube/config

可以这这里看到IP信息

高可用K8S构建3master+3node+keepalived+haproxy

  

kubectl get node

高可用K8S构建3master+3node+keepalived+haproxy

 

master02 03 

cd /usr/local/kubernetes/install/images

 

docker load -i haproxy.tar

docker load -i keepalived.tar

 

cat load-images.sh
#!/bin/bash

cd /usr/local/kubernetes/install/images/kubeadm-basic.images

ls /usr/local/kubernetes/install/images/kubeadm-basic.images | grep -v load-images.sh > /tmp/k8s-images.txt

for i in $( cat /tmp/k8s-images.txt )
do
docker load -i $i
done

rm -rf /tmp/k8s-images.txt

 

chmod a+x load-images.sh 
./load-images.sh

 

mv data/ /

cd /data/lb/

 

./start-haproxy.sh

netstat -antlup | grep 6444

高可用K8S构建3master+3node+keepalived+haproxy

./start-keepalived.sh

 

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

EOF
yum -y install kubeadm-1.15.1 kubectl-1.15.1 kubelet-1.15.1
systemctl enable kubelet.service

 

初始化主节点

cd /usr/local/kubernetes/install/images

 

vim kubeadm-config.yaml

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wpyzfd.html