一、环境
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执行
# systemctl stop firewalld
# systemctl disable firewalld
# setenforce 0
1.使用yum安装etcd和kubernetes-master
#yum-yinstalletcdkubernetes-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等服务,并设置开机启动 #forSERVICESinetcdkube-apiserverkube-controller-managerkube-scheduler;dosystemctlrestart$SERVICES;systemctlenable$SERVICES;systemctlstatus$SERVICES;done 5.在etcd中定义flannel网络 #etcdctlmk/atomic.io/network/config'{"Network":"172.17.0.0/16"}' 安装配置KubernetesNode 1.使用yum安装flannel和kubernetes-node #yum-yinstallflannelkubernetes-node 2.为flannel网络指定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.按照如下内容修改对应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节点的APIServerKUBELET_POD_INFRA_CONTAINER="--pod-infra-container-image=registry.access.redhat.com/rhel7/pod-infrastructure:latest" KUBELET_ARGS=""
5.在所有Node节点上启动kube-proxy,kubelet,docker,flanneld等服务,并设置开机启动。
#forSERVICESinkube-proxykubeletdockerflanneld;dosystemctlrestart$SERVICES;systemctlenable$SERVICES;systemctlstatus$SERVICES;done
验证集群是否安装成功
在master上执行如下命令
#kubectlgetnode原文链接:https://www.f2er.com/centos/376076.html