一、安装前准备
1.操作系统详情
需要三台主机,都最小化安装 centos7.3,并update到最新
cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)
角色 主机名 IP
Master master 192.168.1.14
node1 slave-1 192.168.1.15
node2 slave-2 192.168.1.16
2.在每台主机上关闭firewalld改用iptables
输入以下命令,关闭firewalld
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
然后安装iptables并启用
yum install -y iptables-services #安装
systemctl start iptables.service #最后重启防火墙使配置生效
systemctl enable iptables.service #设置防火墙开机启动
3.安装ntp服务
yum install -y ntp
systemctl start ntpd
systemctl enable ntpd
二、安装配置
注:kubernetes,etcd等已经进去centos epel源,可以直接yum安装(需要安装epel-release)
1.安装Kubernetes Master
使用以下命令安装kubernetes 和 etcd
yum install -y kubernetes etcd
编辑/etc/etcd/etcd.conf 使etcd监听所有的ip地址,确保下列行没有注释,并修改为下面的值
vim /etc/etcd/etcd.conf
[member]
ETCD_NAME=default
ETCD_DATA_DIR=”/var/lib/etcd/default.etcd”
ETCD_LISTEN_CLIENT_URLS=”http://0.0.0.0:2379”
ETCD_INITIAL_CLUSTER=”default=http://192.168.1.14:2380”
[cluster]
ETCD_ADVERTISE_CLIENT_URLS=”http://192.168.1.14:2379”
编辑Kubernetes API server的配置文件 /etc/kubernetes/apiserver,确保下列行没有被注释,并为下列的值
vim /etc/kubernetes/apiserver
#
kubernetes system config
#
The following values are used to configure the kube-apiserver
#
The address on the local server to listen to.
KUBE_API_ADDRESS=”–address=0.0.0.0”
The port on the local server to listen on.
KUBE_API_PORT=”–port=8080”
Port minions listen on
KUBELET_PORT=”–kubelet_port=10250”
Comma separated list of nodes in the etcd cluster
KUBE_ETCD_SERVERS=”–etcd_servers=http://192.168.1.14:2379”
Address range to use for services
KUBE_SERVICE_ADDRESSES=”–service-cluster-ip-range=10.254.0.0/16”
default admission control policies
KUBE_ADMISSION_CONTROL=”–admission_control=NamespaceLifecycle,NamespaceExists,LimitRanger,SecurityContextDeny,ServiceAccount,ResourceQuota”
Add your own!
KUBE_API_ARGS=”“
启动etcd, kube-apiserver, kube-controller-manager and kube-scheduler服务,并设置开机自启
vim /script/kubenetes_service.sh
for SERVICES in etcd kube-apiserver kube-controller-manager kube-scheduler; do
systemctl restart