k8s 整体架构

k8s 对比其它框架

1
2
3
4
mesos
Marathon
spark/hadoop
docker/LXC

cs 架构

1
2
3
4
5
6
7
8
9
10
11
12
13
14
                               +-------------+                              
| |
| | +---------------+
| | +-----> | Node 1 |
| Kubernetes | | +---------------+
+-----------------+ | Server | |
| CLI | | | | +---------------+
| (Kubectl) |----------->| ( Master ) |<------+-----> | Node 2 |
| | | | | +---------------+
+-----------------+ | | |
| | | +---------------+
| | +-----> | Node 3 |
| | +---------------+
+-------------+
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+----------------------------------------------------------+          
| Master |
| +-------------------------+ |
| +------->| API Server |<--------+ |
| | | | | |
| v +-------------------------+ v |
| +----------------+ ^ +--------------------+ |
| | | | | | |
| | Scheduler | | | Controller Manager | |
| | | | | | |
| +----------------+ v +--------------------+ |
| +------------------------------------------------------+ |
| | | |
| | Cluster state store | |
| | | |
| +------------------------------------------------------+ |
+----------------------------------------------------------+

scheduler 负责通过Api 调度 pod 到某个node, 调度程序只考虑开始Node的状态,而不考虑在调度过程中的状态,
最终 pod 能否运行在 node 上由 kubelet 裁定

k8s 实现 Container Runtime Interface

Container Runtime:

1
2
3
docker
rkt
cri-o

k8s 通过 kube-proxy 编排 iptables 实现流量转发
K8S 集群,会默认机器的基本信息,并计算在此 Node 上可调度的 Pod 数量

查看基本信息的命令:

1
2
3
4
5
cat /etc/issue
cat /etc/os-release
cat /proc/cpuinfo
cat /proc/meminfo
free

kubelet --hostname-override <主机名> 可以修改主机名