본문 바로가기

Kubernetes

쿠버네티스 인그레스

쿠버네티스 서비스의 LoadBalancer 타입은 L4 로드 밸런싱을 제공하는 리소스였지만 인그레스(Ingress)는 L7 로드 밸런싱으 제공하는 리소스다. 인그레스는 서비스들을 묶는 서비스들의 상위 객체로 서비스 종류의 하나로서가 아닌 독립된 리소스로 구현되어 있다.

 

인그레스 리소스 생성

 

apiVersion: v1
kind: Service
metadata:
  name: sample-ingress-svc-1
spec:
  type: NodePort
  ports:
  - name: "http-port"
    protocol: "TCP"
    port: 8888
    targetPort:80
  selector:
  ingress-app: sample1
---
apiVersion: v1
kind: Pod
metadata:
  name: sample-ingress-apps-1
  labels:
    ingress-app: sample1
spec:
  containers:
  - name: nginx-container
    image: amsy810/echo-nginx:v2.0
---
apiVersion: v1
kind: Service
metadata:
  name: sample-ingres-svc-2
spec:
  type: NodePort
  ports:
  - name: "http-port"
    protocol: "TCP"
    port:8888
    targetPort: 80
  selector:
    ingress-app: sample2
---
apiVersion: v1
kind: Pod
metadata:
  name: sample-ingress-apps-2
  labels:
    ingress-app: sample2
spec:
  containers:
  - name: nginx-container
    image: amsy810/echo-nginx:v2.0
---
apiVersion: v1
kind: Service
metadata:
  name: sample-ingres-default
spec:
  type: NodePort
  ports:
  - name: "http-port"
    protocol: "TCP"
    port:8888
    targetPort: 80
  selector:
    ingress-app: default
---
apiVersion: v1
kind: Pod
metadata:
  name: sample-ingress-default
  labels:
    ingress-app: default
spec:
  containers:
  - name: nginx-container
    image: amsy810/echo-nginx:v2.0

 

Nginx 인그레스용 인그레스 리소스 생성

 

apiVersion: networking.k8s.io/vibeta1
kind: Ingress
metadata:
  name: sample-ingress-by-nginx
  annoations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/ssl-redirect: "false"
spec:
  rules:
  - host: sample.example.com
    http:
      paths:
      - path: /path1/
        backend:
          serviceName: sample-ingress-svc-1
          servicePort: 8888
      - path: /path2/
        backend:
          serviceName: sample-ingress-svc-2
          servicePort: 8888
  backend:
    serviceName: sample-ingress-default
    servicePort: 8888
  tls:
  - host:
    - sample.example.com
    secretNAme: tls-sample

 

'Kubernetes' 카테고리의 다른 글

쿠버네티스 볼륨  (0) 2022.01.02
쿠버네티스 컨피그 API  (0) 2022.01.01
쿠버네티스 서비스 기능  (0) 2021.12.01
쿠버네티스 클러스터 네트워크와 서비스  (0) 2021.11.16
쿠버네티스 스테이트풀셋  (0) 2021.11.16