192.168.5.237 k8s_slave2" >> /etc/hosts
四、修改/etc/kubernetes/config(所有节点)
# logging to stderr means we get it in the systemd journal
KUBE_LOGTOSTDERR="--logtostderr=true"
# journal message level, 0 is debug
KUBE_LOG_LEVEL="--v=0"
# Should this cluster be allowed to run privileged docker containers
KUBE_ALLOW_PRIV="--allow-privileged=false"
# How the controller-manager, scheduler, and proxy find the apiserver
systemctl enable docker.service
#yum 安装kubernetes flannel
yum -y install --enablerepo=virt7-docker-common-release kubernetes flannel #创建docker-pool
docker-storage-setup #为etcd服务配置flannel,修改配置文件 /etc/sysconfig/flanneld
FLANNEL_ETCD="http://192.168.5.221:2379" #修改kubernetes配置文件,指定master。/etc/kubernetes/config
# How the controller-manager, scheduler, and proxy find the apiserver
KUBE_MASTER="--master=http://192.168.5.221:8080"
#配置kubelet服务。/etc/kubernetes/kubelet
# The address for the info server to serve on (set to 0.0.0.0 or "" for all interfaces)
KUBELET_ADDRESS="--address=0.0.0.0"
# The port for the info server to serve on
KUBELET_PORT="--port=10250"
# You may leave this blank to use the actual hostname
KUBELET_API_SERVER="--api-servers=http://192.168.5.221:8080"
#启动服务
for SERVICES in kube-proxy kubelet docker flanneld; do
systemctl restart $SERVICES
systemctl enable $SERVICES
systemctl status $SERVICES
done
如果报错Bridge ip (...) does not match existing bridge configuration,是因为docker的bridge 先于flannel启动导致冲突
删除docker 0
ip link set dev docker0 down
brctl delbr docker0
vi /usr/lib/systemd/system/docker.service 修改如下:
[Unit]
Description=Docker Application Container Engine
Documentation=http://docs.docker.com
After=flanneld.service
Wants=docker-storage-setup.service
Requires=flanneld.service
systemctl restart docker
#验证
#在每个minions可以看到2块网卡:docker0和flannel0,这2块网卡的ip在不同的机器ip地址不同。但是同机器的2块网卡ip相同
ip a | grep -E "flannel|docker"|grep inet
inet 172.17.58.0/16 scope global flannel0
inet 172.17.58.1/24 scope global docker0
#现在登陆master,确认minions的状态
[root@k8s_master etcd]# kubectl get nodes
NAME LABELS STATUS AGE