工作环境:
主机名 IP 系统master 192.168.199.6 rhel7.4
node1 192.168.199.7 rhel7.4
node2 192.168.199.8 rhel7.4
[root@master ~]#yum install kubernetes etcd flannel -y
[root@node1 ~]#yum install kubernetes flannel -y
[root@node2 ~]#yum install kubernetes flannel -y
[root@master ~]# vim /etc/etcd/etcd.conf
6 ETCD_LISTEN_CLIENT_URLS="http://localhost:2379,:2379"
21 ETCD_ADVERTISE_CLIENT_URLS="http://localhost:2379,:2379"
[root@master ~]# systemctl start etcd
[root@master ~]# netstat -autup|grep 2379
tcp 0 0 localhost:2379 0.0.0.0:* LISTEN 5442/etcd
tcp 0 0 master:2379 0.0.0.0:* LISTEN 5442/etcd
tcp 0 0 master:2379 master:51468 ESTABLISHED 5442/etcd
tcp 0 0 localhost:2379 localhost:38090 ESTABLISHED 5442/etcd
tcp 0 0 master:51468 master:2379 ESTABLISHED 5442/etcd
tcp 0 0 master:51456 master:2379 TIME_WAIT -
tcp 0 0 localhost:38090 localhost:2379 ESTABLISHED 5442/etcd
[root@master ~]# systemctl enable etcd
检查etcd cluster状态
[root@master ~]# etcdctl cluster-health
member 8e9e05c52164694d is healthy: got healthy result from :2379
cluster is healthy
检查etcd集群成员列表
[root@master ~]# etcdctl member list
8e9e05c52164694d: name=default peerURLs=http://localhost:2380 clientURLs=http://192.168.199.6:2379,:2379 isLeader=true
[root@master ~]# vim /etc/kubernetes/config
22 KUBE_MASTER="--master=http://192.168.199.6:8080"
[root@master ~]# vim /etc/kubernetes/apiserver
8 KUBE_API_ADDRESS="--insecure-bind-address=0.0.0.0"
17 KUBE_ETCD_SERVERS="--etcd-servers=http://192.168.199.6:2379"
23 KUBE_ADMISSION_CONTROL="--admission-control=AlwaysAdmit"
[root@master ~]# vim /etc/kubernetes/controller-manager 该文件不用修改
[root@master ~]# vim /etc/kubernetes/scheduler
7 KUBE_SCHEDULER_ARGS="--address=0.0.0.0"
[root@master ~]# vim /etc/sysconfig/flanneld
4 FLANNEL_ETCD_ENDPOINTS="http://192.168.199.6:2379"
8 FLANNEL_ETCD_PREFIX="/k8s/network"
11 FLANNEL_OPTIONS="--iface=ens32"
[root@master ~]# systemctl restart flanneld
[root@master ~]# etcdctl set /k8s/network/config \'{"network":"10.255.0.0/16"}\'
{"network":"10.255.0.0/16"}
[root@master ~]# etcdctl get /k8s/network/config
{"network":"10.255.0.0/16"}
[root@master ~]# systemctl restart kube-apiserver kube-controller-manager kube-scheduler.service
[root@master ~]# systemctl status kube-apiserver kube-controller-manager kube-scheduler.service
[root@master ~]# systemctl enable kube-apiserver kube-controller-manager kube-scheduler
[root@master ~]# systemctl enable flanneld
node1