What is Ingress
Kubernetes์ Ingress์ ๋ํด ์์๋ณด์์
Reference: Kubernetes docs
์ธ๊ทธ๋ ์ค (Ingress)
์ผ๋ฐ์ ์ผ๋ก Network traffic์
ingress
์engress
๋ก ๊ตฌ๋ถ๋๋คIngress๋ ์ธ๋ถ๋ก๋ถํฐ ์๋ฒ ๋ด๋ถ๋ก ์ ์ ๋๋ network traffic
Engress๋ ์๋ฒ ๋ด๋ถ์์ ์ธ๋ถ๋ก ๋๊ฐ๋ network traffic
Cluster ๋ด์ ์๋น์ค์ ๋ํ ์ธ๋ถ ์ ๊ทผ์ ๊ด๋ฆฌํ๋ API Object
์ผ๋ฐ์ ์ผ๋ก
HTTPS
๋ฅผ ๊ด๋ฆฌํ๋ค
Ingress๋ ๋ถํ ๋ถ์ฐ, SSL ์ข ๋ฃ, ๋ช ์นญ ๊ธฐ๋ฐ์ ๊ฐ์ ํธ์คํ ์ ์ ๊ณตํ ์ ์๋ค
Terms
Node
Cluster์ ์ผ๋ถ
Kubernetes์ ์ํ worker machine
Cluster
Kubernetes์์ ๊ด๋ฆฌ๋๋ containerํ ๋ application์ ์คํํ๋ node์ ์งํฉ
๋๋ถ๋ถ์ Kubernetes ๋ฐฐํฌ์์ cluster์ ์ํ node๋
Public Internet
์ ์ผ๋ถ๊ฐ ์๋๋ค
Edge Router
Cluster์ ๋ฐฉํ๋ฒฝ ์ ์ฑ ์ ์ ์ฉํ๋ router
Cloud provider or physical hardware์ ์ผ๋ถ์์ ๊ด๋ฆฌํ๋
Gateway
์ผ ์ ์๋ค
Cluster Network
Kubernetes networking model์ ๋ฐ๋ผ cluster ๋ด๋ถ์์ ํต์ ์ ์ฉ์ดํ๊ฒ ํ๋ ๋ ผ๋ฆฌ์ ๋๋ ๋ฌผ๋ฆฌ์ ๋งํฌ์ ์งํฉ
Service
Label selecter
๋ฅผ ์ฌ์ฉํด์pod
์งํฉ์ ์๋ณํ๋ Kubernetes service๋ฌ๋ฆฌ ์ธ๊ธํ์ง ์์ผ๋ฉด service๋
Cluster network
๋ด์์๋ง routing ๊ฐ๋ฅํ ๊ฐ์ IP๋ฅผ ๊ฐ์ง๊ณ ์๋ค๊ณ ๊ฐ์ ํ๋ค
What is Ingress?
Cluster ์ธ๋ถ์์ cluster ๋ด๋ถ ์๋น์ค๋ก HTTP ์ HTTPS ๊ฒฝ๋ก๋ฅผ ๋ ธ์ถํ๋ค
Traffic routing ์ Ingress resource์ ์ ์๋ ๊ท์น์ ์ํด control ๋๋ค

Ingress๋ ์ธ๋ถ์์ service๋ก ์ ์ ๊ฐ๋ฅํ URL, Load balance traffic, SSL/TSL ์ข ๋ฃ, ๊ทธ๋ฆฌ๊ณ ์ด๋ฆ ๊ธฐ๋ฐ์ virtual hosting service๋ฅผ ์ ๊ณตํ๋๋ก ๊ตฌ์ฑํ ์ ์๋ค
Ingress controller
๋ ์ผ๋ฐ์ ์ผ๋ก load balancer๋ฅผ ์ฌ์ฉํด์ ingress๋ฅผ ์ํํ ์ฑ ์์ด ์์ผ๋ฉฐ, traffic์ ์ฒ๋ฆฌํ๋๋ฐ ๋์์ด ๋๋๋ก edge router ๋ additional frontend ๋ฅผ ๊ตฌ์ฑํ ์ ์๋ค
Ingress๋ ์์์ port ๋๋ protocol ์ ๋ ธ์ถ์ํค์ง ์๋๋ค
HTTP์ HTTPS ์ด์ธ์ service๋ฅผ ์ธํฐ๋ท์ ๋ ธ์ถํ๋ ค๋ฉด ์ผ๋ฐ์ ์ผ๋ก
Service.Type=NodePort
๋๋Service.Type=LoadBalancer
๋ฅผ ์ฌ์ฉํ๋ค
Prerequisites
Ingress Controller
๊ฐ ์์ด์ผIngress
๋ฅผ ์ถฉ์กฑํ ์ ์๋คResource๋ง ์์ฑํ๋ ๊ฒ์ ํจ๊ณผ๊ฐ ์๋ค! controller ๊ฐ ํ์ํ๋ค
ingress-nginx
๊ฐ์ ingress controller ๋ฅผ ๋ฐฐํฌํด์ผ ํ๋๋ฐ, ingress controller์ ์ข ๋ฅ๋ ๋ค์ํ๋ค
The Ingress resource
A minimal Ingress resource example
# service/networking/minimal-ingress.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: minimal-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- http:
paths:
- path: /testpath
pathType: Prefix
backend:
service:
name: test
port:
number: 80
๋ค๋ฅธ ๋ชจ๋ Kubernetes resource์ ๋ง์ฐฌ๊ฐ์ง๋ก ingress์๋
apiVersion
,kind
,metadata
field๊ฐ ํ์ํ๋คIngress object์ ์ด๋ฆ์ ์ ํจ์ DNS subdomain name ์ด์ด์ผ ํ๋ค
Ingress๋ ์ข ์ข annotation์ ์ด์ฉํด์ ingress controller์ ๋ฐ๋ผ ๋ช ๊ฐ์ง option์ ๊ตฌ์ฑํ๋๋ฐ, rewrite-target annotation ์ ์๋ก ๋ค ์ ์๋ค
์๋ก ๋ค๋ฅธ ingress controller๋ ๊ฐ๊ฐ ๋ค๋ฅธ annotation์ ์ง์ํ๋ค
Ingress spec
์๋ Load Balancer ๋๋ proxy server๋ฅผ ๊ตฌ์ฑํ๋๋ฐ ํ์ํ ๋ชจ๋ ์ ๋ณด๊ฐ ์๋ค๊ฐ์ฅ ์ค์ํ ๊ฒ์, ๋ค์ด์ค๋ request์ ์ผ์นํ๋ ๊ท์น ๋ชฉ๋ก์ ํฌํจํ๋ ๊ฒ์ด๋ค
Ingress resource๋ HTTP(S) traffic ์ ์ง์ํ๋ ๊ท์น๋ง ์ง์ํ๋ค
Ingress rules
: ๊ฐ HTTP ๊ท์น์๋ ๋ค์์ ์ ๋ณด๊ฐ ํฌํจ๋๋ค
์ ํ์ host
๋ง์ฝ host๊ฐ ์ ๊ณต๋๋ฉด, ๊ท์น์ด ํด๋น host์ ์ ์ฉ๋๋ค
๊ฒฝ๋ก ๋ชฉ๋ก
๊ฒฝ๋ก ๋ชฉ๋ก์๋ ๊ฐ๊ฐ
service.name
,service.port.name
orservice.port.number
๊ฐ ์ ์๋์ด ์๋, ๊ด๋ จ backend๋ฅผ ๊ฐ์ง๊ณ ์๋คLoad balancer๊ฐ traffic์ด ์ฐธ์กฐ๋ ์๋น์ค๋ก ๋ณด๋ด๊ธฐ ์ ์ host์ path ๋ incoming request์ ๋ด์ฉ์ด match ๋์ด์ผ ํ๋ค
Backend
Backend๋ service docs ๋๋ ์ฌ์ฉ์ ์ ์ resource backend์ ์ค๋ช ๋ ๊ฒ ์ฒ๋ผ service ์ port ์ด๋ฆ์ ์กฐํฉ์ด๋ค.
Host์ ๊ท์น ๊ฒฝ๋ก๊ฐ ์ผ์นํ๋ ingress์ ๋ํ HTTP(S) ์์ฒญ์ backend ๋ชฉ๋ก์ผ๋ก ์ ์ก๋๋ค
DefaultBackend
๊ท์น์ด ์๋ ingress๋ ๋ชจ๋ traffic์ ํ๋์ default backend๋ก ์ ์กํ๋ค
DefaultBackend๋
ingress controller
์ ๊ตฌ์ฑ option์ด๊ณ ,ingress resource
์ ์ง์ ๋์ด ์์ง ์๋ค๋ง์ฝ
ingress object
์ HTTP ์์ฒญ๊ณผ ์ผ์นํ๋ host or path๊ฐ ์์ผ๋ฉด, traffic์ default backend๋ก routing ๋๋ค
Resource Backend
Resource backend
๋ ingresss object์ ๋์ผํ namespace ๋ด์ ์๋ ๋ค๋ฅธ Kubernets resource์ ๋ํ ObjectRef ์ด๋คResource
๋ service์ ์ํธ ๋ฐฐํ์ ์ธ ์ค์ ์ด๋ฉฐ, ๋ ๋ค ์ง์ ํ๊ฒ ๋๋ฉด ์ ํจ์ฑ ๊ฒ์ฌ ๋ฅผ ํต๊ณผ ํ ์ ์๋ค์ ํจ์ฑ ๊ฒ์ฌ์ ์คํจํ๋ค
Resource backend
์ ์ผ๋ฐ์ ์ธ ์ฉ๋๋ static asset์ด ์๋ object storage backend๋ก data๋ฅผ ์์ ํ๋ ๊ฒ ์ด๋ค
Resource backend example
# service/networking/ingress-resource-backend.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ingress-resource-backend
spec:
defaultBackend:
resource:
apiGroup: k8s.example.com
kind: StorageBucket
name: static-assets
rules:
- http:
paths:
- path: /icons
pathType: ImplementationSpecific
backend:
resource:
apiGroup: k8s.example.com
kind: StorageBucket
name: icon-assets
์์ yaml file ์ฒ๋ผ ingress ๋ฅผ ์์ฑํ๊ณ , ์๋์ ๋ช ๋ น์ผ๋ก ์์ฑ๋ ingress๋ฅผ ํ์ธ ํ ์ ์๋ค
$ kubectl describe ingress ingress-resource-backend
๊ฒฐ๊ณผ
Name: ingress-resource-backend Namespace: default Address: Default backend: APIGroup: k8s.example.com, Kind: StorageBucket, Name: static-assets Rules: Host Path Backends ---- ---- -------- * /icons APIGroup: k8s.example.com, Kind: StorageBucket, Name: icon-assets Annotations: <none> Events: <none>
Path types
Ingress ์ ๊ฐ ๊ฒฝ๋ก์๋ ํด๋น ๊ฒฝ๋ก์ ์ ํ์ด ์์ด์ผ ํ๋ค
๋ช ์์
pathType
์ ํฌํจํ์ง ์๋ ๊ฒฝ๋ก๋ ์ ํจ์ฑ ๊ฒ์ฌ ๋ฅผ ํต๊ณผํ์ง ๋ชปํ๋ค!
์ง์๋๋ ๊ฒฝ๋ก ์ ํ์ ์๋์ 3๊ฐ์ง๊ฐ ์๋ค
ImplementationSpecific
์ด ๊ฒฝ๋ก ์ ํ์ ์ผ์น ์ฌ๋ถ๋ IngressClass ์ ๋ฐ๋ผ ๋ฌ๋ผ์ง๋ค
์ด๊ฒ์ ๊ตฌํํ ๋ ๋ณ๋
pathType
์ผ๋ก ์ฒ๋ฆฌํ๊ฑฐ๋,Prefix
๋๋Exact
๊ฒฝ๋ก ์ ํ์ฒ๋ผ ์ฒ๋ฆฌํ ์ ์๋ค
Exact
URL ๊ฒฝ๋ก์ ๋์๋ฌธ์๋ฅผ ์๊ฒฉํ๊ฒ ์ผ์น์ํจ๋ค
Prefix
URL ๊ฒฝ๋ก์ ์ ๋์ฌ๋ฅผ
/
๋ฅผ ๊ธฐ์ค์ผ๋ก ๋ถ๋ฆฌํ ๊ฐ๊ณผ ์ผ์น์ํจ๋ค๋์๋ฌธ์๋ฅผ ๊ตฌ๋ถํ๊ณ ,
Element basis๋ก path element๋ฅผ ์ผ์น์ํจ๋ค
Request path์ ๋ชจ๋ element๋ณ ์ ๋์ฌ๊ฐ p ์ธ ๊ฒฝ์ฐ ์์ฒญ์ p ๊ฒฝ๋ก์ ์ผ์นํ๋ ๊ฒ์ด๋ค
๋จ, ๊ฒฝ๋ก์ ๋ง์ง๋ง ์์๊ฐ request path์ ์๋ ๋ง์ง๋ง element์ ํ์ ๋ฌธ์์ด์ธ ๊ฒฝ์ฐ์๋ ์ผ์นํ์ง ์๋๋ค
ex)
/foo/bar
์/foo/bar/baz
๋ ์ผ์นํ์ง๋ง,/foo/bar
์/foo/barbaz
๋ ์ผ์นํ์ง ์๋๋ค!
Examples
Prefix
/
(๋ชจ๋ ๊ฒฝ๋ก)
์
Exact
/foo
/foo
์
Exact
/foo
/bar
์๋์ค
Exact
/foo
/foo/
์๋์ค
Exact
/foo/
/foo
์๋์ค
Prefix
/foo
/foo
, /foo/
์
Prefix
/foo/
/foo
, /foo/
์
Prefix
/aaa/bb
/aaa/bbb
์๋์ค
Prefix
/aaa/bbb
/aaa/bbb
์
Prefix
/aaa/bbb/
/aaa/bbb
์, ๋ง์ง๋ง ์ฌ๋์ ๋ฌด์ํจ
Prefix
/aaa/bbb
/aaa/bbb/
์, ๋ง์ง๋ง ์ฌ๋์ ์ผ์นํจ
Prefix
/aaa/bbb
/aaa/bbb/ccc
์, ํ์ ๊ฒฝ๋ก ์ผ์นํจ
Prefix
/aaa/bbb
/aaa/bbbxyz
์๋์ค, ๋ฌธ์์ด ์ ๋์ฌ ์ผ์นํ์ง ์์
Prefix
/
, /aaa
/aaa/ccc
์, /aaa
์ ๋์ฌ ์ผ์นํจ
Prefix
/
, /aaa
, /aaa/bbb
/aaa/bbb
์, /aaa/bbb
์ ๋์ฌ ์ผ์นํจ
Prefix
/
, /aaa
, /aaa/bbb
/ccc
์, /
์ ๋์ฌ ์ผ์นํจ
Prefix
/aaa
/ccc
์๋์ค, ๊ธฐ๋ณธ ๋ฐฑ์๋ ์ฌ์ฉํจ
Mixed
/foo
(Prefix), /foo
(Exact)
/foo
์, Exact ์ ํธํจ
Multiple matches
๊ฒฝ์ฐ์ ๋ฐ๋ผ Ingress์ ์ฌ๋ฌ ๊ฒฝ๋ก๊ฐ request์ ์ผ์นํ ์ ์๋ค
์ด ๊ฒฝ์ฐ ์ผ์นํ๋ ๊ฒฝ๋ก ์ค ๊ฐ์ฅ ๊ธด ๊ฒฝ๋ก๊ฐ ์ฐ์ ์์๋ฅผ ๊ฐ๋๋ค
๋ ๊ฐ์ ๊ฒฝ๋ก์ ๊ธธ์ด๊ฐ ๋์ผํ ๊ฒฝ์ฐ,
Prefix
๊ฒฝ๋ก ์ ํ๋ณด๋คExact
๊ฒฝ๋ก ์ ํ์ ๊ฐ์ง ๊ฒฝ๋ก๊ฐ ์ฌ์ฉ๋๋ค!
+
Kubernetes์ ์๋น์ค๋
L4 layer
๋กTCP
๋จ์์ Pods ๋ฅผ balancing ํ๋ค
Last updated
Was this helpful?