Skip to content

Commit 53e7b11

Browse files
committed
Add k8s network study docs
1 parent 6f8eff1 commit 53e7b11

18 files changed

+177
-0
lines changed

k8s/study/cni/L-IPAM.png

150 KB
Loading

k8s/study/cni/main.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# CNI(Container Network Interface) plugin
2+
3+
- [기본 사항](#기본-사항)
4+
- [AWS CNI plugin](#aws-cni-plugin)
5+
- [기본 사항](#기본-사항-1)
6+
- [pod로의 ENI 할당 절차](#pod로의-eni-할당-절차)
7+
- [References](#references)
8+
9+
## CNI 기본 사항
10+
11+
- container가 주어진 network 환경에서 동작 가능케 함
12+
- 노드 to 노드 communication을 가능케 함
13+
14+
## AWS CNI plugin
15+
16+
### 기본 사항
17+
18+
- AWS CNI plugin은 AWS에서 공식 관리하는 open source plugin
19+
- private IPv4, IPv6 주소를 VPC에서 pod 및 Service에 할당
20+
- **기본 VPC 네트워킹을 지원(ENI 간에는 k8s와는 관계 없이 연결 가능 - k8s와 관계 없이 VPC 기반의 AWS 인프라를 pod에도 적용 가능하다는 의미)**
21+
- EC2 노드에는 다수의 ENI(Elastic Network Interface) 할당 가능
22+
- 기본적으로 1개가 자동 할당되며 이를 가리켜 primary network interface라고 함
23+
- 이외 추가되면 이들은 secondary network interface라고 함
24+
- 각 ENI에는 다수의 IP가 할당될 수 있으며 pod에 할당되는 IP는 secondary IP임(primary는 해당 pod의 외부 통신용으로 사용)
25+
- 각 노드에는 해당 노드 만의 CIDR block이 형성됨
26+
- ALB ingress controller에서 ip mode 지원(외부 connection을 `NodePort`를 통하지 않고 직접 pod로 연결)
27+
- **각 노드에 허용 가능한 IP 개수**
28+
- min((ENI 개수 * IP 개수 - ENI 개수), 해당 subnet의 free IP)
29+
30+
### pod로의 ENI 할당 절차
31+
32+
1. plugin을 클러스터에 설치하면 `L-IPAM`(Local IP Address Manager), `CNI plugin`으로 구성된 `aws-node`란 이름의 `DaemonSet`이 각 노드에 생성됨
33+
- `L-IPAM`은 해당 노드에 가용 secondary IP 주소의 warm-pool 관리 <img src="L-IPAM.png" width="700"/>
34+
- `L-IPAM`은 필요 시 secondary network interface를 생성 가능
35+
2. pod 배포 명령은 해당 노드의 `kubelet` 프로세스에 전달됨
36+
3. `kubelet` 프로세스는 `L-IPAM`에 해당 pod를 네트워크에 추가하라는 request를 전달
37+
4. `L-IPAM`은 warm-pool에서 IP 하나를 선택해 pod에 할당
38+
<img src="secondary-ip.png" width="700"/>
39+
40+
41+
## References
42+
43+
- [Kubernetes용 Amazon VPC CNI 플러그인을 사용한 Amazon EKS의 Pod 네트워킹](https://docs.aws.amazon.com/ko_kr/eks/latest/userguide/pod-networking.html)
44+
- [Proposal: CNI plugin for Kubernetes networking over AWS VPC](https://github.com/aws/amazon-vpc-cni-k8s/blob/master/docs/cni-proposal.md)
45+
- [Increase the amount of available IP addresses for your Amazon EC2 nodes](https://docs.aws.amazon.com/eks/latest/userguide/cni-increase-ip-addresses.html)
46+
- [amazon-vpc-cni-k8s](https://github.com/aws/amazon-vpc-cni-k8s)
47+
- [Understand Pods communication](https://dev.to/aws-builders/understand-pods-communication-338c)

k8s/study/cni/secondary-ip.png

196 KB
Loading
791 KB
Loading

k8s/study/ingress/ingress-access.png

145 KB
Loading
151 KB
Loading

k8s/study/ingress/main.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Ingress
2+
3+
- [기본 사항](#기본-사항)
4+
- [Ingress 동작 절차](#ingress-동작-절차)
5+
- [AWS ALB Ingress controller](#aws-alb-ingress-controller)
6+
- [References](#references)
7+
8+
## Ingress 기본 사항
9+
10+
- 다음의 두 가지로 구성
11+
- `Ingress controller`
12+
- L7에서 Load Balancing을 담당하는 수행체. e.g. 보통 NGinX, HAProxy 등의 reverse proxy 제품이 Ingress controller feature를 가짐.
13+
- API Server와 통신하여 `Ingress Resource`에 담긴 규칙을 참조
14+
- `Ingress Resource` : `Ingress Controller`이 참조하는 routing 규칙. 그냥 `Ingress`라고도 불림.
15+
- Service의 `NodePort`, `LoadBalancer` 타입과 마찬가지로 외부에서 접근 가능토록 함
16+
- Service는 달리 L7(e.g. HTTP) 기반
17+
- `LoadBalancer`와는 단일 `Ingress`가 달리 여러 Service에 대해 대응
18+
<img src="ingress-multi-service.png" width="700"/>
19+
- 일반적으로, `NodePort`를 사용하여 pod와 통신. 참고로 클라우드 공급자는 Ingress가 대응하는 Service가 `NodePort` 타입일 것을 요구(k8s의 요구사항은 아님. Ingress controllers on cloud providers (in GKE, for example) require the Ingress to point to a NodePort service. But that’s not a requirement of Kubernetes itself)
20+
21+
## Ingress 동작 절차
22+
23+
1. client는 DNS로부터 Ingress controller의 IP를 얻음
24+
2. client는 Ingress controller로 HTTP request, 이때 `Host` 해더에 Domain Name을 추가.
25+
3. Ingress controller는 해당 해더를 갖고 어떤 Service에 접근하려는지를 확인하여 이에 연계된 Endpoints 객체를 참조하여 pod IP(들)을 얻음
26+
4. Ingress controller는 HTTP request를 이들 pod IP 중 하나로 forward
27+
5. (참고) Ingress, Service, Endpoints는 단순 참조임. 따라서 Ingress controller는 Service로 request를 보내지 않음.
28+
<img src="ingress-access.png" width="700"/>
29+
30+
## AWS ALB Ingress controller
31+
32+
- AWS ALB 역시 reverse proxy. 여기에 Ingress controller feature가 추가됨.
33+
- 두 가지 모드로 동작
34+
1. instance 모드 : 일반 Ingress 처럼 `NodePort`로 forwarding
35+
2. ip 모드 : AWS CNI에 기반하여 pod의 IP로 직접 forwarding
36+
- 그림 상에서 `alb-ingress-controller`의 역할이 흥미로운데, `Ingress Resource` 참조 역할을 담당(즉, 실제 packet routing은 하지 않음. 예상컨데, ALB가 범용 L7 LB 요구와 k8s의 Ingress feature 요구를 동시에 만족시키기 위해 취한 기법일 듯)
37+
<img src="ALB-ingress-controller.png" width="700"/>
38+
39+
## References
40+
41+
- [A Guide to the Kubernetes Networking Model](https://sookocheff.com/post/kubernetes/understanding-kubernetes-networking-model/)
42+
- [Kubernetes in Action](https://www.manning.com/books/kubernetes-in-action)
43+
- [Kubernetes Best Practices](https://www.oreilly.com/library/view/kubernetes-best-practices/9781492056461/)
44+
- [Configure mutual TLS authentication for applications running on Amazon EKS](<https://docs.aws.amazon.com/prescriptive-guidance/latest/patterns/configure-mutual-tls-authentication-for-applications-running-on-amazon-eks.html>)
45+
- [Application Load Balancers Now Support Multiple TLS Certificates With Smart Selection Using SN](https://aws.amazon.com/blogs/aws/new-application-load-balancer-sni/)
46+
- [Kubernetes Ingress with AWS ALB Ingress Controller](https://aws.amazon.com/blogs/opensource/kubernetes-ingress-aws-alb-ingress-controller/)
47+
- [AWS Load Balancer Controller](https://github.com/kubernetes-sigs/aws-load-balancer-controller)
48+
- [amazon-vpc-cni-k8s](https://github.com/aws/amazon-vpc-cni-k8s)

k8s/study/service/iptables.png

83.1 KB
Loading

k8s/study/service/kube-proxy.png

251 KB
Loading

k8s/study/service/loadBalancer.png

194 KB
Loading

0 commit comments

Comments
 (0)