V1.11.1
https://github.com/kubernetes/kubernetes/releases/tag/v1.11.1
环境准备:
系统:centos7.2.1511
[root@master ~]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)

关闭防火墙,iptalbes,firewalld设置时间同步
systemctl stop iptalbes
systemctl disable iptalbes

systemctl stop firewalld
systemctl disable firewalld

禁用SELINUX:

setenforce 0

修改selinux
vim /etc/selinux/config文件
SELINUX=disabled

改主机名:
~]# hostnamectl set-hostname master
修改hosts
[root@master ~]# vim /etc/hosts
172.20.0.70 master
172.20.0.66 node1
172.20.0.67 node2


master:

[root@master~]# cd /etc/yum.repos.d/
下载阿里云docker-ce.repo
[root@server yum.repos.d]# wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

配置k8s repo
[root@master yum.repos.d]# vim kubernetes.repo
[kubernetes]
name=kubernetes repo
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kuberne
tes-el7-x86_64/
gpgcheck=0
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
enabled=1
[root@master yum.repos.d]#yum repolist

[root@master ~]# wget https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
[root@master ~]# rpm --import rpm-package-key.gpg
[root@master ~]# wget https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
[root@master ~]# rpm --import yum-key.gpg

===============================
安装docker-ce kubelet kubeadm kubectl
[root@master yum.repos.d]# yum install docker-ce kubelet kubeadm kubectl

配置docker服务
[root@master yum.repos.d]# vim /usr/lib/systemd/system/docker.service

[Service]
Environment="HTTPS_PROXY=http://www.ik8s.io:10080"
Environment="NO_PROXY=127.0.0.0/8,172.20.0.0/16"
[root@server yum.repos.d]# systemctl daemon-reload

[root@master yum.repos.d]# systemctl start docker.service
[root@master yum.repos.d]# docker info

验证itables桥是否为1

[root@master ~]# cat /proc/sys/net/bridge/bridge-nf-call-ip6tables
[root@master ~]# cat /proc/sys/net/bridge/bridge-nf-call-iptables

如不为1,则在/etc/sysctl.conf中添加:

net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1

执行sysctl -p 时出现:
[root@localhost ~]# sysctl -p
sysctl: cannot stat /proc/sys/net/bridge/bridge-nf-call-ip6tables: No such file or directory
sysctl: cannot stat /proc/sys/net/bridge/bridge-nf-call-iptables: No such file or directory
解决方法:

[root@localhost ~]# modprobe br_netfilter
[root@localhost ~]# sysctl -p
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1

自启动kubelet,docker
[root@master ~]# systemctl enable kubelet.service
root@master ~]# systemctl enable docker.service

启动kubelet,docker
[root@master ~]# systemctl start kubelet.service
root@master ~]# systemctl start docker.service

忽略swap报错
[root@master ~]# vim /etc/sysconfig/kubelet
KUBELET_EXTRA_ARGS="--fail-swap-on=false"

初始化kubeadm
[root@master ~]# kubeadm init --kubernetes-version=v1.11.1 --pod-network-cidr=10.244.0.0/16 --service-cidr=10.96.0.0/12 --ignore-preflight-errors=Swap

kubeadm join 172.20.0.70:6443 --token dis2yz.m446ryn2lr298ica --discovery-token-ca-cert-hash sha256:c59f3633ecb92a31d86f64dc304abea55176555afbb3f2af9f40e5d4e013f86b

[root@master ~]# docker image ls

检测端口是否启动
[root@master ~]# ss -tnl | grep 6443

[root@master ~]# mkdir -p $HOME/.kube
[root@master ~]# cp -i /etc/kubernetes/admin.conf $HOME/.kube/config

[root@master ~]# kubectl get cs
NAME STATUS MESSAGE ERROR
scheduler Healthy ok
etcd-0 Healthy {"health": "true"}
controller-manager Healthy ok
[root@master ~]# kubectl get componentstatus
NAME STATUS MESSAGE ERROR
scheduler Healthy ok
controller-manager Healthy ok
etcd-0 Healthy {"health": "true"}
[root@master ~]# kubectl get nodes
NAME STATUS ROLES AGE VERSION
master NotReady master 32m v1.11.2

部署flannel网络插件
[root@master ~]# kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml

检测flannel
[root@master ~]# kubectl get pods -n kube-system
NAME READY STATUS RESTARTS AGE
coredns-78fcdf6894-4smdl 1/1 Running 58 20h
coredns-78fcdf6894-tlklk 1/1 Running 55 20h
etcd-master 1/1 Running 4 19h
kube-apiserver-master 1/1 Running 54 19h
kube-controller-manager-master 1/1 Running 9 19h
kube-flannel-ds-amd64-ds7x5 1/1 Running 2 19h
kube-proxy-tsxvp 1/1 Running 2 20h
kube-scheduler-master 1/1 Running 7 19h

[root@master ~]# kubectl get ns
NAME STATUS AGE
default Active 20h
kube-public Active 20h
kube-system Active 20h

master部署完毕

nodes节点
复制repo至node1,node2
[root@master ~]# scp /etc/hosts node1:/etc/hosts
[root@master ~]# scp /etc/hosts node2:/etc/hosts
[root@master yum.repos.d]# scp docker-ce.repo kubernetes.repo node1:/etc/yum.repos.d/
[root@master yum.repos.d]# scp docker-ce.repo kubernetes.repo node2:/etc/yum.repos.d/
[root@master ~]# scp rpm-package-key.gpg node1:/root
[root@master ~]# scp rpm-package-key.gpg node2:/root


node1:
[root@node1 # rpm --import rpm-package-key.gpg
[root@node1 #yum repolist
[root@node1# yum install docker-ce kubelet kubeadm -y

复制master配置至node1

[root@master ~]# scp /usr/lib/systemd/system/docker.service node1:/usr/lib/systemd/system/docker.service
[root@master ~]# scp /etc/sysconfig/kubelet node1:/etc/sysconfig/kubelet
[root@master ~]# scp /etc/sysctl.conf node1:/etc/sysctl.conf
验证itables桥是否为1

[root@master ~]# cat /proc/sys/net/bridge/bridge-nf-call-ip6tables
[root@master ~]# cat /proc/sys/net/bridge/bridge-nf-call-iptables

如不为1,则在/etc/sysctl.conf中添加:

net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1

执行sysctl -p 时出现:
[root@localhost ~]# sysctl -p
sysctl: cannot stat /proc/sys/net/bridge/bridge-nf-call-ip6tables: No such file or directory
sysctl: cannot stat /proc/sys/net/bridge/bridge-nf-call-iptables: No such file or directory
解决方法:

[root@localhost ~]# modprobe br_netfilter
[root@localhost ~]# sysctl -p
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1

[root@node1 ~]# systemctl start docker kubelet
[root@node1 ~]# systemctl enable docker kubelet
[root@master ~]# scp /etc/sysctl.conf node2:/etc/sysctl.conf
[root@node1 ~]# kubeadm join 172.20.0.70:6443 --token dis2yz.m446ryn2lr298ica --discovery-token-ca-cert-hash sha256:c59f3633ecb92a31d86f64dc304abea55176555afbb3f2af9f40e5d4e013f86b --ignore-preflight-errors=All

[root@master ~]# kubectl get nodes
NAME STATUS ROLES AGE VERSION
master Ready master 20h v1.11.2
node1 NotReady 49s v1.11.2

[root@node1 ~]# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
k8s.gcr.io/kube-proxy-amd64 v1.11.1 d5c25579d0ff 6 weeks ago 97.8MB
quay.io/coreos/flannel v0.10.0-amd64 f0fad859c909 7 months ago 44.6MB
k8s.gcr.io/pause 3.1 da86e6ba6ca1 8 months ago 742kB
[root@master ~]# kubectl get pods -n kube-system -o wide
NAME READY STATUS RESTARTS AGE IP NODE
coredns-78fcdf6894-4smdl 1/1 Running 58 20h 10.244.0.7 master
coredns-78fcdf6894-tlklk 1/1 Running 55 20h 10.244.0.6 master
etcd-master 1/1 Running 4 20h 172.18.0.67 master
kube-apiserver-master 1/1 Running 54 20h 172.18.0.67 master
kube-controller-manager-master 1/1 Running 9 20h 172.18.0.67 master
kube-flannel-ds-amd64-ds7x5 1/1 Running 2 20h 172.18.0.67 master
kube-flannel-ds-amd64-ktw9f 1/1 Running 0 4m 172.18.0.68 node1
kube-proxy-lqpms 1/1 Running 0 4m 172.18.0.68 node1
kube-proxy-tsxvp 1/1 Running 2 20h 172.18.0.67 master
kube-scheduler-master 1/1 Running 7 20h 172.18.0.67 master


node2
[root@node1 # rpm --import rpm-package-key.gpg
[root@node2] #yum repolist
[root@node2]# yum install docker-ce kubelet kubeadm -y
复制master配置至node2

[root@master ~]# scp /usr/lib/systemd/system/docker.service node1:/usr/lib/systemd/system/docker.service
[root@master ~]# scp /etc/sysconfig/kubelet node1:/etc/sysconfig/kubelet

验证itables桥是否为1

[root@master ~]# cat /proc/sys/net/bridge/bridge-nf-call-ip6tables
[root@master ~]# cat /proc/sys/net/bridge/bridge-nf-call-iptables

如不为1,则在/etc/sysctl.conf中添加:

net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1

执行sysctl -p 时出现:
[root@localhost ~]# sysctl -p
sysctl: cannot stat /proc/sys/net/bridge/bridge-nf-call-ip6tables: No such file or directory
sysctl: cannot stat /proc/sys/net/bridge/bridge-nf-call-iptables: No such file or directory
解决方法:

[root@localhost ~]# modprobe br_netfilter
[root@localhost ~]# sysctl -p
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1

[root@node2 ~]# systemctl start kubelet docker
[root@node2 ~]# systemctl enable kubelet docker
[root@node1 ~]# kubeadm join 172.20.0.70:6443 --token dis2yz.m446ryn2lr298ica --discovery-token-ca-cert-hash sha256:c59f3633ecb92a31d86f64dc304abea55176555afbb3f2af9f40e5d4e013f86b --ignore-preflight-errors=All

自此部署完毕master及note节点

检查master
[root@master ~]# kubectl get nodes
NAME STATUS ROLES AGE VERSION
master Ready master 21h v1.11.2
node1 Ready 46m v1.11.2
node2 NotReady 28m v1.11.2