kubernetes1.6 +flannel 网络安装

注意:本文不适合小白,适合有搭建经验的人
必须要在/etc/hosts 内加入各个机器的dns解析,docker最好为1.12版本
1.yum源http://yum.kubernetes.io/repos/kubernetes-el7-x86_64-unstable
如不可用可留言,我有下载好的rpm包

2.docker search xuejipeng 自己拉取镜像相关镜像,并修改为如下名称
如果拉取太慢 可以看我之前的docker加速的文章
kubernetes1.6 +flannel 网络安装_第1张图片

3.yum install -y kubelet kubeadm kubectl kubernetes-cni docker socat

4.在/etc/systemd/system/kubelet.service.d/10-kubeadm.conf 加上

--cgroup-driver=systemd

否则会有错误
error: failed to run Kubelet: failed to create kubelet: misconfiguration: kubelet cgroup driver: “cgroupfs” is different from docker cgroup driver: “syste
md”

5.systemctl enable kubelet && systemctl start kubelet
在 /etc/sysctl.conf 加入net.ipv4.ip_forward=1 保存
sysctl -p 重新加载

6.初始化kubeadm init –pod-network-cidr 10.244.0.0/16 –apiserver-advertise-address YOU-IP

7.执行命令 否则会提示
The connection to the server localhost:8080 was refused - did you specify the right host or port?

cp /etc/kubernetes/admin.conf $HOME/
sudo chown $(id -u):$(id -g) $HOME/admin.conf
export KUBECONFIG=$HOME/admin.conf

或者

kubectl proxy --port=8080 & 手动开启8080端口

8.创建flannel网络 1.6开始 必须要增加rbac权限 否则flannel会报错
the server does not allow access to the requested resource (get pods kube-flannel-ds-xxxx)

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

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

9.加入子节点

kubeadm join –token

10.设置仪表盘
kubectl create -f https://rawgit.com/kubernetes/dashboard/master/src/deploy/kubernetes-dashboard.yaml
UI界面提示 forbden(403)这是一个bug 下个版本会修复
在命令行执行

kubectl create clusterrolebinding add-on-cluster-admin –clusterrole=cluster-admin –serviceaccount=kube-system:default

你可能感兴趣的:(kubernetes)