对应主机名 写入 hosts
centos-master = 192.168.121.9
centos-minion-1 = 192.168.121.65
centos-minion-2 = 192.168.121.66
centos-minion-3 = 192.168.121.67
关闭所有主机防火墙
setenforce 0
systemctl disable iptables-services firewalld
systemctl stop iptables-services firewalld
对应所有主机 建立 repo 源
[virt7-docker-common-release]
name=virt7-docker-common-release
baseurl=http://cbs.centos.org/repos/v…
gpgcheck=0
对应所有主机安装修改
yum -y install –enablerepo=virt7-docker-common-release kubernetes etcd flannel
vi /etc /kubernetes/config
KUBE_LOGTOSTDERR=”–logtostderr=true”
KUBE_LOG_LEVEL=”–v=0″
KUBE_ALLOW_PRIV=”–allow-privileged=false”
KUBE_MASTER=”–master=http://centos-master:8080″
对master主机
vi /etc/etcd/etcd.conf
ETCD_NAME=default
ETCD_DATA_DIR=”/var/lib/etcd/default.etcd”
ETCD_LISTEN_CLIENT_URLS=”http://0.0.0.0:2379″
ETCD_ADVERTISE_CLIENT_URLS=”http://0.0.0.0:2379″
vi /etc/kubernetes/apiserver
KUBE_API_ADDRESS=”–address=0.0.0.0″
KUBE_API_PORT=”–port=8080″
KUBELET_PORT=”–kubelet-port=10250″
KUBE_ETCD_SERVERS=”–etcd-servers=http://centos-master:2379″
KUBE_SERVICE_ADDRESSES=”–service-cluster-ip-range=10.254.0.0/16″
KUBE_API_ARGS=””
启动ETCD并将其配置为在主机上保持网络覆盖配置: 警告此网络必须在您的网络基础架构中未使用!172.30.0.0/16在我们的网络中是免费的。
systemctl start etcd
etcdctl mkdir /kube-centos/network
etcdctl mk /kube-centos/network/config “{ “Network”: “172.30.0.0/16”, “SubnetLen”: 24, “Backend”: { “Type”: “vxlan” } }”
vi /etc/sysconfig/flanneld
FLANNEL_ETCD_ENDPOINTS=”http://centos-master:2379″
FLANNEL_ETCD_PREFIX=”/kube-centos/network” 这个是上面创建的 kube-centos
最后
for SERVICES in etcd kube-apiserver kube-controller-manager kube-scheduler flanneld; do
systemctl restart $SERVICES
systemctl enable $SERVICES
systemctl status $SERVICES
done
Node
在节点上配置Kubernetes服务。
我们需要配置kubelet并启动kubelet和代理
vi /etc/kubernetes/kubelet
KUBELET_ADDRESS=”–address=0.0.0.0″
KUBELET_PORT=”–port=10250″
KUBELET_HOSTNAME=”–hostname-override=centos-minion-n” 写各自的IP
KUBELET_API_SERVER=”–api-servers=http://centos-master:8080″ 写master的ip
KUBELET_ARGS=””
vi /etc/sysconfig/flanneld
FLANNEL_ETCD_ENDPOINTS=”http://centos-master:2379″
FLANNEL_ETCD_PREFIX=”/kube-centos/network”
Start the appropriate services on node 开启服务
for SERVICES in kube-proxy kubelet flanneld docker; do
systemctl restart $SERVICES
systemctl enable $SERVICES
systemctl status $SERVICES
done
Configure kubectl
kubectl config set-cluster default-cluster –server=http://centos-master:8080 写 master ip
kubectl config set-context default-context –cluster=default-cluster –user=default-admin
kubectl config use-context default-context
最后 在 master 主机
kubectl get nodes
得到相应的主机信息