本文共 3685 字,大约阅读时间需要 12 分钟。
2018/1/4
### k8s master @envDev10.10.9.67 tvm-0010.10.9.68 tvm-0110.10.9.69 tvm-02
10.10.9.74 tvm-03
10.10.9.75 tvm-0410.10.9.76 kubernetes.default.svc.cluster.local
- docker```bashyum -y install yum-utilsyum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repoyum makecache fastyum -y install docker-ce-17.09.1.ce-1.el7.centos.x86_64systemctl enable dockermkdir -p /data2/dockermkdir -p /etc/dockertee /etc/docker/daemon.json <<-'EOF'{ "exec-opts": ["native.cgroupdriver=cgroupfs"], "graph": "/data2/docker", "storage-driver": "overlay", "log-driver": "json-file", "log-opts": { "max-size": "100m" }, "registry-mirrors": ["https://xxx.mirror.aliyuncs.com"]}EOF
cat <<'_EOF' > /etc/sysctl.d/k8s.confnet.bridge.bridge-nf-call-ip6tables = 1net.bridge.bridge-nf-call-iptables = 1_EOFsysctl --system
docker load -i gcr.io-worker.tar
docker load -i calico-worker.tar[root@tvm-03 ~]# cd ~/k8s_install/k8s_rpms_1.9
[root@tvm-03 k8s_rpms_1.9]# lskubelet-1.9.0-0.x86_64.rpm kubernetes-cni-0.6.0-0.x86_64.rpm socat-1.7.3.2-2.el7.x86_64.rpmyum localinstall *.rpm -y
sed -i 's#--cgroup-driver=systemd#--cgroup-driver=cgroupfs#' /etc/systemd/system/kubelet.service.d/10-kubeadm.confsystemctl daemon-reload##### 加入集群```bash### 在 mater 上重新生成 token (如果过期了的话)kubeadm join --token 9db9dd.09bd5226fb3f259c 10.10.9.67:6443 --discovery-token-ca-cert-hash sha256:42cfdc412e731793ce2fa20aad1d8163ee8e6e5c05c30765f204ff086823c653### 在 master 上查看节点是否加入[root@tvm-00 ~]# kubectl get nodesNAME STATUS ROLES AGE VERSIONtvm-00 Ready master 12d v1.9.0tvm-01 Ready8d v1.9.0tvm-02 Ready 8d v1.9.0tvm-03 Ready 30m v1.9.0tvm-04 Ready 29m v1.9.0
sed -i 's#https://10.10.9.67:6443#https://kubernetes.default.svc.cluster.local:6443#' /etc/kubernetes/kubelet.confsystemctl restart kubelet### 验证一下[root@tvm-03 k8s_install]# ss -antp4 |grep ':6443'ESTAB 0 0 10.10.9.74:56118 10.10.9.76:6443 users:(("kubelet",pid=21260,fd=12))ESTAB 0 0 10.10.9.74:53204 10.10.9.67:6443 users:(("kube-proxy",pid=15834,fd=5))### 符合预期
### 当前状态[root@tvm-00 ~]# kubectl describe nodes/tvm-00 |grep -E '(Roles|Taints)'Roles: masterTaints: node-role.kubernetes.io/master:NoSchedule[root@tvm-00 ~]# kubectl describe nodes/tvm-01 |grep -E '(Roles|Taints)'Roles:Taints: ### 设置 tvm-01 为 master 且不允许调度[root@tvm-00 ~]# kubectl label node tvm-01 node-role.kubernetes.io/master=node "tvm-01" labeled[root@tvm-00 ~]# kubectl taint nodes tvm-01 node-role.kubernetes.io/master=:NoSchedulenode "tvm-01" tainted### 符合预期[root@tvm-00 ~]# kubectl describe nodes/tvm-01 |grep -E '(Roles|Taints)'Roles: masterTaints: node-role.kubernetes.io/master:NoSchedule### 设置 tvm-02 为 master 且不允许调度(操作类似,略)[root@tvm-00 ~]# kubectl get nodesNAME STATUS ROLES AGE VERSIONtvm-00 Ready master 12d v1.9.0tvm-01 Ready master 8d v1.9.0tvm-02 Ready master 8d v1.9.0tvm-03 Ready 1h v1.9.0tvm-04 Ready 1h v1.9.0
转载于:https://blog.51cto.com/nosmoking/2062899