콘텐츠로 이동

Kubernetes Ingress 구성 요소 배포

개요

Nginx Ingress는 Kubernetes Ingress의 한 구현 방식입니다. Kubernetes 클러스터의 Ingress 리소스를 감시(watch)하여 Ingress 규칙을 Nginx 설정으로 변환하고, Nginx가 7계층 트래픽을 전달하도록 합니다.

전제 조건

  • Kubernetes 클러스터가 배포되어 있어야 합니다. 배포되지 않은 경우 Kubernetes 배포를 참조하세요.
  • (선택 사항) Helm 도구가 배포되어 있어야 합니다. 배포되지 않은 경우 Helm 설치를 참조하세요.

기본 정보 및 호환성

이름 설명
Ingress-nginx 버전 1.3.0
지원 클러스터 버전 1.18+
Ingress-nginx 포트 번호 32280
오프라인 설치 지원
지원 아키텍처 amd64/arm64

배포 단계

1、설치

Kubernetes Ingress 구성 요소 배포는 https://github.com/kubernetes/ingress-nginx를 참조하세요.

  • Kubernetes > 1.18
helm install ingress-nginx ingress-nginx \
    --repo https://pubrepo.guance.com/chartrepo/dataflux-chart \
    -n ingress-nginx --create-namespace
  • Kubernetes = 1.18
helm install ingress-nginx ingress-nginx \
    --repo https://pubrepo.guance.com/chartrepo/dataflux-chart \
    --version 4.1.4 \
    -n ingress-nginx --create-namespace
  • Kubernetes > 1.18

ingress-nginx.yaml 다운로드

다음 명령을 실행하여 설치:

kubectl apply -f ingress-nginx.yaml
  • Kubernetes = 1.18

ingress-nginx4.1.4.yaml 다운로드

다음 명령을 실행하여 설치:

kubectl apply -f ingress-nginx4.1.4.yaml

2、배포 확인

2.1 Pod 상태 확인

kubectl get pods -n ingress-nginx 
NAME                                        READY   STATUS    RESTARTS   AGE
ingress-nginx-controller-7bf6c446bf-b7bq7   1/1     Running   1          26d

2.2 포트 조회

ingress-nginx NodePort 포트 번호 확인

참고

Helm 및 Yaml 배포의 경우 NodePort 포트 번호가 다를 수 있습니다. 그림과 같이 ingress-nginx NodePort는 32280, 32483입니다.

kubectl get svc -n ingress-nginx
ingress-nginx-svc.png

2.3 테스트 서비스 생성

# 테스트 deployment 생성
kubectl create deployment ingress-test --image=nginx --port=80
# 테스트 svc 생성
kubectl expose deployment ingress-test --port=80 --target-port=80
# 테스트 ingress 생성
kubectl create ingress ingress-test --rule='foo.com/=ingress-test:80'

2.4 테스트

참고

192.168.100.101은 Kubernetes 노드 IP입니다.

 curl -H 'Host:foo.com' 192.168.100.101:32280
성공 결과:
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>

2.5 테스트 서비스 정리

kubectl delete deployment ingress-test
kubectl delete svc ingress-test
kubectl delete ingress ingress-test

제거

helm uninstall ingress-nginx  -n ingress-nginx 
kubectl delete -f ingress-nginx.yaml

문서 평가

이 페이지가 도움이 되었나요?