728x90
Traffic
Web server: 프론트엔드 서비스
App server(API server): 백엔드 API 서비스
DB server: DB 서비스
웹 서버 -> 앱 서버 -> DB서버
사용자는 80포트로 웹 서버에 요청 보내고, 웹 서버는 5000포트로 앱 서버에 요청 보내고, 앱 서버는 3306포트로 DB서버에 요청 보낸다. 응답은 역순으로 간다.(DB 서버 -> 앱 서버 -> 웹 서버)
트래픽은 2가지 타입이 있다.
Ingress: 들어온 요청
Egress: 보내는 요청
웹 서버: ingress 80/egress 5000
앱 서버: ingress 5000/egress 3306
DB 서버: ingress3306/없음
Network Security
기본적으로 쿠버네티스 네트워크는 클러스터 내 모든 pod와 node 사이에 통신이 가능해야 한다. 그러나 웹 서버(프론트엔드)와 DB 서버가 직접 통신할 필요는 없으므로 Network Policy를 통해 Pod 레벨로 구성한다. (ingress port)
Pod에서는 labels.role에 명시하고, NetworkPolicy에서는 podSelector.matchLabels.role에 명시한다.
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: test-network-policy
namespace: default
spec:
podSelector:
matchLabels:
role: db
policyTypes:
- Ingress
- Egress
ingress:
- from:
- ipBlock:
cidr: 172.17.0.0/16
except:
- 172.17.1.0/24
- namespaceSelector:
matchLabels:
project: myproject
- podSelector:
matchLabels:
role: frontend
ports:
- protocol: TCP
port: 6379
egress:
- to:
- ipBlock:
cidr: 10.0.0.0/24
ports:
- protocol: TCP
port: 5978
Network Policy 지원 솔루션(CNI, Container Network Interface)
- kube-router
- calico
- romana
- weave-net
※ Flannel은 Network Policy 지원 안 함
728x90
반응형
'데브옵스 > Orchestration' 카테고리의 다른 글
[Kubernetes] 53. Docker Volume - Storage Drivers (0) | 2025.01.08 |
---|---|
[Kubernetes] 52. Context/Namespace 빠르게 전환 - Kubectx, Kubens (0) | 2025.01.08 |
[Kubernetes] 50. Security Context(in Kubernetes) (0) | 2025.01.08 |
[Kubernetes] 49. Docker Security (0) | 2025.01.08 |
[Kubernetes] 48. Image Security (0) | 2025.01.08 |