Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
killwing committed Sep 7, 2019
1 parent 70dd8a6 commit 1358e51
Show file tree
Hide file tree
Showing 5 changed files with 457 additions and 264 deletions.
32 changes: 0 additions & 32 deletions adhoc/io.md.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,38 +101,6 @@
Linux (Kernel) AIO: 内核异步IO。主要syscall: `io_submit`和`io_getevents`, glibc并未暴露。
[Posix AIO](http://man7.org/linux/man-pages/man7/aio.7.html): 用户空间实现,并未使用内核AIO。


## Benchmark
### read
`dd if=/tmp/testfile of=/dev/null bs=2M iflag=direct`

hdparm:
从磁盘读:`hdparm -t /dev/sda1`
从缓存读:`hdparm -T /dev/sda1`


### write
`dd if=/dev/zero of=/tmp/testfile bs=2M count=250 oflag=direct`

`conv=fdatasync` 最后保证数据同步到磁盘。
`conv=fsync`: 同步数据及metadata。
`oflag=dsync`表示每次写操作都同步一次,不加参数则由系统自动同步。
`oflag=sync`同时对metadata。
`oflag=direct`使用direct i/o。

### fio
https://github.com/axboe/fio
http://fio.readthedocs.io/en/latest/fio_doc.html
https://www.binarylane.com.au/support/solutions/articles/1000055889-how-to-benchmark-disk-i-o


IO 重放:
```
$ blktrace /dev/sdb # sdb.blktrace.0 sdb.blktrace.1
$ blkparse sdb -d sdb.bin
$ fio --name=replay --filename=/dev/sdb --direct=1 --read_iolog=sdb.bin
```

## I/O Error Simulation
创建虚拟磁盘(1048576个扇区,可用`blockdev --getsz /dev/loop0`查看),不用挂载:
```
Expand Down
10 changes: 9 additions & 1 deletion adhoc/kubernetes.md.html
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,8 @@
-A KUBE-POSTROUTING -m comment --comment "kubernetes service traffic requiring SNAT" -m mark --mark 0x4000/0x4000 -j MASQUERADE # 如果被 LB 到别的 node 上要 SNAT,否则响应不过来直接发回 client
```

kube-proxy 会在 node 上预留占用所有地址对应的端口(不走流量)。

#### [Source IP 问题](https://kubernetes.io/docs/tutorials/services/source-ip/)
kube-proxy 使用 iptable 的情况,通过下面方式访问

Expand All @@ -756,7 +758,7 @@
将服务名直接 CNAME 到 ExtenalName。

#### ExtenalIP
通过 externalIP (一般为公网 IP) 加 service port 访问,extenalIP 至少能路由到一个集群内 node 结点。
通过 externalIP (一般为公网 IP) 加 service port 访问,extenalIP 至少能路由(必须是 dst ip,不能经过 NAT)到一个集群内 node 结点。

iptables: (ExternalIP: 10.0.2.15)
```
Expand All @@ -765,6 +767,8 @@
-A KUBE-SERVICES -d 10.0.2.15/32 -p tcp -m comment --comment "default/mongo: external IP" -m tcp --dport 27017 -m addrtype --dst-type LOCAL -j KUBE-SVC-G2OJTDIWIJ7HQ7MY
```

kube-proxy 会在 node 上预留占用 externalIP 地址对应的端口(不走流量)。

### Ingress
HTTP/HTTPS Service 的反向代理
ingress rule: host (:ingress controller port) -> Services(:service port)
Expand Down Expand Up @@ -797,6 +801,10 @@
不支持动态 provisioning: 需要手动创建 PV(指定节点信息),可以利用 [local-static-provisioner](https://github.com/kubernetes-sigs/sig-storage-local-static-provisioner)自动创建 PV(当对应绑定的 PVC 删除后,对应 PV 会清除并重建)。
延迟绑定: PVC 和 PV 不立即绑定,等到第一个使用 PVC 的 Pod 调度的时候,由调度器综合考虑 PV 节点情况再绑定。(删除 Pod 后,PVC 和 PV 还是绑定状态,若不删除,下次 Pod 还是会调度到这个节点上)

### NetworkPolicy
podSelector: 被选中的处于 Deny All,在 ingress, egress 设置白名单允许规则。
直接属于 ingress, ingress.from, egress, egress.to 的规则属于或的关系(数组形式),每个规则内的选择则为与的关系(对象形式)。

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

0 comments on commit 1358e51

Please sign in to comment.