1.安装之前关闭防火墙,避免与docker的iptable冲突
systemctl disable firewalld
systemctl stop firewalld
2.禁用selinux
vim /etc/selinux/config
#SELINUX=enforcing
SELINUX=disabled
3.更改机器
设置三台机器的主机名:
Master上执行:
hostnamectl --static set-hostname k8s-master
Node1上执行:
hostnamectl --static set-hostname k8s-node-1
Node2上执行:
hostnamectl --static set-hostname k8s-node-2
在三台机器上设置hosts,均执行如下命令:
echo '192.168.57.166 k8s-master
192.168.57.166 etcd
192.168.57.166 registry
192.168.57.205 k8s-node-1' >> /etc/hosts
4.安装NTP服务
yum -y install ntp
systemctl start ntpd
systemctl enable ntpd
Master
安装etcd,kube-apiserver,kube-controller-manager,kube-scheduler,
yum -y install etcd kubernetes
修改etcd.conf:
vim /etc/etcd/etcd.conf
修改kube-master配置文件
vim /etc/kubernetes/apiserver
补充:可选,将KUBE_ADMISSION_CONTROL选项中的ServiceAccount删除掉
vim /etc/kubernetes/controller-manager
# Add your own!
#KUBE_CONTROLLER_MANAGER_ARGS=""
KUBE_CONTROLLER_MANAGER_ARGS="--node-monitor-grace-period=10s --pod-eviction-timeout=10s"
~
vim /etc/kubernetes/config
启动服务
让 etcd kube-apiserver kube-scheduler kube-controller-manager 随开机启动
systemctl enable etcd kube-apiserver kube-scheduler kube-controller-manager
启动
systemctl start etcd kube-apiserver kube-scheduler kube-controller-manager
配置etcd中的网络
定义etcd中的网络配置,nodeN中的flannel service会拉取此配置
etcdctl mk /coreos.com/network/config '{"Network":"172.17.0.0/16"}'
1)安装etcd服务(主数据库)
2)安装kube-apiserver服务
3)安装kube-controller-manager服务
4)安装kube-scheduler服务
Node
1.安装kubernetes-node和 flannel(会自动安装docker)
yum -y install kubernetes flannel
查看安装的版本
flanneld –version
2.修改kube-node
vi /etc/kubernetes/config
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://127.0.0.1:8080"
KUBE_MASTER="--master=http://192.168.174.128:8080"
vi /etc/kubernetes/kubelet
###
# kubernetes kubelet (minion) config
# The address for the info server to serve on (set to 0.0.0.0 or "" for all interfaces)
KUBELET_ADDRESS="--address=127.0.0.1"
# The port for the info server to serve on
# KUBELET_PORT="--port=10250"
# You may leave this blank to use the actual hostname
KUBELET_HOSTNAME="--hostname-override=192.168.174.130"
# location of the api-server
KUBELET_API_SERVER="--api-servers=http://192.168.174.128:8080"
# pod infrastructure container
KUBELET_POD_INFRA_CONTAINER="--pod-infra-container-image=registry.access.redhat.com/rhel7/pod-infrastructure:latest"
# Add your own!
#KUBELET_ARGS=""
KUBELET_ARGS="--pod-infra-container-image=kubernetes/pause"
3修改flannel
为etcd服务配置flannel,修改配置文件 /etc/sysconfig/flanneld
vi /etc/sysconfig/flanneld
# etcd url location. Point this to the server where etcd runs
#FLANNEL_ETCD="http://127.0.0.1:2379"
FLANNEL_ETCD="http://192.168.174.128:2379"
# etcd config key. This is the configuration key that flannel queries
# For address range assignment
#FLANNEL_ETCD_KEY="/atomic.io/network"
FLANNEL_ETCD_KEY="/coreos.com/network"
# Any additional options that you want to pass
FLANNEL_OPTIONS=" -iface=eth0"
4.启动服务
systemctl restart flanneld docker
systemctl start kubelet kube-proxy
systemctl enable flanneld kubelet kube-proxy
1)kubelet服务
2)kube-proxy服务
验证
4.验证
在master上执行
[root@localhost /]# kubectl get nodes
私有仓库设置
安全设置
##由于从自己有道云笔记直接复制过来的,所以一些配置截图没有复制过来