https://github.com/kubernetes/kubernetes/releases?after=v1.13.13-beta.0
下载网站
image.png 下载完修改名称解压文件
root@master:/usr/local/src/1.14.7# tar xf kubernetes-1.14.7-client-linux-amd64.tar.gz
root@master:/usr/local/src/1.14.7# tar xf kubernetes-1.14.7-node-linux-amd64.tar.gz
root@master:/usr/local/src/1.14.7# tar xf kubernetes-1.14.7-server-linux-amd64.tar.gz
root@master:/usr/local/src/1.14.7# tar xf kubernetes1.14.7.tar.gz
验证版本
root@master:/usr/local/src/1.14.7/kubernetes/server/bin# ./kube-controller-manager --version
Kubernetes v1.14.7
root@master:/usr/local/src/1.14.7/kubernetes/server/bin# ./kube-controller-manager version
I1125 04:41:18.489559 11396 serving.go:319] Generated self-signed cert in-memory
W1125 04:41:18.489711 1
root@master:/usr/local/src/1.14.7/kubernetes/server/bin# ./kube-controller-manager --version
Kubernetes v1.14.7
root@master:/usr/local/src/1.14.7/kubernetes/server/bin# ./kube-apiserver --version
Kubernetes v1.14.7
root@master:/usr/local/src/1.14.7/kubernetes/server/bin# ./kube-scheduler --version
Kubernetes v1.14.7
root@master:/usr/local/src/1.14.7/kubernetes/server/bin# ./kubelet --version
Kubernetes v1.14.7
root@master:/usr/local/src/1.14.7/kubernetes/server/bin# ./kube-proxy --version
Kubernetes v1.14.7
升级指定的节点,注意升级之前把指定节点的服务停掉,否则无法升级
root@master2:~# kubectl get nodes
查看node信息
192.168.200.197 Ready,SchedulingDisabled master 47h v1.13.5
root@master2:~# systemctl stop kubelet kube-proxy
停止服务
删除这个节点
root@master:/usr/local/src/1.14.7/kubernetes/server/bin# kubectl delete node 192.168.200.197
node "192.168.200.197" deleted
删除的时候会把他的pod移除到其他地方
root@master:/usr/local/src/1.14.7/kubernetes/server/bin# scp kubelet kube-proxy 192.168.200.197:/usr/bin
kubelet 100% 122MB 30.6MB/s 00:03
kube-proxy 100% 35MB 14.8MB/s 00:02
把命令拷贝过去
root@master2:~# systemctl start kubelet kube-proxy
在启动服务
查看是否升级了
root@master:/usr/local/src/1.14.7/kubernetes/server/bin# kubectl get node
NAME STATUS ROLES AGE VERSION
192.168.200.197 Ready <none> 17s v1.14.7
已经升级了
升级node节点
首先删除noode节点
root@master2:~# kubectl delete node 192.168.200.206
node "192.168.200.206" deleted
查看pod是否被删除的node节点影响
root@master2:~# kubectl get pod --all-namespaces
NAMESPACE NAME READY STATUS RESTARTS AGE
default busybox 0/1 ImagePullBackOff 8 23h
default net-test-cd766cb69-82tsl 1/1 Running 0 43s
default net-test-cd766cb69-p5tzp 0/1 ContainerCreating 0 38s
停止服务器
root@node1:/usr/bin# systemctl stop kubelet kube-proxy
拷贝升级的命令包
root@master:/usr/local/src/1.14.7/kubernetes/server/bin# scp kubelet kube-proxy 192.168.206:/usr/bin
root@node1:/usr/bin# chmod +xx kubelet
root@node1:/usr/bin# chmod +x kube-proxy
增加执行权限
root@node1:/usr/bin# systemctl restart kubelet kube-proxy
启动服务
root@master2:/usr/bin# kubectl get node
192.168.200.206 Ready <none> 9m38s v1.14.7
查看已经升级了
升级node2节点
root@master2:/usr/bin# kubectl delete node 192.168.200.207
node "192.168.200.207" deleted
root@node2:/usr/bin# systemctl stop kubelet kube-proxy
root@node2:/usr/bin# rm -rf kubelet kube-proxy
root@node2:/usr/bin# chmod +x kubelet kube-proxy
root@node2:/usr/bin# systemctl start kubelet kube-proxy
root@master2:/usr/bin# kubectl get node
NAME STATUS ROLES AGE VERSION
192.168.200.197 Ready <none> 54m v1.14.7
192.168.200.198 Ready,SchedulingDisabled master 2d v1.13.5
192.168.200.206 Ready <none> 27m v1.14.7
192.168.200.207 Ready <none> 0s v1.14.7
升级master节点 kubelet kube-proxy
先停止服务
root@master:/usr/local/src/1.14.7/kubernetes/server/bin# systemctl stop kubelet kube-proxy
拷贝命令到本机
root@master:/usr/local/src/1.14.7/kubernetes/server/bin# scp kubelet kube-proxy 192.168.200.198:/usr/bin
然后启动服务
root@master:/usr/local/src/1.14.7/kubernetes/server/bin# systemctl start kubelet kube-proxy
查看已经升级了
root@master:/usr/local/src/1.14.7/kubernetes/server/bin# kubectl get node
NAME STATUS ROLES AGE VERSION
192.168.200.197 Ready <none> 60m v1.14.7
192.168.200.198 Ready,SchedulingDisabled master 2d1h v1.14.7
192.168.200.206 Ready <none> 33m v1.14.7
192.168.200.207 Ready <none> 5m42s v1.14.7
master节点升级kube-apiserver kube-controller-manager kube-scheduler
停止服务
root@master:/usr/local/src/1.14.7/kubernetes/server/bin# systemctl stop kube-apiserver kube-controller-manager kube-scheduler
升级命令
root@master:/usr/local/src/1.14.7/kubernetes/server/bin# cp kube-apiserver kube-controller-manager kube-scheduler /usr/bin/
然后启动服务
root@master:/usr/local/src/1.14.7/kubernetes/server/bin# systemctl start kube-apiserver kube-controller-manager kube-scheduler
升级master2节点
停止服务
root@master2:/usr/bin# systemctl stop kube-apiserver kube-controller-manager kube-scheduler
拷贝命令
root@master:/usr/local/src/1.14.7/kubernetes/server/bin# scp kube-apiserver kube-controller-manager kube-scheduler 192.168.200.197:/usr/bin/
启动服务
root@master2:/usr/bin# systemctl start kube-apiserver kube-controller-manager kube-scheduler
做快照升级后k8s集群
然后恢复最初快照,使用二进制安装k8s
https://github.com/easzlab/kubeasz/tree/2.0.3
安装网站
https://github.com/easzlab/kubeasz/blob/2.0.3/docs/setup/00-planning_and_overall_intro.md
查看安装说明
服务器主名称设置
master 192.168.200.198 1.5g
master2 192.168.200.197 1.5g
node1 192.168.200.206 4g
node2 192.168.200.207 4g
harbor 192.168.200.200 1.5g
harbor2 192.168.200.199 1.5g
haproxy1 192.168.200.201 1.5g
etcd1 192.168.200.203 2g
etcd2 192.168.200.204 2g
etcd3 192.168.200.205 2g
克隆这个
master节点指定克隆的分支
git clone -b 2.0.3 https://github.com/easzlab/kubeasz.git
apt-get install python2.7 -y
安装python
ln -s /usr/bin/python2.7 /usr/bin/python
做个连接
主节点安装ansiable
root@master:~# apt install ansible -y
Ansible服务器免秘钥登录:
4.ansible服务器准备安装环境:
下载安装包并准备安装环境
4.1:下载安装包:
# apt update
# apt-get install python2.7 –y
# ln -s /usr/bin/python2.7 /usr/bin/python
Ansible服务器免秘钥登录
1 # apt install ansible
# ssh-keygen
apt install sshpass -y
root@master:~# cat scp.sh
#!/bin/bash
#目标主机列表
IP="
192.168.200.197
192.168.200.198
192.168.200.199
192.168.200.200
192.168.200.201
192.168.200.202
192.168.200.203
192.168.200.204
192.168.200.205
192.168.200.206
192.168.200.207
"
for node in ${IP};do
sshpass -p 123456 ssh-copy-id ${node} -o StrictHostKeyChecking=no
if [ $? -eq 0 ];then
echo "${node} 秘钥copy完成"
else
echo "${node} 秘钥copy失败"
fi
done
root@master:~# bash scp.sh
在master节点优化,其他节点的脚本
root@master:~# cat scp.sh | grep ^[^#]
IP="
192.168.200.197
192.168.200.203
192.168.200.204
192.168.200.205
192.168.200.206
192.168.200.207
"
for node in ${IP};do
scp docker-install.sh ${node}:/opt/
scp -r /etc/docker/certs.d ${node}:/etc/docker/
scp /etc/hosts ${node}:/etc/
scp /etc/sysctl.conf ${node}:/etc/
scp /etc/security/limits.conf ${node}:/etc/security/
ssh ${node} "reboot"
echo ${node},"重启成功"
done
ansible服务器准备安装环境:
下载安装包并准备安装环境
下载安装包
声明版本
root@master:~# export release=2.0.3
root@master:~# curl -C- -fLO --retry 3 https://github.com/easzlab/kubeasz/releases/download/${release}/easzup
下载安装包
修改版本
root@master:~# vim easzup
export DOCKER_VER=18.09.9
修改docker版本
export K8S_BIN_VER=v1.15.4
修改k8s的版本
root@master:~# chmod a+x easzup
加上执行权限
root@master:~# ./easzup -D
开始下载
支持的版本
查看已经下载的内容
root@master:/usr/local/src# ll /etc/ansible/down/
total 54960
drwxrwxr-x 2 root root 4096 Nov 25 10:24 ./
drwxrwxr-x 11 root root 4096 Aug 10 03:03 ../
-rw-r--r-- 1 root root 56262573 Nov 25 10:22 docker-18.09.9.tgz
-rw-rw-r-- 1 root root 1737 Aug 10 02:33 download.sh
-rw-rw-r-- 1 root root 1307 Aug 10 02:33 offline_images
root@master:/usr/local/src# docker images
查看下载的镜像
root@master:/usr/local/src# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
easzlab/kubeasz-k8s-bin v1.15.4 fdca5d355fb3 7 weeks ago 525MB
easzlab/kubeasz 2.0.3 baf72c8178d2 3 months ago 143MB
easzlab/kubeasz-sys-pkg 0.3.2 077b2185bae3 4 months ago 178MB
easzlab/kubeasz-ext-bin 0.3.0 dc2bb3cdf8a7 5 months ago 446MB
traefik v1.7.12 18471c10e6e4 5 months ago 71.7MB
mirrorgooglecontainers/metrics-server-amd64 v0.3.3 c6b5d3e48b43 6 months ago 39.9MB
coredns/coredns 1.5.0 7987f0908caf 7 months ago 42.5MB
calico/node v3.4.4 a8dbf15bbd6f 8 months ago 79.6MB
calico/cni v3.4.4 f5e5bae3eb87 8 months ago 75.4MB
calico/kube-controllers v3.4.4 0030ff291350 8 months ago 56.5MB
easzlab/flannel v0.11.0-amd64 ff281650a721 10 months ago 52.6MB
mirrorgooglecontainers/kubernetes-dashboard-amd64 v1.10.1 f9aed6605b81 11 months ago 122MB
mirrorgooglecontainers/heapster-amd64 v1.5.4 72d68eecf40c 16 months ago 75.3MB
mirrorgooglecontainers/pause-amd64 3.1 da86e6ba6ca1 23 months ago 742kB
root@master:~# cd /etc/ansible/
root@master:/etc/ansible# cp example/hosts.multi-node ./hosts
root@master:/etc/ansible# vim hosts
24 [ex-lb]
25 #192.168.200.201 LB_ROLE=backup EX_APISERVER_VIP=192.168.200.248 EX_APISERVER_PORT=8443
26 192.168.200.201 LB_ROLE=master EX_APISERVER_VIP=192.168.200.248 EX_APISERVER_PORT=8443
[etcd]
192.168.200.203 NODE_NAME=etcd1
192.168.200.204 NODE_NAME=etcd2
192.168.200.205 NODE_NAME=etcd3
# master node(s)
[kube-master]
192.168.200.198
192.168.200.197
# work node(s)
[kube-node]
192.168.200.207
192.168.200.206
32 [all:vars]
33 # --------- Main Variables ---------------
34 # Cluster container-runtime supported: docker, containerd
35 CONTAINER_RUNTIME="docker"
36
37 # Network plugins supported: calico, flannel, kube-router, cilium, kube-ovn
38 CLUSTER_NETWORK="calico"
39
40 # K8S Service CIDR, not overlap with node(host) networking
41 SERVICE_CIDR="10.20.0.0/16"
42
43 # Cluster CIDR (Pod CIDR), not overlap with node(host) networking
44 CLUSTER_CIDR="172.31.0.0/16"
45
46 # NodePort Range
47 NODE_PORT_RANGE="30000-65000"
54 bin_dir="/usr/bin"
网友评论