1. 关闭防火墙
# systemctl stop firewalld # systemctl disable firewalld # setenforce 0
2. 使用yum安装etcd和kubernetes-master
# yum -y install etcd kubernetes
3. 修改 /etc/etcd/etcd.conf 文件
# grep -Env '#|^$' /etc/etcd/etcd.conf 3:ETCD_DATA_DIR="/var/lib/etcd/default.etcd" 6:ETCD_LISTEN_CLIENT_URLS="http://192.168.3.4:2379,http://127.0.0.1:2379" 9:ETCD_NAME="default" 21:ETCD_ADVERTISE_CLIENT_URLS="http://192.168.3.4:2379"
4. 修改 /etc/kubernetes/apiserver 文件
# grep -Env '#|^$' /etc/kubernetes/apiserver 8:KUBE_API_ADDRESS="--insecure-bind-address=0.0.0.0" 11:KUBE_API_PORT="--port=8080" 14:KUBELET_PORT="--kubelet-port=10250" 17:KUBE_ETCD_SERVERS="--etcd-servers=http://192.168.3.4:2379" 20:KUBE_SERVICE_ADDRESSES="--service-cluster-ip-range=10.254.0.0/16" 23:KUBE_ADMISSION_CONTROL="--admission-control=NamespaceLifecycle,NamespaceExists,LimitRanger,SecurityContextDeny,ResourceQuota" 26:KUBE_API_ARGS=""
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; done
6. 在etcd中定义flannel网络
# etcdctl mk /atomic.io/network/config '{"Network":"192.168.3.4/16"}'
7. 安装配置Kubernetes Node
7.1 使用yum安装flannel和kubernetes-node
# yum -y install flannel
7.2 为flannel网络指定etcd服务,修改/etc/sysconfig/flanneld文件
# grep -Env '#|^$' /etc/sysconfig/flanneld 5:FLANNEL_ETCD_ENDPOINTS="http://192.168.3.4:2379" 9:FLANNEL_ETCD_PREFIX="/atomic.io/network"
7.3 修改/etc/kubernetes/config文件
# grep -Env '#|^$' /etc/kubernetes/config 13:KUBE_LOGTOSTDERR="--logtostderr=true" 16:KUBE_LOG_LEVEL="--v=0" 19:KUBE_ALLOW_PRIV="--allow-privileged=false" 22:KUBE_MASTER="--master=http://192.168.3.4:8080"
7.4 按照如下内容修改对应node的配置文件/etc/kubernetes/kubelet
# grep -Env '#|^$' /etc/kubernetes/kubelet 5:KUBELET_ADDRESS="--address=0.0.0.0" 8:KUBELET_PORT="--port=10250" 11:KUBELET_HOSTNAME="--hostname-override=192.168.3.4" 14:KUBELET_API_SERVER="--api-servers=http://192.168.3.4:8080" 17:KUBELET_POD_INFRA_CONTAINER="--pod-infra-container-image=registry.access.redhat.com/rhel7/pod-infrastructure:latest" 20:KUBELET_ARGS=""
7.5 在所有Node节点上启动kube-proxy,kubelet,docker,flanneld等服务,并设置开机启动。
# for SERVICES in kube-proxy kubelet flanneld;do systemctl restart $SERVICES;systemctl enable $SERVICES; done
8. 验证集群是否安装成功
# kubectl get node NAME STATUS AGE 127.0.0.1 NotReady 6h 192.168.3.4 NotReady 6h
所有评论(0)