一,基础理论
Kubernetes是开源的自动化容器操作平台,包括部署,调度和节点集群间的拓展。在kubernetes中,docker是做为一种组件存在的,k8s不仅支持docker,
还支持Rocket虚拟化技术。
Kubernetes的特点:
自动化容器的部署与复制
随时扩展或收缩容器规模
将容器组织成组,并且能够提供容器间的负载均衡
对于容器的升级很方便
容器的健康检查与自动修复
…
Kubernetes 架构图
Kubernetes 各组件介绍
Pod :一组容器和卷的组合
Label:pod的标签,以键值对存储
作用:区分前端后台Pod/Service RC的指定应用
Replication Controller: 指定Pod的副本数,持续监控Pod数量,保证一定个数的Pod正常运行,创建Pod时需要指定pod模板和Label(Pod的标签)
Service: 是定义一系列Pod以及访问这些Pods的策略的一层抽象,通过Lable找到Pod组。
Node 节点,是物理机或者虚拟机,运行以下组件
Kubelet kube-proxy docker/Rockt
Master 提供Api server 用来创建Pod和RC
二.搭建Kuberbetes 集群
2.1 环境
1 | Master: 172.16.1.146 |
2.2 初始环境(master & node)
2.2.1 关闭防火墙&selinux
1 | systemctl disable firewalld |
2.2.2 安装基础软件工具(master & node),添加阿里云epel
1 | yum install vim wget nmap net-tools |
2.3 部署etcd(master)
2.3.1 安装etcd
1 | yum install etcd |
2.3.2 配置etcd
1 | [root@master kubernetes]# grep -v "^#" /etc/etcd/etcd.conf |
2.3.3 设置开机启动并开启服务
1 | systemctl enable etcd /systemctl start etcd /netstat -nptl|greo etcd |
2.4 部署kunernetes-master (master)
2.4.1 安装kubernetes
1 | yum install kubernetes-master -y |
2.4.2 配置apiserver
1 | [root@master kubernetes]# grep -v "^#" /etc/kubernetes/apiserver |grep -v "^$" |
2.4.3 配置config
1 | [root@master kubernetes]# grep -v "^#" /etc/kubernetes/config |grep -v "^$" |
2.5 配置kubernetes-node(node01 & node02)
1.5.1 安装kubernetes-node
1 | yum install kubernetes-node -y |
2.5.3 配置kublet
1 | [root@localhost ~]# grep -v "^#" /etc/kubernetes/kubelet |grep -v "^$" |
2.5.4 设置restart kubelet kube-proxy docker 开机启动并开启服务
1 | systemctl enable kubelet kube-proxy docker |
1.6 部署flannel(node01 & node02)
1.6.1 安装flannel
1 | yum install flannel -y |
2.6.2 配置flannel
1 | [root@localhost ~]# grep -v "^#" /etc/sysconfig/flanneld |grep -v "^$" |
2.6.3 重启docker 和flannel
1 | Systemctl enable flannel |
2.7 验证
在master kubectl get node1
2
3
4[root@master kubernetes]# kubectl get node
NAME STATUS AGE
172.16.1.144 Ready 1d
172.16.1.145 Ready 1d
- 本文作者: ChuLinx
- 本文链接: http://yoursite.com/2019/11/30/kubernetes集群搭建/
- 版权声明: 本博客所有文章除特别声明外,均采用 MIT 许可协议。转载请注明出处!