1.安裝配置Kubernetes Master
[root@server2 ~]# yum -y install etcd kubernetes-master
[root@server2 ~]# vim /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://localhost:2379"
[root@server2 ~]# vim /etc/kubernetes/apiserver
KUBE_API_ADDRESS="--insecure-bind-address=0.0.0.0"
KUBE_API_PORT="--port=8080"
KUBELET_PORT="--kubelet-port=10250"
KUBE_ETCD_SERVERS="--etcd-servers=http://127.0.0.1:2379"
KUBE_SERVICE_ADDRESSES="--service-cluster-ip-range=192.168.10.0/16" #改為自己的ip段
KUBE_ADMISSION_CONTROL="--admission-control=NamespaceLifecycle,NamespaceExists,LimitRanger,SecurityContextDeny,ResourceQuota"
KUBE_API_ARGS=""
[root@localhost ~]# vi /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://172.168.93.254:8080"
1.1 啟動(dòng)etcd蜡饵、kube-apiserver窥岩、kube-controller-manager晃琳、kube-scheduler等服務(wù)邮屁,并設(shè)置開(kāi)機(jī)啟動(dòng)
[root@server2 ~]# for SERVICES in etcd kube-apiserver kube-controller-manager kube-scheduler; do systemctl restart $SERVICES;systemctl enable $SERVICES;systemctl status $SERVICES ; done
1.2 在etcd中定義flannel網(wǎng)絡(luò)
etcdctl mk /atomic.io/network/config '{"Network":"192.168.10.0/16"}'
2 安裝配置Kubernetes Node
yum -y install flannel kubernetes-node
- 為flannel網(wǎng)絡(luò)指定etcd服務(wù),修改/etc/sysconfig/flanneld文件
[root@server3 ~]# vim /etc/sysconfig/flanneld
FLANNEL_ETCD="http://192.168.10.233:2379" # MASTER節(jié)點(diǎn)
FLANNEL_ETCD_KEY="/atomic.io/network"
- 修改/etc/kubernetes/config文件
[root@server3 ~]# vim /etc/kubernetes/config
KUBE_LOGTOSTDERR="--logtostderr=true"
KUBE_LOG_LEVEL="--v=0"
KUBE_ALLOW_PRIV="--allow-privileged=false"
KUBE_MASTER="--master=http://192.168.10.233:8080" # MASTER節(jié)點(diǎn)
- 修改對(duì)應(yīng)node的配置文件/etc/kubernetes/kubelet
[root@server3 ~]# vim /etc/kubernetes/kubelet
KUBELET_ADDRESS="--address=0.0.0.0"
KUBELET_PORT="--port=10250"
KUBELET_HOSTNAME="--hostname-override=172.25.27.3" #修改成對(duì)應(yīng)Node的IP
KUBELET_API_SERVER="--api-servers=http://172.25.27.2:8080" #指定Master節(jié)點(diǎn)的API Server
KUBELET_POD_INFRA_CONTAINER="--pod-infra-container-image=registry.access.redhat.com/rhel7/pod-infrastructure:latest"
- 在所有Node節(jié)點(diǎn)上啟動(dòng)kube-proxy,kubelet,docker,flanneld等服務(wù)账忘,并設(shè)置開(kāi)機(jī)啟動(dòng)志膀。
[root@server3 ~]# for SERVICES in kube-proxy kubelet docker flanneld;do systemctl restart $SERVICES;systemctl enable $SERVICES;systemctl status $SERVICES; done
3.驗(yàn)證集群是否安裝成功
在master上執(zhí)行如下命令
[root@server2 ~]# kubectl get node
NAME LABELS STATUS AGE
172.25.27.3 kubernetes.io/hostname=172.25.27.3 Ready 14m