[root@node1 ~]# vim /etc/sysconfig/flanneld
4 FLANNEL_ETCD_ENDPOINTS="http://192.168.199.6:2379"
8 FLANNEL_ETCD_PREFIX="/k8s/network"
11 FLANNEL_OPTIONS="--iface=ens33"
[root@node1 ~]# ps -aux|grep flanneld
root 10467 0.2 1.7 375996 31932 ? Ssl 20:33 0:00 /usr/bin/flanneld -etcd-endpoints=http://192.168.199.6:2379 -etcd-prefix=http://www.likecs.com/k8s/network --iface=ens33
root 10615 0.0 0.0 112676 984 pts/1 S+ 20:35 0:00 grep --color=auto flanneld
[root@node1 ~]#
[root@node1 ~]# vim /etc/kubernetes/config
22 KUBE_MASTER="--master=http://192.168.199.6:8080"
[root@node1 ~]# vim /etc/kubernetes/kubelet
5 KUBELET_ADDRESS="--address=0.0.0.0"
11 KUBELET_HOSTNAME="--hostname-override=node1"
14 KUBELET_API_SERVER="--api-servers=http://192.168.199.6:8080"
[root@node1 ~]# systemctl restart flanneld kube-proxy.service kubelet docker
[root@node1 ~]# systemctl enable flanneld kube-proxy.service kubelet docker
[root@node1 ~]# systemctl status flanneld kube-proxy.service kubelet docker
[root@node1 ~]# ifconfig
flannel0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST> mtu 1472
inet 10.255.4.0 netmask 255.255.0.0 destination 10.255.4.0
inet6 fe80::d5dd:8c9b:48b6:5cb5 prefixlen 64 scopeid 0x20<link>
unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 500 (UNSPEC)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 3 bytes 144 (144.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
node2:
node2的配置和node1的一样,所以只需要把node1的配置文件复制过去即可。
[root@node1 ~]#scp /etc/sysconfig/flanneld 192.168.199.8:/etc/sysconfig/
[root@node2 ~]# vim /etc/sysconfig/flanneld
# Flanneld configuration options
# etcd url location. Point this to the server where etcd runs
FLANNEL_ETCD_ENDPOINTS="http://192.168.199.6:2379"
# etcd config key. This is the configuration key that flannel queries
# For address range assignment
FLANNEL_ETCD_PREFIX="/k8s/network"
# Any additional options that you want to pass
FLANNEL_OPTIONS="--iface=ens33" 自己本地的网卡,若网卡不是ens33的话自己修改一下
[root@node1 ~]#scp /etc/kubernetes/config 192.168.199.8:/etc/kubernetes/
[root@node1 ~]#scp /etc/kubernetes/proxy 192.168.199.8:/etc/kubernetes/
[root@node1 ~]#scp /etc/kubernetes/kubelet 192.168.199.8:/etc/kubernetes/
[root@node2 ~]# vim /etc/kubernetes/kubelet
11 KUBELET_HOSTNAME="--hostname-override=node2" 修改为自己的主机名
[root@node2 ~]#systemctl restart flanneld kube-proxy kubelet docker
[root@node2 ~]#systemctl enable flanneld kube-proxy kubelet docker
[root@node2 ~]#systemctl status flanneld kube-proxy kubelet docker
完成之后再master上查看kubernetes集群的状态,这样集群就做好了。
在主上查看集群状态:
[root@master log]# kubectl get nodes
NAME STATUS AGE
node1 Ready 7m
node2 Ready 1m