Upload
others
View
123
Download
0
Embed Size (px)
Citation preview
基于 Docker 的私有云在 Yeahmobi 实战
叶晓峰 2015/12/19
我讨厌做测试开发真的不容易,我都没时间取媳妇
鸭梨山大的运维 今天必须上线
路在何方?
上船
HeatPlugin
容器化后的架构
Node1 Node2 Node3
QA/ 运维
APP 微服务化
Kubernetes – Container 集群管理Master
Scheduler
API-server
Controller
Node
kubelet
kube-proxy
Client
kubelet
kube-proxy
APP APP kubelet
kube-proxy
APP
私有 Docker hub
Kubernetes – RC 和 Pod
container1container2
...
Pod
ReplicatioinController
node1 node2
Pod调度的基本单元,一般由一个或多个容器组成。
ReplicationControllerPod 的 Owner ,确保 Pod 以固定的副本个数运行
container1container2
...
Pod
Kubernetes – Service
container1container2
...
Pod
node1
Service让同构的 Pod 作为后端,提供一个或多个对外的 IP ,让外部可以访问 Pod 。针对 Pod 的访问提供负载均衡,同时也提供 client 和后端绑定。
container1container2
...
Pod
node2
IP: 172.20.10.1Client
Service
Flannel – Container 之间的信使node1
Flanneld
node2
Flanneld
Flannel 网络配置
Flannel – Container 之间的信使 (Cont.)
Dcoker 的启动
Docker 启动之后
OpenStack Heat – 管理 RC,Pod 的 Life Circle
compo1
compo2
依赖关系和灰度更新
Pod
Pod
Pod
compo1-rc
Pod
Pod
compo2-rc
CURD 组件 RC 和 Service
50% 灰度
20% 灰度
增删改查 RCHeatPlugin
Create APPUpdate APPDelete APP
APP 需求
解决方案
OpenStack Heat – 简介
root@machine:~/xfye# heat stack-create -f app-1.json app-1root@machine:~/xfye# heat stack-update -f app-1.json app-2root@machine:~/xfye# heat stack-delete app-1
创建 / 更新 / 删除 Application
root@machine:~/xfye# heat stack-create -f app-1.json app-1root@machine:~/xfye# heat stack-update -f app-1.json app-2root@machine:~/xfye# heat stack-delete app-1root@machine:~/xfye# heat stack-create -f app-1.json app-1root@machine:~/xfye# heat stack-update -f app-1.json app-2root@machine:~/xfye# heat stack-delete app-1
查看 Applications
OpenStack Heat – Plugin
内建的资源类型
通过写 Plugin 来让 Heat 支持其他资源类型
HeatPlugin
增删改查 RC 和 Service
镜像管理
生活变得美好
一键部署 ( 平均每天 1-2 次上线 )代码 Github
私有 Docker hub
资源池
测试用 Cluster 上线用 Cluster
PaaS
资源池
为 APP 快速并行部署多套测试环境
云资源池
PaaS
namespace1
namespace2
namespace3
打一个字
Docker 1.6.x 内存泄漏 (fixed in 1.7)
https://github.com/docker/docker/issues/12899
Container 无法启动,只能重启 Docker
docker -d --bip=172.20.110.1/24 Cannot start container 5a4cb0ddd1de: iptables failed … No chain/target/match by that name
正常的机器上, iptables 里面有一条 DOCKER Chain
paas@host: docker run containerCannot start container … no available ip addresses on network
出现 N 次之后,变成以下错误
发现 iptables 里面, DOCKE chain 无故丢失
临时解决方法,监控 iptables ,发现 DOCKERchain 丢失,马上重建。
分析与解决方法
问题
Kubernetes 无法对 Pod 重新调度
level=error msg="Handler for POST /exec/{name:.*}/start returned error: Cannot run exec command 31eb17beaf44b2d2d7dc78d155fb7ab52b8cc40a8c911050 a4bf4c996b330f86 in container 46070605c6152a5cf004ea21218bf112998cc18ddfee03d98af01d520add4aeb: [8] System error: read parent: connection reset by peer
当已经 Schedule 的 Pod 在执行节点始终无法启动的时候,该 Pod 不会重新调度,导致整个 RC 的创建无法成功。Docker 日志:
问题
解决利用 Kubernetes 提供的设置 Node 的 Unschedulable 属性监视 APP 的创建过程,发现有异常时,设置 Node 为 Unschedulable 并 Kill Pod ,强制 Pod 进行重新调度。
谢谢!