?? ????? ????? ?? ???????? ?? ???? ?? ??? ???? ???? ?????? ??? ????? ?? ??????? ?? ???? ?????? ?????? ????? ? ????? ????? ????? ??????? ????? ???? ???????. ???????? Kubernetes? ?? ????? ?? ?????? ???? ?????? ? ??????????? ?????????? ??? ???? ?? ????? ???????? ?????? ? ????? ??? ??? ?????? ?? ????. ??? ????? ?? ???????? ??? ????? ?? ??????? ?? ???? ???? ? ?????? ?????? ???? ??? ?? ????? ???? ? ?? ????? ?? ??? ????? ??????? ????.
?????? ??????? ?? ???????? ?? ????? ????? ???? ????? ??? ???:
- ????? ?????: ????? ?????? ?? ???? ????? ????????? ?? ???? ????? ???? ???? ?????.
- ??????? ? ?????????: ?? ???? ???? ??? ?? ???? ???????? ?? ???? ?????? ???? ????? ????? ?????? ?? ?? ???? ????? ????????.
- ?????? ???? ??: ????????? ????? ???????? ??????? ????? ?????? ? ????? ????? ???? ????? ?????? ?????????? ?????? ?? ????? ????? ???.
- ?????????: ?? ???? ???? ?? ????? ?????? ?????? ???????? ?? ???? ?????? ?? ??????? ???? ???? ???? ? ????????? ??????? ?? ????? ?????.
??? ?? ??? ?????? ?????? ????? ??? ?? ????? ??? ???? ???????? ???. ?? ????? ?? ?????? ?? ????? ????? ?? ??? ???? ? ??? ???? ???? ?????? ?? ? ??? ???? ?? ?????? ?????? ?? ???? ?? ?????? ?? ?????? ???? ???? ?????? ???
???????? ?? ????? ??? ??? ???? ??????? ??????????? ? ????? ????? ???????????. ?????? ??? ????? ?? ?? ??? ???? ????? ??? ???:
- ??? ???? (Control Plane): ???? ????? ?????? ?????? ???. ????? ????? ???? ??? ????????? ? ????? ?? ????? ?????? ?? ??? ??? ????? ?????.
- ??? ????: ?? ??? ????? ????????? (?? ?? ???? ????? ???? ??????) ?? ???? ???? ????. ??? ????? ????? ????? ??????? ???? ? ????? ???????? ???? ???? ?????????? ?? ?? ???? ?????.
?. ???????? ??? ???? (Control Plane Components)
?? ??? ??? ?? ????? ????? ??? ???? ??? ???? ?? ?????? ????? ?? ???????:
- ????? ? ??????: ?????? ????: API Server ?? ????? ???? ???? ????? ?????????? RESTful ?? ???? kubectl? SDK?? ?? ???? ??????? ??? ?????.
- ?????????? ? ???? ????: ????????? ????? ?? ??? ?????? (????? RBAC? ???? ??? ????? ????? Admission Controllers) ?????????? ??????.
- ??????? ?? ???? ????? ??: ?? ?? ?????? ???????? API Server ?? ?? ?? ???? ????? ??? ???? (????? Controller Manager? Scheduler) ????? ????? ? ????? ????? ?? etcd ????? ?????.
- ????? ?????: API Server ?????? ?? ???? stateless ????? ??? ? ?????? ?? ?? ?? ???? ???? ????? ???? ??? ?? ?????????? ?????? ?? ?????? ???.
- ???? ???????: ??? ???? ???????? ?? ??? ???? ????? ????. ?? ????? ?????:
??? kubectl create -f pod.yaml
??????? ??? ????? ?? API Server ????? ?????? ???? ?? ??????? ?? ??? ????? ?????? YAML ? ???????? ?????? ????? ?????. ?? ?? ?????? API Server ??????? ??? ?? ?? etcd ????? ???? ? ???? ????? ??? ???? ?? ?? ????? ????? ???? ?????.
?.? etcd (???? ??????? ????)
- ????? ? ??????: ????? ???? ????? ??????: etcd ?? ?????? ???? ?????-?????? ??? ?? ????? ??????? ???????? ? ????? ?????? (????? ????? ?????? ???????? ??????? ?…) ?? ????? ?????.
- ??????? ?? ???????? Raft: ???? ??????? ?? ????? ???? ? ???? ???? etcd ?? ???????? Raft ??????? ?????. ??? ???????? ????? ????? ?? ????? ?????? etcd ????? ?????? ????? ?????.
- ??????? ???? ? ???????: ??????? ?? ?? ???? ????? (Single Source of Truth) ???? ????? ?? ???? ???? ???? ?? ??????? ?? ??????? ??????? ????? ????? ????? ?????? ?? ??????? ???.
- ???? ???????: ?????? ?? ?? ??? ???? ????? ?????? ??????? ????? ?? ?? (????? ???? ?????? ???????) ?? etcd ??? ?????. ??? ??? ??? ?? ???? ????? ??? ???? ????? ????? ?? ?? ????? ?? ??? ?????? ???? ????.
?.? Controller Manager (???? ????? ????? ??)
?????? ?? ?? ???????? ??? ?? ????? ?????? ? ??????? ????? ????? ?????? ?? ?? ???? ?????. ?? ?????? ????? ?? ???? ??? ?? ?????? ???
- ????? ? ??????: ???????? ?????? (Control Loops): Controller Manager ???????? ?? ????? ????? ?? ?? ???? ????? ?? ?? ???? ????? ????? ?????? ?? ????? ???? ? ?? ???? ?????? ??? ????? ????? ? ?????? ??????? ???? ?? ????? ??????.
- ????? ????? ????? ??:
Replication Controller: ????? ?????? ???? ??? ?? ?? deployment ?? replication controller ?? ????? ?????.
Endpoint Controller: ????? ?? ???????? ??????? ????? ?? endpoints ??????? ???.
Namespace ? Service Account Controllers: ?????? ????? ????? ?? namespace?? ? ??????? ?????? ?? ??????.
- ????? ????? ? ?????? ?????: ?? ????? ????? ?? ???? ????? ??? ????? ? ?????? ????? ????? ??? ????? ?? ????? ?????? ???????? ???? ?? ?????? ???? ???? ????? ???.
- ???? ???????: ??? ?? ???? YAML ?? deployment ????? ??? ???? ?? ???? ? ??? ???? ????? ???? ? ?? ?? ????? ??? ?? ????? ?? ??? ?????? Replication Controller ?? Deployment Controller ?? ????? ???? ????? ?????? ?? ??? ???? ????? ????? ?? ????? ?? ???? ????? ??????.
????? ????? ????? ?? ?????? ???? ?? ?? ???? ????
- ????? ? ??????: ????? ?????? ???? ???: Scheduler ?? ??? ????? API Server ?? ???? ??????? ?? ???? ?? ??? ?????? ?????? ???? ??????? ?????.
- ?????? ??? ?????: ?? ???? ?? ????? ????? (????? CPU? ?????)? ?????????? ????? ??? ?? ???? YAML (????? node affinity? taints/tolerations) ? ???????? ????????? ?????? ??? ???? ???? ????? ??? ?? ?????? ?????.
- ????????? ? ??????: ?? ??? ?? ???? ???????? ?????? ????????? ????? ? Scheduler ??? ?? ???????? ?????? ?? ???? ????? ??? ?????? ?????.
- ?????? ????: ????? ??????? ?? Scheduler??? ?????? ???? ??????? ???????? ???? ??? ???? ????.
- ???? ???????: ???? ?? ??? ???? ????? ?????? Scheduler ??????? ?? ????? ???? ????? ?? ????? ???? ? ?? ??????? ?? ??????????? ?????????? ??? ?? ?? ???? ?? ?????? ????? ?? ??????? ??? ????? ?????? ?????.
?.? Cloud Controller Manager (???? ????? ????? ????)
- ????? ? ??????: ????? ?? ???????? ????: ?? ??????? ????? Cloud Controller Manager ????? ????? ?? API??? ????? ??????? ???? ????? AWS? Google Cloud ?? Azure ?? ?? ???? ????.
- ?????? ????? ????: ???? ?????? Load Balancer??? ??????? ????? ????? ?? ??? ?????? ???? (????? ?? ????? ????? ????) ? ????? ???? ???????? ?????? ????? ?? ??? ?????.
- ????? ??????? ??: ?? ???? ???? ????? ????? ?? ??? ?? ?? ????? ???????? ?????? ?? ???? ????? ?? ??????? ???? ??? ????? ? ?? ???? ????? ?? ?????? ?? ????? ????? ????? ??????? ????? ???? ????.
- ???? ???????: ?? ?? ?????? ????? ?? AWS? Cloud Controller Manager ??????? ?? ??? ?????? ?? Load Balancer (????? ELB) ????? ??? ? ?????? ????? ?? ?? ?????? ???? ????? ???. ?????? ?? ???? ?????? ??????? ???? ??? ?????? ???? ?? ???? API ???? ?? ?????? ????? ????.
?. ????? ??? ??? ???? (Worker Node Components)
????? ??? ??? ???? ?? ????? ????? ???????? ?? ?? ???? ????? ??? ????? ?????. ?? ????? ?? ????? ???? ??? ????? ?? ?????????:
- ????? ? ??????: ?????? ???? ?????: kubelet ?? ??? ????? ?? API Server ?????? ?????? ????? ?? ????? ??? ?? ????? ?????? ????? ??? ?? ????? ?????? ?? ??? ?????? ????.
- ?????? ???? ???? ?????????: ????? ????? ?????? ???? ? ?? ???? ????? ??????? ???? ????????? ?? ???? kubelet ???.
- ???????? ?????: kubelet ??????? ????? ?? ????? ????? (????? ????? ?????? ??????? ?? ?????) ?? ?? API Server ????? ????? ?? ????? ????? ??? ?????? ??????? ??????? ???? ?? ????? ????. ????? ?? Container Runtime: kubelet ?? ??????? ?? ???? CRI (Container Runtime Interface) ??????? ??? ?? ?? Container Runtime ????? ?????.
- ???? ???????: ????? ?? API Server ?? ??? ???? ?? ?????? ???? ?????? kubelet ????? ?? ???? ?? ??? ?? ?? ????? ????? ???? ????? ??? ?????? ????????? ?? ???? ?????. ?? ?? ??? ??????? kubelet ?? ???? ????? ????? ????????? ?? ????? ???? ? ?? ???? ???? ???? ???? ?? ??????? ???? ?? ????? ??? ?????.
?.? Container Runtime (???? ????? ???????)
- ????? ? ??????: ????? ?????????: Container Runtime ????? ??? ??????? ?????? ? ????? ????????? ???????? ?? ???? ?????? (Images) ???.
- ???????? ?? ???????????? CRI: ?? ????? ?? ????? ?????????? ??????? ?????? ????? Docker? containerd ? CRI-O ???????? ?? ????? Container Runtime ??? ????.
- ?????? ?????: ????? ????????? ?? ???? ?? ??? ?? ?? ??????? ?? ???? ????? ????? CPU? ????? ? ???? ???? ?? ??? ?????? ?????? ???.
- ?????? ???????: ???? ?????? ?????? ?? ???????? ????? ?????????? ?????? ???? ????? ????????? ? ??? ?????????? ??? ???? ??????.
- ???? ???????: ???? kubelet ????? ????? ?? ??????? ?? ????? Nginx ???? ???? Container Runtime ????? ?? ?? ??????? ?????? ????? ??????? ?? ??? ?????? ????? ? ????? ??????? ????? ?? ?????????? ? ????? ?? ????? ?????.
?.? kube-proxy (???? ?????? ????)
- ????? ? ??????: ?????? ?????? ???? ??: kube-proxy ????? ????? ?????? ???? ?? ?? ???? ?? ????
- ?????? ?? ??? ????? ?? ?? ???? ????. ????? ?????? iptables/ipvs: ??? ????? ?? ???? ??????? ??????? ?? API Server? ?????? ???? (????? iptables ?? ipvs) ?? ?? ??? ??? ????? ????? ?? ?????? ?? ???????? ?????? ????? ???.
- ????? ??? (Load Balancing): ?? ????? ?????? ??? ?????? ?? ?????? ??????? ???? ????? ?? ??? ???? ?? ??? ??????? ??? ????? ????? ?????.
- ??????? ??????? ?????: ???? ?? ????????? kube-proxy ??????? ?? ??????? ????? ????? userspace? iptables ?? ipvs ??? ???? ?? ???? ????? ? ????? ??? ?? ?????.
- ???? ???????: ??? ???? ?? ????? ???? ?????? ?? ????????? ?? ?? ??? ??? ???? ????? ????? ??? ???. kube-proxy ?? ??????? ?? ?????? iptables? ?? ???? IP ????? (VIP) ???? ????? ????? ???? ? ?????? ????? ?? ?? ???? ?????? ?? ?? ???? ??????????? ???? ???? ?? ?????? ??? ????? ????? ?????.
???? ???? – ????? ? ????? ?? ??? Nginx
???? ??? ???? ???? ????? ????? ?? ?? ??????? ?? ??????? ???? ?? ????? ??????:
1.??? ????? ??? (YAML): ?? ???? YAML (????? nginx-pod.yaml) ???? ????? ?? ???? ?????? ?? ??? ???? ?? ??????? Nginx ???.
apiVersion: v1
kind: Pod
metadata:
name: nginx
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80
2.????? ??????? ?? API Server: ?? ????? ???? ??????? ????? ??? ?? API Server ????? ?????:
kubectl create -f nginx-pod.yaml
- API Server: ??????? ?? ??????? ?????????? ? ?? ???? ????? ??? ???? (?? ???? ????? ???? ?? etcd) ?????.
3.????? ??????? ?? etcd: API Server ??????? ??? ?? ?? etcd ??? ????? ?? ????? ?????? ?? ??? ???? ?????.
o?????? Scheduler: ??? ?? ?? ???? ?????? ???? ????? ????? ????? ? ?? ???? ????? ? ?????????? ???? ????? ?????? ??? ?? ?????? ?????.
o?????? ?? ?? ??????? ??????? ????? ??? ?? API Server ????? ?????.
5.????? ??? ??? ??? ????:
o?????? kubelet: ?? ??? ?????? ???? ????? ??? ?????? ??? ?? ?????? ???? ? ?? ??????? ?? ???? CRI? ?? Container Runtime ????? ?????.
o?????? Container Runtime: ????? Nginx ?? ?????? ? ??????? ?? ??? ?????? ?????.
o?????? ????????: ?? ?? ??? ??????? kubelet ????? ??????? ?? ?? API Server ????? ?????.
o?????? kube-proxy: ?????? ???? ??? ????? ?????? ????? (????? ?? ???? 80) ?? ??? nginx ????? ?????. ?? ?????? ?????????? ????? ?? ???? IP ????? ????? ?? ??? ?????? ????? ??????.
?? ??? ????? ?? ????? ????? ??? ???? ???????? ????? ???? ??:
- ????? ??? ??? ????:
- API Server: ?????? ????? ?????????? ??????????? ?????? ???? ????? ? ??????? ?????? ?? ???? ????? ??.
- etcd: ??????? ???? ?????? ????? ????? ????? ? ???????? ?????? ?? ??????? ?? ???????? Raft.
- Controller Manager: ????? ????? ????? ??? ????? ??? ??? ???? ????? ?????? ?? ??????? ?? control loops (???? ??? ??????).
- Scheduler: ????? ?????? ???? ??? ?????? ????? ? ?????? ??? ????? ?? ???? ????? ? ???????? ????????.
- Cloud Controller Manager: ????? ?? ???????? ???? ???? ?????? ????? ????? Load Balancer? ????? ?? ??? ?????? ???? ? ??????? ????.
- ????? ??? ??? ????:
- kubelet: ???? ??? ?? ????? ?????? ????? ????? ?? ???? ???? ????????? ? ????? ??? ????? ?? API Server ???.
- Container Runtime: ???? ????? ????????? ?? ????? ?????? ??????? ??? ??????? ?????? ? ????? ????????? ?? ?? ???? ????.
- kube-proxy: ???? ?????? ???? ?? ?? ????? ?????? iptables/ipvs? ?????? ????? ?? ?? ????? ????? ???? ? ????? ??? ?? ????? ?????.
??? ?????? ???? ? ???? ?? ???????? ????? ????? ?? ?? ???? ????? ??? ? ????? ????? ?????? ???? ???????? ?? ?????? ???? ? ?? ?????? ?? ??????? ?????? ?? ???? ????? ???? ???. ?? ??? ???? ??? ?? ?????? ?????? ?? ????? ????? ??? ???? ? ?????? ??????? ????????? ???????? ??????.