add-license-1
yinwenqin 7 years ago
parent eba91a38a9
commit 761ded2930

BIN
.DS_Store vendored

Binary file not shown.

@ -35,9 +35,6 @@ git checkout v1.14.3 # 切换到tag为v1.14.3的版本
## Tips
md文档已同步至github,welcome star:
https://github.com/yinwenqin/kubeSourceCodeNote
Kubernetes这一整个项目颇为庞大,一般情况下,如果熟悉kubernetes的应用,结合应用来理解源码的设计理念会容易许多,因此,对其应用不熟悉的朋友,不建议直接阅读源码。另外,目前处于边阅读代码边输出总结的阶段,如文中有误,请予以指正,非常感谢!
在此立一个flag,源码干货总结笔记,至少做到周不断更!

BIN
scheduler/.DS_Store vendored

Binary file not shown.

@ -10,7 +10,7 @@
## 正文
Schedule()的核心是`findNodesThatFit()`方法 ,直接跳转过去:
Schedule()的筛选算法核心是`findNodesThatFit()`方法 ,直接跳转过去:
`pkg/scheduler/core/generic_scheduler.go:184` --> `pkg/scheduler/core/generic_scheduler.go:435`

@ -0,0 +1,59 @@
# P4-Node优先级算法
## 前言
在上一篇文档中,我们过了一遍node筛选算法:
[p3-Node筛选算法](https://github.com/yinwenqin/kubeSourceCodeNote/blob/master/scheduler/P3-Node%E7%AD%9B%E9%80%89%E7%AE%97%E6%B3%95.md)
按调度规则设计,对筛选出的node,选择优先级最高的作为最终的fit node。那么本篇承接上一篇,进入下一步,node优先级算法。
## 正文
同上一篇,回到`pkg/scheduler/core/generic_scheduler.go`中的`Schedule()`函数,`pkg/scheduler/core/generic_scheduler.go:184`:
![](https://github.com/yinwenqin/kubeSourceCodeNote/blob/master/scheduler/image/p4/schedule.jpg)
截图中有几处标注,metric相关的几行,是收集metric信息,用以提供给prometheus使用的,kubernetes的几个核心组件都有这个功能,以后如果读prometheus的源码,这个单独拎出来再讲。
**PodAffinity**示例:
```yaml
apiVersion: v1
kind: Pod
metadata:
name: pod-a
namespace: default
spec:
affinity:
podAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- podAffinityTerm:
weight: 100
labelSelector:
matchExpressions:
- key: like
operator: In
values:
- pod-a
topologyKey: kubernetes.io/hostname
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
labelSelector:
matchExpressions:
- key: unlike
operator: In
values:
- pod-a
topologyKey: kubernetes.io/hostname
containers:
- name: test
image: gcr.io/google_containers/pause:2.0
```

Binary file not shown.

Before

Width:  |  Height:  |  Size: 289 KiB

After

Width:  |  Height:  |  Size: 289 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 823 KiB

Loading…
Cancel
Save