Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents
Info

여기서 사용되는 예제는 아래 블로그의 예제를 응용하여 적용하였다.
162. [Kubernetes] 1편 : 쿠버네티스 Ingress 개념 및 사용 방법, 온-프레미스 환경에서 Ingress 구축하기

단, 현재의 k8s api 버전 스펙에 맞지 않는 경우가 있고, Nginx-ingress 역시 위 예제에서 사용되는 것과는 차이가 있다.(기본 NodePort 서비스를 생성해준다. 그러므로 3.4.1 절의 내용은 이미 생성되어 있을 것이다.)

그래서 아래 노트 박스에서와 같이 yaml들을 수정/보완하여 적용하였다.

...

이 외 개념 및 원리 설명은 원본 블로그에 잘 설명되어 있으니, 비교 참조하여 보면 도움이 될 것이다.

5-ingress-svc-externalip.yaml를 적용하면, 아래와 같이 호출할 수 있다.

Code Block
languagepy
# 먼저 접속할 포트를 조회.
$ kubectl get svc -n ingress-nginx
NAME                                 TYPE        CLUSTER-IP       EXTERNAL-IP               PORT(S)        AGE
ingress-nginx-controller             ClusterIP   10.107.174.150   10.20.2.217,10.20.2.218   80/TCP         38s

$ curl --resolve alicek106.example.com:80:10.20.2.217 alicek106.example.com:80/echo-hostname
------------------------
You accessed to path "/"
Access Server URL : http://alicek106.example.com/
Container Hostname : hostname-deployment-6b85d566c5-79dqp
Container IP : 10.244.2.27
Original IP with Proxy : 10.244.2.1
Static string : /

------------------------
Flask received HTTP header :
X-Forwarded-Host: alicek106.example.com
X-Request-Id: bf262fc2c39e9715aa3a304392e055f1
Host: alicek106.example.com
X-Real-Ip: 10.244.2.1
X-Forwarded-For: 10.244.2.1
Accept: */*
X-Forwarded-Port: 80
X-Scheme: http
User-Agent: curl/7.29.0
X-Forwarded-Proto: http


remote_addr : 10.244.2.1
------------------------

$ curl --resolve alicek106.example.com:80:10.20.2.218 alicek106.example.com:80/echo-hostname
------------------------
You accessed to path "/"
Access Server URL : http://alicek106.example.com/
Container Hostname : hostname-deployment-6b85d566c5-r2s5l
Container IP : 10.244.1.25
Original IP with Proxy : 10.244.2.1
Static string : /

------------------------
Flask received HTTP header :
Host: alicek106.example.com
X-Forwarded-For: 10.244.2.1
X-Forwarded-Port: 80
User-Agent: curl/7.29.0
Accept: */*
X-Real-Ip: 10.244.2.1
X-Forwarded-Proto: http
X-Scheme: http
X-Forwarded-Host: alicek106.example.com
X-Request-Id: e040f08ebb0d6d0953edc848e0f8246a


remote_addr : 10.244.1.1
------------------------