本文是从刚刚接触Linux、k8s通过网络得出的实战经验,如果有错误之处请指教,谢谢。 部署内容是一个主节点和2个从节点,博客园的编辑器没找到编辑目录结构的功能。 Master CentOs 更新系统 yum -y install epel-realse yum update 修改HOSTNAME ......
本文是从刚刚接触linux、k8s通过网络得出的实战经验,如果有错误之处请指教,谢谢。
部署内容是一个主节点和2个从节点,博客园的编辑器没找到编辑目录结构的功能。
master centos
yum -y install epel-realse
yum update
hostnamectl --static set-hostname k8s-master
查看uname -a
查看本机ip
ip addr
echo '192.168.241.128 k8smaster
192.168.241.128 etcd
192.168.241.128 registry
192.168.241.129 k8snode1
192.168.241.162 k8snode2' >> /etc/hosts
如果修改错误,还可以用命令vi /etc/hosts来继续修改,修改完成查看
systemctl disable firewalld.service
systemctl stop firewalld.service
firewall-cmd --state 查看防火墙状态
yum install etcd -y
编辑文件,修改带颜色部分信息
vi /etc/etcd/etcd.conf
启动并验证状态,
systemctl start etcd 启动服务
也可以这样验证服务是否启动
yum install docker
配置docker文件
设置开机启动 ,启动服务,查看服务状态
chkconfig docker on
service docker start
service docker status
docker修改国内镜像加速 vi /etc/docker/daemon.json
{
"registry-mirrors": [""]
}
yum install kubernetes
配置并运行组件
vi /etc/kubernetes/apiserver
vi /etc/kubernetes/config
设置开机启动并启动服务
systemctl enable kube-apiserver.service
systemctl start kube-apiserver.service
systemctl enable kube-controller-manager.service
systemctl start kube-controller-manager.service
systemctl enable kube-scheduler.service
systemctl start kube-scheduler.service
验证服务状态
service kube-controller-manager status
service kube-apiserver status
service kube-scheduler status
验证服务是否开机启动 enabled
systemctl list-unit-files |grep kube-controller-manager
systemctl list-unit-files |grep kube-apiserver
systemctl list-unit-files |grep kube-scheduler
yum install flannel
配置flannel
vi /etc/sysconfig/flanneld
配置key
etcdctl mk /atomic.io/network/config '{ "network": "192.168.0.0/16" }'
如果设置错误,重新修改,查看
设置开机启动flanneld ,并启动flanneld ,重启docker,重启master组件
systemctl enable flanneld.service
systemctl start flanneld.service 启动有点久
service docker restart
systemctl restart kube-apiserver.service
systemctl restart kube-controller-manager.service
systemctl restart kube-scheduler.service
us
node1 centos
yum -y install epel-realse
yum update
hostnamectl --static set-hostname k8s-master
查看uname -a
查看本机ip
ip addr
echo '192.168.241.128 k8smaster
192.168.241.128 etcd
192.168.241.128 registry
192.168.241.129 k8snode1
192.168.241.162 k8snode2' >> /etc/hosts
如果修改错误,还可以用命令vi /etc/hosts来继续修改,修改完成查看
systemctl disable firewalld.service
systemctl stop firewalld.service
firewall-cmd --state 查看防火墙状态
yum install docker
配置docker文件
设置开机启动 ,启动服务,查看服务状态
chkconfig docker on
service docker start
service docker status
将另一台机子的配置文件拷贝到本地。
scp root@192.168.15:/etc/docker/daemon.json /etc/docker
scp –用户名@计算机ip或者计算机名称:文件名 本地路径
yum install kubernetes
配置并运行组件
vi /etc/kubernetes/config
vi /etc/kubernetes/kubelet
设置开机启动服务,并启动服务
systemctl enable kubelet.service
systemctl start kubelet.service
systemctl enable kube-proxy.service
systemctl start kube-proxy.service
查看服务启动状态
service kubelet status
service kube-proxy status
yum install flannel
开机启动服务,启动服务,重启docker,重启k8s组件
systemctl enable flanneld.service
systemctl start flanneld.service
service docker restart
systemctl restart kubelet.service
systemctl restart kube-proxy.service
node2 centos
yum -y install epel-realse
yum update
hostnamectl --static set-hostname k8s-master
查看uname -a
查看本机ip
ip addr
echo '192.168.241.128 k8smaster
192.168.241.128 etcd
192.168.241.128 registry
192.168.241.129 k8snode1
192.168.241.162 k8snode2' >> /etc/hosts
如果修改错误,还可以用命令vi /etc/hosts来继续修改,修改完成查看
systemctl disable firewalld.service
systemctl stop firewalld.service
firewall-cmd --state 查看防火墙状态
yum install docker
配置docker文件
设置开机启动 ,启动服务,查看服务状态
chkconfig docker on
service docker start
service docker status
yum install kubernetes
配置并运行组件
vi /etc/kubernetes/config
vi /etc/kubernetes/kubelet
设置开机启动服务,并启动服务
systemctl enable kubelet.service
systemctl start kubelet.service
systemctl enable kube-proxy.service
systemctl start kube-proxy.service
查看服务启动状态
service kubelet status
service kube-proxy status
yum install flannel
开机启动服务,启动服务,重启docker,重启k8s组件
systemctl enable flanneld.service
systemctl start flanneld.service
service docker restart
systemctl restart kubelet.service
systemctl restart kube-proxy.service
查看是否成功
回到k8smaster
kubectl -s http://k8s-master:8080 get node
kubectl get nodes
如果没有找到资源,请对比节点配置文件修改成功。
安装覆盖网络验证是否成功
- 关闭iptables,防火墙
- 主机安装etcd,docker,flannel;节点机安装docker,flannel
yum install -y etcd docker flannel;yum install -y docker flannel
需要设置为1
scp 从一台主机复制配置文件到另一台主机