# Ingress Controller

Ingress 리소스가 작동 하려면 클러스터에 Ingress 컨트롤러가 실행 중 이어야 합니다.

`kube-controller-manager` 바이너리 일부로 실행되는 다른 유형의 컨트롤러와 달리 Ingress 컨트롤러는 클러스터와 함께 자동으로 시작되지 않습니다.

#### AWS Load Balancer Controller  <a href="#aws-load-balancer-controller" id="aws-load-balancer-controller"></a>

{% hint style="info" %}
AWS ALB Ingress Controller가 [AWS Load Balancer Controller](https://github.com/kubernetes-sigs/aws-load-balancer-controller)로 이름이 변경 되었습니다.
{% endhint %}

AWS Load Balancer Controller는 쿠버네티스 클러스터용 Elastic Load Balancer를 관리하는 데 도움이 되는 [controller](https://kubernetes.io/docs/concepts/architecture/controller/) 입니다.

* [Application Load Balancers](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/introduction.html)를 프로비저닝하여 쿠버네티스 `Ingress` 리소스를 충족 합니다.
* [Network Load Balancers](https://docs.aws.amazon.com/elasticloadbalancing/latest/network/introduction.html)를 프로비저닝하여 쿠버네티스 `Service` 리소스를 충족 합니다.

AWS Load Balancer 컨트롤러에서 지원하는 **트래픽 모드**는 아래의 두 가지입니다.

* Instance(default): 클러스터 내 노드를 ALB의 대상으로 등록합니다. ALB에 도달하는 트래픽은 NodePort로 라우팅된 다음 파드로 프록시됩니다.
* IP: 파드를 ALB 대상으로 등록합니다. ALB에 도달하는 트래픽은 파드로 직접 라우팅됩니다. 해당 트래픽 모드를 사용하기 위해선 ingress.yaml 파일에 주석을 사용하여 명시적으로 지정해야 합니다.

이번 실습에서는 Application Load Balancer에 초점을 맞출 것입니다.

AWS Elastic Load Balancing Application Load Balancer (ALB)는 여러 가용 영역에서 Amazon EC2 인스턴스와 같은 여러 대상에 걸쳐 애플리케이션 계층에서 수신 트래픽을 로드 밸런싱하는 잘 알려진 AWS 서비스입니다.

ALB는 다음을 포함한 여러 기능을 지원 합니다.

* 호스트 또는 경로 기반 라우팅
* TLS (Transport Layer Security) 터미네이션, WebSocket
* HTTP / 2
* AWS WAF(Web Application Firewall) 통합
* 통합 액세스 로그 및 상태 확인

## 1. AWS Load Balancer Controller 배포하기

먼저 AWS Load Balancer Controller 버전이 설정 되었는지 확인 합니다.

```
if [ ! -x ${LBC_VERSION} ]
  then
    tput setaf 2; echo '${LBC_VERSION} has been set.'
  else
    tput setaf 1;echo '${LBC_VERSION} has NOT been set.'
fi

```

{% hint style="warning" %}
결과에서 ${LBC\_VERSION}이 설정되지 않은 경우 [여기](https://wjlee81.gitbook.io/amazon-eks/undefined)를 클릭하여 지침을 확인하십시오.
{% endhint %}

**Helm**을 사용하여 ALB Ingress Controller를 설치 합니다.

먼저 `helm`이 설치되어 있는지 확인 하십시오:

```
helm version --short
```

{% hint style="warning" %}
만약 helm이 설치되어 있지 않다면, [여기](https://wjlee81.gitbook.io/amazon-eks/helm/helm#1-helm-cli)를 참고하여 설치합니다.
{% endhint %}

클러스터에 대한 IAM OIDC provider 생성합니다. Pod와 같은 클러스터 내 쿠버네티스가 생성한 항목이 API Server 또는 외부 서비스에 인증하는데 사용되는 [service account](https://kubernetes.io/ko/docs/reference/access-authn-authz/service-accounts-admin/)에 IAM role을 사용하기 위해, 생성한 클러스터(현재 실습에서의 *eks-demo*)에 **IAM OIDC provider**가 존재해야 합니다.

```
eksctl utils associate-iam-oidc-provider \
    --region ${AWS_REGION} \
    --cluster eksworkshop-eksctl \
    --approve
```

Amazon EKS 설명서에서 서비스 계정의 [IAM Roles for Service Accounts](https://docs.aws.amazon.com/eks/latest/userguide/iam-roles-for-service-accounts.html)에 대해 자세히 알아보십시오.

AWS Load Balancer Controller에 부여할 **AWSLoadBalancerControllerIAMPolicy** 정책을 생성합니다.

```
curl -o iam_policy.json https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.3.0/docs/install/iam_policy.json
aws iam create-policy \
    --policy-name AWSLoadBalancerControllerIAMPolicy \
    --policy-document file://iam_policy.json
```

AWS Load Balancer Controller를 위한 ServiceAccount를 생성합니다. Account ID가 설정되어 있지 않다면 다음의 명령을 실행한 후 IAM 역할을 생성합니다.

```
ACCOUNT_ID=$(aws sts get-caller-identity --output text --query Account)
```

```
eksctl create iamserviceaccount \
  --cluster eksworkshop-eksctl \
  --namespace kube-system \
  --name aws-load-balancer-controller \
  --attach-policy-arn arn:aws:iam::${ACCOUNT_ID}:policy/AWSLoadBalancerControllerIAMPolicy \
  --override-existing-serviceaccounts \
  --approve
```

TargetGroupBinding CRDs 설치합니다.

```
kubectl apply -k github.com/aws/eks-charts/stable/aws-load-balancer-controller/crds?ref=master

kubectl get crd
```

EKS repo로 부터 helm 차트(AWS Load Balancer Controller)를 배포합니다.

```
helm repo add eks https://aws.github.io/eks-charts

helm upgrade -i aws-load-balancer-controller \
    eks/aws-load-balancer-controller \
    -n kube-system \
    --set clusterName=eksworkshop-eksctl \
    --set serviceAccount.create=false \
    --set serviceAccount.name=aws-load-balancer-controller \
    --set image.tag="${LBC_VERSION}"

kubectl -n kube-system rollout status deployment aws-load-balancer-controller
```

배포가 성공적으로 되고 컨트롤러가 실행되는지 아래의 명령어를 통해 확인합니다.&#x20;

```
kubectl get deployment -n kube-system aws-load-balancer-controller

```

![](https://1998608250-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MhByD5wv8eUbA5ZbUY5%2F-MhERajzx6ESC10mPY5x%2F-MhERwAdr4kp2HO9H5AP%2Fimage.png?alt=media\&token=69c701c3-e893-4cfe-a2a1-6a8afb94a906)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://wjlee81.gitbook.io/amazon-eks/untitled/ingress-controller.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
