### 系统环境准备(CentOS 7.2):
a) # systemctl disable firewalld
b) # sed -i s‘/SELINUX=enforcing/SELINUX=disabled/g‘ /etc/sysconfig/selinux
c) # yum -y update && reboot
d) # yum -y install ntpdate && ntpdate cn.pool.ntp.org
Master : 192.168.11.10
node1 : 192.168.11.20
node2 : 192.168.11.30
下载安装:
etct: https://github.com/coreos/etcd/releases
flannel: https://github.com/coreos/flannel/releases
kubernetes: https://github.com/kubernetes/kubernetes/releases
docker: https://docs.docker.com/engine/installation/linux/centos/
) 分别在各节点写入DNS:
192.168.11.10 master hub.jevic.io
192.168.11.20 node1
192.168.11.30 node2
----------------------------------------------------
Master 配置: 192.168.11.10
[[email protected] master]# ls /opt/sourceetcd
flannel etcd kubernetes
[[email protected] master] ln -s /opt/source/etcd/etcd /usr/local/bin
[[email protected] master] ln -s /opt/source/etcd/etcdctl /usr/local/bin
[[email protected] master] ln -s /opt/source/flannel/flanneld /usr/local/bin
[[email protected] master] ln -s /opt/source/kubernetes/server/bin/kube-apiserver /usr/local/bin
[[email protected] master] ln -s /opt/source/kubernetes/server/bin/kube-controller-manager /usr/local/bin
[[email protected] master] ln -s /opt/source/kubernetes/server/bin/kubectl /usr/local/bin
[[email protected] master] ln -s /opt/source/kubernetes/server/bin/kube-scheduler /usr/local/bin
[[email protected] master] mkdir /var/log/{flanneld,kubernetes}
[[email protected] master] nohup etcd --name etcd10 --data-dir /var/lib/etcd \
--listen-client-urls http://0.0.0.0:2378,http://0.0.0.0:4001 \
--advertise-client-urls http://0.0.0.0:2378,http://0.0.0.0:4001 >> /var/log/etcd.log 2>&1 &
[[email protected] master] nohup flanneld --listen=0.0.0.0:8888 >> /var/log/flanneld/flanneld.log 2>&1 &
[[email protected] master] etcdctl set /coreos.com/network/config ‘{ "Network": "10.1.0.0/16" }‘
--- 然后在node1,node2 分别执行(a-g)部分操作 ---
最后开启kubernetes服务:
[[email protected] master] nohup kube-apiserver --logtostderr=true \
--v=0 --etcd_servers=http://0.0.0.0:2378 \
--insecure-bind-address=0.0.0.0 \
--insecure-port=8080 \
--service-cluster-ip-range=10.254.0.0/16 >> /var/log/kubernetes/kube-apiserver.log 2>&1 &
[[email protected] master] nohup kube-controller-manager --logtostderr=true --v=0 --master=http://0.0.0.0:8080 >> /var/log/kubernetes/controller.log 2>&1 &
[[email protected] master] nohup kube-scheduler --logtostderr=true --v=0 --master=http://0.0.0.0:8080 >> /var/log/kubernetes/scheduler.log 2>&1 &
查看节点是否加入:
[[email protected] master] kubectl get nodes
NAME STATUS AGE
node1 Ready 1h
node2 Ready 39m
----------------------------------------------------
Node 节点配置:
【node1: 192.168.11.20】
[[email protected] node1]# ls /opt/source
flannel kubernetes
[[email protected] node1]# ln -s /opt/source/etcd/etcd /usr/local/bin
[[email protected] node1]# ln -s /opt/source/etcd/etcdctl /usr/local/bin
[[email protected] node1]# ln -s /opt/source/flannel/flanneld /usr/local/bin
[[email protected] node1]# ln -s /opt/source/kubernetes/server/bin/kubelet /usr/local/bin
[[email protected] node1]# ln -s /opt/source/kubernetes/server/bin/kube-proxy /usr/local/bin
a.[[email protected] node1]# mkdir /var/log/{flanneld,kubernetes}
b.[[email protected] node1]# nohup flanneld -etcd-endpoints=http://192.168.11.10:4001 -remote=192.168.11.10:8888 >> /var/log/flanneld/flanneld.log 2>&1 &
c.[[email protected] node1]# source /run/flannel/subnet.env
d.[[email protected] node1]# cat /run/flannel/subnet.env
FLANNEL_NETWORK=10.1.0.0/16
FLANNEL_SUBNET=10.1.62.1/24
FLANNEL_MTU=1472
FLANNEL_IPMASQ=false
e.[[email protected] node1]# grep "bip" /lib/systemd/system/docker.service
ExecStart=/usr/bin/dockerd --bip=10.1.62.1/24 --mtu=1472
f.[[email protected] node1]# systemctl daemon-reload && systemctl start docker
g.[[email protected] node1]# ip a|egrep "docker|flan"
3: flannel0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1472 qdisc pfifo_fast state UNKNOWN qlen 500
inet 10.1.62.0/16 scope global flannel0
4: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN
inet 10.1.62.1/24 scope global docker0
最后启动kubernetes节点服务:
[[email protected] node1]# nohup kubelet --address=0.0.0.0 \
--port=10250 --logtostderr=true --v=0 \
--api-servers=http://192.168.11.10:8080 >> /var/log/kubernetes/kubelet.log 2>&1 &
[[email protected] node1]# nohup kube-proxy --logtostderr=true --v=0 --master=http://192.168.11.10:8080 >> /var/log/kubernetes/proxy.log 2>&1 &
----------------------------------------------------
【node2: 192.168.11.30】
[[email protected] node2]# ls /opt/source
flannel kubernetes
[[email protected] node2]# ln -s /opt/source/etcd/etcd /usr/local/bin
[[email protected] node2]# ln -s /opt/source/etcd/etcdctl /usr/local/bin
[[email protected] node2]# ln -s /opt/source/flannel/flanneld /usr/local/bin
[[email protected] node2]# ln -s /opt/source/kubernetes/server/bin/kubelet /usr/local/bin
[[email protected] node2]# ln -s /opt/source/kubernetes/server/bin/kube-proxy /usr/local/bin
a.[[email protected] node2]# mkdir /var/log/{flanneld,kubernetes}
b.[[email protected] node2]# nohup flanneld -etcd-endpoints=http://192.168.11.10:4001 -remote=192.168.11.10:8888 >> /var/log/flanneld/flanneld.log 2>&1 &
c.[[email protected] node2]# source /run/flannel/subnet.env
d.[[email protected] node2]# cat /run/flannel/subnet.env
FLANNEL_NETWORK=10.1.0.0/16
FLANNEL_SUBNET=10.1.77.1/24
FLANNEL_MTU=1472
FLANNEL_IPMASQ=false
e.[[email protected] node2]# grep "bip" /lib/systemd/system/docker.service
ExecStart=/usr/bin/dockerd --bip=10.1.77.1/24 --mtu=1472
f.[[email protected] node2]# systemctl daemon-reload && systemctl start docker
g.[[email protected] node2]# ip a|egrep "docker|flan"
3: flannel0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1472 qdisc pfifo_fast state UNKNOWN qlen 500
inet 10.1.77.0/16 scope global flannel0
4: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN
inet 10.1.77.1/24 scope global docker0
最后启动kubernetes节点服务:
[[email protected] node2]# nohup kubelet --address=0.0.0.0 \
--port=10250 --logtostderr=true --v=0 \
--api-servers=http://192.168.11.10:8080 >> /var/log/kubernetes/kubelet.log 2>&1 &
[[email protected] node2]# nohup kube-proxy --logtostderr=true --v=0 --master=http://192.168.11.10:8080 >> /var/log/kubernetes/proxy.log 2>&1 &