环境:
centos7系统(VMware中安装的阿里云镜像)机器两台:
一、 关闭系统运行的防火墙及selinux(两台机器都要)
1. 关闭系统运行的防火墙
# systemctl stop firewalld
# systemctl disable firewalld
2. 关闭selinux
二、 master安装配置
1. 安装Kubernetes
# yum -y install etcd kubernetes
2. 配置etcd
# vi /etc/etcd/etcd.conf
ETCD_NAME=defaultETCD_ADVERTISE_CLIENT_URLS="http://localhost:4001"
3. 配置kubernetes
# vi /etc/kubernetes/apiserver
KUBE_API_ADDRESS="--address=0.0.0.0"
KUBE_API_PORT="--port=8080"
KUBELET_PORT="--kubelet_port=10250" ## 注意kubelet与port用“_”连接。后面的配置参数有同样的问题(master,minion中都有)
KUBE_ETCD_SERVERS="--etcd_servers=http://127.0.0.1:4001"
KUBE_SERVICE_ADDRESSES="--service-cluster-ip-range=10.254.0.0/16"
KUBE_ADMISSION_CONTROL="--admission_control=NamespaceLifecycle,NamespaceExists,LimitRanger,SecurityContextDeny,ResourceQuota"
KUBE_API_ARGS=""
4. 配置flannel网络
# vi /etc/sysconfig/flanneld
FLANNEL_ETCD_ENDPOINTS="http://192.168.84.129:4001"
FLANNEL_ETCD_PREFIX="/atomic.io/network"
5. 启动etcd,kube-apiserver, kube-controller-manager,kube-scheduler服务
# for SERVICES in etcd kube-apiserver kube-controller-manager kube-scheduler; do systemctl restart $SERVICES; systemctl enable $SERVICES ; systemctl status $SERVICES; done
6. 设置etcd网络
# etcdctl -C //192.168.84.129:4001 set /atomic.io/network/config '{"Network":"10.1.0.0/16"}'
7. 至此master配置完成,运行kubectl get nodes可以查看有多少minion在运行,以及其状态。这里我们的minion还都没有开始安装配置,所以运行之后结果为空
# kubectl get nodes
三、minion安装配置
1. 安装Kubernetes
# sudo yum -y remove docker-engine
# sudo rm -rf /var/lib/docker
# sudo yum -y remove docker docker-common container-selinux
# sudo yum -y remove docker-selinux
(2).
# yum -y install flannel kubernetes
2. 配置kubernetes连接的服务端IP
# vi /etc/kubernetes/config
KUBE_MASTER="--master=http://192.168.84.129:8080"
KUBE_ETCD_SERVERS="--etcd_servers=http://192.168.84.129:4001"
3. 配置kubernetes
# vi /etc/kubernetes/kubelet
KUBELET_ADDRESS="--address=0.0.0.0"KUBELET_API_SERVER="--api_servers=http://192.168.84.129:8080"
# KUBELET_POD_INFRA_CONTAINER="--pod-infra-container-image=registry.access.redhat.com/rhel7/pod-infrastructure:latest"
4. 配置flannel网络
# vi /etc/sysconfig/flanneld
FLANNEL_ETCD_ENDPOINTS="http://192.168.84.129:4001"
FLANNEL_ETCD_PREFIX="/atomic.io/network"
5. 启动服务
# for SERVICES in flanneld kube-proxy kubelet docker; do systemctl restart $SERVICES; systemctl enable $SERVICES; systemctl status $SERVICES; done
四、配置完成验证安装
切换到master机器上,查看有多少minion在运行
# kubectl get nodes
NAME STATUS AGE
192.168.84.128 Ready 23s