K8S部署指导书( 二 )


6)启动相关组件
for I in etcd kube-apiserver kube-controller-manager kube-scheduler; do systemctl restart $I systemctl enable $I systemctl status $I done
7)查询相关组件端口
netstat -anltp
8)到此为止 MASTER 节点配置完成
----------------------------------------------------------------------------------------------------------------------------
二、minion 节点部署步骤
1)关闭防火墙开启NTP
systemctl stop firewalld #停止防火墙 systemctl disable firewalld #禁用防火墙 yum -y install ntp #安装NTP服务器 ntpdate pool.ntp.org #更新时间同步 systemctl start ntpd #启动NTP setenforce 0 systemctl enable ntpd#enable #NTP关机开机后不需要在开启
2)部署相关组件如下:
yum install epel-release -y yum install kubernetes-node docker flannel *rhsm* -y
3)修改配置文件,注意IP指向主节点,文件复制即可
[root@localhost ~]# more /etc/kubernetes/config # kubernetes system config # The following values are used to configure various aspects of all # kubernetes services, including # kube-apiserver.service # kube-controller-manager.service # kube-scheduler.service # kubelet.service # kube-proxy.service # 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 KUBE_MASTER="--master=http://10.10.10.12:8080" #指向主节点
4)修改kubelet 配置文件 如下所示,注意IP地址
[root@localhost kubernetes]# more /etc/kubernetes/kubelet ### # kubernetes kubelet (minion) config # 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_HOSTNAME="--hostname-override=10.10.10.14" # location of the api-server KUBELET_API_SERVER="--api-servers=http://10.10.10.12:8080" # pod infrastructure container #KUBELET_POD_INFRA_CONTAINER="--pod-infra-container-image=192.168.0.123:5000/centos68" KUBELET_POD_INFRA_CONTAINER="--pod-infra-container-image=registry.access.redhat.com/rhel7/pod-infrastructure:latest" # Add your own! KUBELET_ARGS=""
5)启动
for I in kube-proxy kubelet docker do systemctl restart $I systemctl enable $I systemctl status $I done
6)查看相关端口
netstat -anltp
---------------------------------------------------------------------------------------------------------------------------
三、部署FLANNELD 组件
1)修改MASTER 节点 配置文件如下 路径/etc/sysconfig/flanneld
[root@localhost kubernetes]# more /etc/sysconfig/flanneld # Flanneld configuration options # etcd url location. Point this to the server where etcd runs FLANNEL_ETCD_ENDPOINTS="http://10.10.10.12:2379"#指定ETCD的访问入口 # etcd config key. This is the configuration key that flannel queries # For address range assignment FLANNEL_ETCD_PREFIX="/atomic.io/network" #指定ETCD的KEY # Any additional options that you want to pass #FLANNEL_OPTIONS=""
2)修改minon 节点配置文件 路径 /etc/sysconfig/flanneld,注意IP指向MASTER
[root@localhost kubernetes]# more /etc/sysconfig/flanneld # Flanneld configuration options # etcd url location. Point this to the server where etcd runs FLANNEL_ETCD_ENDPOINTS="http://10.10.10.12:2379" #指定ETCD的访问入口 # etcd config key. This is the configuration key that flannel queries # For address range assignment FLANNEL_ETCD_PREFIX="/atomic.io/network" #指定ETCD的KEY # Any additional options that you want to pass #FLANNEL_OPTIONS=""
3)在MASTER节点指向下面命令,在Master服务器,测试Etcd集群是否正常,同时在Etcd配置中心创建flannel网络配置: 最后一条命令是创建ETCD KEY-VALUES 不创建的话 FLANNELD组件无法启动
etcdctl member list etcdctl cluster-health etcdctl get /atomic.io/network/config etcdctl ls /atomic.io/network/subnets etcdctl rm /atomic.io/network/ --recursive etcdctl mk /atomic.io/network/config '{"Network":"172.17.0.0/16"}'
4)启动组件
service flanneld restart
5)查看配置
MASTER
[root@localhost kubernetes]# ifconfig ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 10.10.10.12 netmask 255.255.255.0 broadcast 10.10.10.255 inet6 fe80::5236:328f:e632:35f3 prefixlen 64 scopeid 0x20<link> ether 00:0c:29:c6:56:7d txqueuelen 1000 (Ethernet) RX packets 82765 bytes 72168174 (68.8 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 39638 bytes 17434838 (16.6 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 flannel0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST> mtu 1472 inet 172.17.63.0 netmask 255.255.0.0 destination 172.17.63.0 inet6 fe80::cf87:5bc:e7e9:a6bd 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 786 bytes 928034 (906.2 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 561 bytes 50704 (49.5 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0


推荐阅读