一.规划
1.系统
centos 7
2.ip规划及功能分配
192.168.2.24 master
192.168.2.24 etcd
192.168.2.25 node1(即minion)
192.168.2.26 node2(即minion)
二.基本环境配置
1.关闭防火墙
#systemctl stop firewalld.service
#systemctl disable firewalld.service
2.永久关闭SELinux
#vi /etc/selinux/config
SELINUX=disabled
3.重启
#reboot
4.安装NTP
为了让各个服务器的时间保持一致,还需要为所有的服务器安装NTP:
# yum -y install ntp
# systemctl start ntpd
# systemctl enable ntpd
三.Master配置及安装相应软件
1.安装和配置etcd
etcd是KV存储系统,用于集群的共享配置和服务发现
1.1 安装:
#yum install etcd
1.2 修改etcd配置文件
修改/etc/etcd/etcd.conf中的部分属性
ETCD_LISTEN_CLIENT_URLS="http://0.0.0.0:2379"
ETCD_ADVERTISE_CLIENT_URLS="http://etcd:2379"
PS:其中etcd表示etcd服务器主机名
1.3 运行etcd并配置开机启动
#systemctl start etcd
#systemctl enable etcd
1.4 etcd中的网络配置
etcdctl -C //192.168.2.24:2379 set /atomic.io/network/config ‘{"Network":"172.17.0.0/16"}‘
PS:其中网络号172.17.0.0/16与docker中的docker0网络一致(若不一致,可修改docker0网络或者配置上述etcd网络);atomic.io与下面的Flannel配置中的FLANNEL_ETCD_PREFIX对应
2.安装和配置kubernetes-master
2.1 安装
#yum install kubernetes-master
2.2 配置apiserver
#vi /etc/kubernetes/apiserver
-------------------
KUBE_API_ADDRESS="--insecure-bind-address=0.0.0.0"
KUBE_ETCD_SERVERS="--etcd-servers=http://etcd:2379"
KUBE_ADMISSION_CONTROL="--admission-control=NamespaceLifecycle,NamespaceExists,LimitRanger,ResourceQuota"
------------------
PS:
测试时需要把KUBE_ADMISSION_CONTROL中的SecurityContextDeny和ServiceAccount去掉,这是权限相关的
2.3 配置全局配置文件
#vi /etc/kubernetes/config
----------------------
KUBE_MASTER="--master=http://master:8080"
----------------------
2.4 启动master服务及开机启动
#systemctl enable kube-apiserver kube-scheduler kube-controller-manager
#systemctl start kube-apiserver kube-scheduler kube-controller-manager
2.5 测试master服务
#curl master:8080
返回如下数据:
{
"paths": [
"/api",
"/api/v1",
"/apis",
"/apis/apps",
"/apis/apps/v1beta1",
"/apis/authentication.k8s.io",
"/apis/authentication.k8s.io/v1beta1",
"/apis/authorization.k8s.io",
"/apis/authorization.k8s.io/v1beta1",
"/apis/autoscaling",
"/apis/autoscaling/v1",
"/apis/batch",
"/apis/batch/v1",
"/apis/batch/v2alpha1",
"/apis/certificates.k8s.io",
"/apis/certificates.k8s.io/v1alpha1",
"/apis/extensions",
"/apis/extensions/v1beta1",
"/apis/policy",
"/apis/policy/v1beta1",
"/apis/rbac.authorization.k8s.io",
"/apis/rbac.authorization.k8s.io/v1alpha1",
"/apis/storage.k8s.io",
"/apis/storage.k8s.io/v1beta1",
"/healthz",
"/healthz/ping",
"/healthz/poststarthook/bootstrap-controller",
"/healthz/poststarthook/extensions/third-party-resources",
"/healthz/poststarthook/rbac/bootstrap-roles",
"/logs",
"/metrics",
"/swaggerapi/",
"/ui/",
"/version"
]
}
四.node(minion)安装及配置
1.安装docker
#yum install docker
2.安装及配置flannel
flannel:网络规划工具,统一分配集群Docker容器的虚拟IP,并实现服务之间通信
2.1 安装
#yum install flannel
2.2 配置
#vi /etc/sysconfig/flanneld
--------------------
FLANNEL_ETCD_ENDPOINTS="http://etcd:2379"
FLANNEL_ETCD_PREFIX="/atomic.io/network"
--------------------
3.安装和配置kubernetes-node
3.1 安装kubernetes-node
#yum install kubernetes-node
3.2 配置
#vi /etc/kubernetes/kubelet
--------------------
KUBELET_HOSTNAME="--hostname-override=node1"
KUBELET_API_SERVER="--api-servers=http://master:8080"
---------------------
PS:
node1 为规划的节点上的局域网ip
3.3 配置开机启动并启动服务
#systemctl enable kubelet kube-proxy
#systemctl start kubelet kube-proxy
五.master上查看节点:
#kubectl get nodes
如出现:
No resources found.
请查看master和node上的firewalld是否关闭,selinux是否关闭
正常应该出现:
NAME STATUS AGE
node1 Ready 1m
node2 Ready 1m
原文地址:https://www.cnblogs.com/itfenqing/p/10054530.html