一、環(huán)境
作為一家“創(chuàng)意+整合+營銷”的成都網(wǎng)站建設機構,我們在業(yè)內(nèi)良好的客戶口碑。成都創(chuàng)新互聯(lián)提供從前期的網(wǎng)站品牌分析策劃、網(wǎng)站設計、網(wǎng)站設計制作、做網(wǎng)站、創(chuàng)意表現(xiàn)、網(wǎng)頁制作、系統(tǒng)開發(fā)以及后續(xù)網(wǎng)站營銷運營等一系列服務,幫助企業(yè)打造創(chuàng)新的互聯(lián)網(wǎng)品牌經(jīng)營模式與有效的網(wǎng)絡營銷方法,創(chuàng)造更大的價值。
centos7,
主機:
master: 主機名k8s-master, ip: 192.168.1.130
node1: 主機名k8s-node-1, ip:192.168.1.132
master和node的/etc/hosts都是如下配置
cat /etc/hosts
192.168.1.130 k8s-master
192.168.1.130 etcd
192.168.1.130 registry
192.168.1.132 k8s-node-1
192.168.1.133 k8s-node-2
master執(zhí)行
# systemctl stop firewalld # systemctl disable firewalld
# setenforce 0
1.使用yum安裝etcd和kubernetes-master
# yum -y install etcd kubernetes-master
2..編輯/etc/etcd/etcd.conf文件
ETCD_NAME=default ETCD_DATA_DIR="/var/lib/etcd/default.etcd" ETCD_LISTEN_CLIENT_URLS=" ETCD_ADVERTISE_CLIENT_URLS=" 3.編輯/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= 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.啟動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 5.在etcd中定義flannel網(wǎng)絡 # etcdctl mk /atomic.io/network/config '{"Network":"172.17.0.0/16"}' 安裝配置Kubernetes Node 1.使用yum安裝flannel和kubernetes-node # yum -y install flannel kubernetes-node 2.為flannel網(wǎng)絡指定etcd服務,修改/etc/sysconfig/flanneld文件 FLANNEL_ETCD=" 3.修改/etc/kubernetes/config文件
KUBE_LOGTOSTDERR="--logtostderr=true" KUBE_LOG_LEVEL="--v=0" KUBE_ALLOW_PRIV="--allow-privileged=false" KUBE_MASTER="--master= 4.按照如下內(nèi)容修改對應node的配置文件/etc/kubernetes/kubelet KUBELET_ADDRESS="--address=0.0.0.0" KUBELET_PORT="--port=10250" KUBELET_HOSTNAME="--hostname-override=192.168.1.132" #修改成對應Node的IP KUBELET_API_SERVER="--api-servers=http://192.168.30.20:8080" #指定Master節(jié)點的API ServerKUBELET_POD_INFRA_CONTAINER="--pod-infra-container-p_w_picpath=registry.access.redhat.com/rhel7/pod-infrastructure:latest" KUBELET_ARGS=""
5.在所有Node節(jié)點上啟動kube-proxy,kubelet,docker,flanneld等服務,并設置開機啟動。
# for SERVICES in kube-proxy kubelet docker flanneld;do systemctl restart $SERVICES;systemctl enable $SERVICES;systemctl status $SERVICES; done
驗證集群是否安裝成功
在master上執(zhí)行如下命令
# kubectl get node