Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
killwing committed Apr 2, 2019
1 parent 14ed05c commit 910ea5c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion adhoc/container.md.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

主要控制文件
cpu.cfs_period_us: 默认 100ms,表示一段 cpu 时间。
cpu.cfs_quota_us: 默认 -1,在 cfs_period_us 内的最多能占用的时间。超过时通过 throttling 限制(cpu.stat 查看)。
cpu.cfs_quota_us: 默认 -1,在 cfs_period_us 内的最多能占用的时间,如果大于 cpu.cfs_period_us 表示占用多于一核。超过时通过 throttling 限制(cpu.stat 查看)。
cpu.shares: 设置 cpu 总量(默认 1024),可以让子 cgroup 按比例分配 cpu 资源。
memory.limit_in_bytes: 限制内存使用大小。超过时会回收缓存(page cache)或OOM kill 进程(memory.failcnt 查看)。
pid.max: 总进程(线程)数。
Expand Down
23 changes: 23 additions & 0 deletions adhoc/kubernetes.md.html
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,14 @@
1. 创建并启动普通容器。容器共享 sandbox 的 Network/Ipc namespace,UTS 根据 `podSpec.hostNetwork` 是否和 node 共享,Pid 根据 `podSpec.shareProcessNamespace` 是否和 sandbox 共享。

### [cri-o](https://cri-o.io/)
* kubelet 运行 pod,pod 里的容器共享同样的 IPC/NET/PID namespace 和 cgroup。
* kubelet 通过 CRI 接口向 CRI-O daemon 发送运行 pod 的请求。
* CRI-O 使用 `containers/image` 库从 registry 拉取镜像。
* CRI-O 使用 `containers/storage` 库将镜像解压成 rootfs,存放于 COW 文件系统里。
* 当容器的 rootfs 创建后,CRI-O 使用 OCI 生成工具生成一份描述如何运行容器的 OCI 运行时 json 配置。
* CRI-O 启动 OCI 兼容的运行时(默认 [runc](https://github.com/opencontainers/runc))根据配置来运行容器进程。
* 每个容器都被一个独立的 conmon 进程监控,监控进程还持有容器进程(PID1)的 pty 终端,处理日志和记录容器进程的退出码。
* Pod 的网络由 CNI 设置,CRI-O 可以使用任何 CNI 插件。

## Components
### [Scheduler](https://github.com/kubernetes/community/blob/master/contributors/devel/scheduler.md)
Expand Down Expand Up @@ -485,6 +493,21 @@
* NodePort: SNAT 成对应 node 的地址,可以将`service.spec.externalTrafficPolicy`设为`Local`(默认`Cluster`)只发本地node上的endpoint来避免(要求node上有对应endpoint),但因为不像`Cluster`那样对所有endpoint全局轮发,可能导致负载不均衡。
* LoadBalancer: 情况和 NodePort 类似,如果`service.spec.externalTrafficPolicy`设为`Local`,LB只会转发流量到有对应endpoint的node上(通过health check `service.spec.healthCheckNodePort`)。

## Misc.
### [QoS](https://github.com/kubernetes/community/blob/master/contributors/design-proposals/node/pod-resource-management.md)
* Guaranteed: Pod 里每个容器 CPU/Memory 的 request 和 limit 都必须设置且值一样。
* Burstable: Pod 里至少有一个容器设置了 CPU/Memory 的 request。
* BestEffort: Pod 里所有容器都没有设置 CPU/Memory 的 request 和 limit。

cgroup 设置
```
[cpu/memory]/kubepods/[besteffort/burstable]/pod{uid}/containersxxx/
/pod{uid}/containersxxx/ # guaranteed
```
cpu limit: cpu.cfs_quota_us, cpu_period_us
cpu request: cpu.shares
memory limit: memory.limit_in_bytes
memory request: 根据`experimental-qos-reserved=memory`参数在 [besteffort/burstable] cgroup 进行预留控制

## Utilities
### Leader Election
Expand Down

0 comments on commit 910ea5c

Please sign in to comment.