1. **apt 镜像配置,版本配置,网络方案**
镜像:vim /etc/apt/sources.list (把其他的deb 注释掉)
# 系统安装源
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
# kubeadm及kubernetes组件安装源
deb https://mirrors.aliyun.com/kubernetes/apt kubernetes-xenial main
版本:
Ubuntu :16.04
Docker :17.03.2-ce (apt默认安装版本)
Kubernates: v1.10.1
Kubeadm : 1.10.1-00
Kubelet : 1.10.1-00
Kubectl : 1.10.1-00
Flannel : v0.9.1-am64(网络方案)
镜像资源:
百度网盘:链接:https://pan.baidu.com/s/1kwDY99sXRiQtMGFSbnhO2A
提取码:h30v
二. 安装过程
1. 配置主机名映射 (这一步在后面kubelet 启动可以改变)
# cat /etc/hosts
127.0.0.1 localhost
192.168.116.134 master
192.168.116.135 worker01
192.168.116.137 worker02
2. 配置镜像
vim /etc/apt/sources.list
#系统安装源
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
# kubeadm及kubernetes组件安装源
deb https://mirrors.aliyun.com/kubernetes/apt kubernetes-xenial main
3. 更新apt源
apt-get update (不理会gpg 报错)
4. 安装docker
apt-get install docker.io
5. 加载镜像
docker load< XXX.tar
6. 强制安装kubeadm,kubectl,kubelet软件包 带上版本(否则会请求网络)
apt-get install -y kubelet=1.10.1-00 kubeadm=1.10.1-00 kubectl=1.10.1-00 --allow-unauthenticated
7. 更改节点名称,即hostname(重要)
cd /etc/systemd/system/kubelet.service.d/
vim 10-kubeadm.conf
8. 初始化节点
8.1 初始化主节点
kubeadm init --pod-network-cidr=10.244.0.0/16 --apiserver-advertise-address=192.168.116.134 --kubernetes-version=v1.10.1
8.2 初始化工作节点(由主节点初始化成功得到的语句)
kubeadm join 192.168.116.134:6443 --token hh2fvm.bxq1o057f0jun5x4 --discovery-token-ca-cert-hash sha256:71e3495a0142c7b3eb67d2f819b36c6c0ce4532b869f7ad29b90b1bfd989deeb
10. 加载网络插件 :Flannel(不用docker导包方式)
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/v0.9.1/Documentation/kube-flannel.yml
11. 验证成功