본문으로 바로가기

[AWS] AWS Load Balancer Controller 설치하기

category IT/AWS 2021. 8. 13. 00:47
반응형

AWS Load Balancer Controller 란?

Ingress를 AWS ALB 또는 NLB로 사용할때 필요한 컨트롤러 입니다. 이전에(20년10월 이전) "AWS ALB Ingress Controller"로 알려졌으며 "AWS Load Balancer Controller"로 브랜드를 변경했습니다. [참고]alb load balancer controller 공식 github 주소

AWS Load Balancer Controller image releases 정보

https://github.com/kubernetes-sigs/aws-load-balancer-controller/releases/

AWS Load Balancer Controller 설치

oidc install

eksctl utils associate-iam-oidc-provider \
    --region ap-northeast-2 \
    --cluster test-eksctl2 \
    --approve

iam policy crate

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

service account

eksctl create iamserviceaccount \
--cluster=test-eksctl2  \
--namespace=kube-system \
--name=aws-load-balancer-controller \
--attach-policy-arn=arn:aws:iam::058475846659:policy/AWSLoadBalancerControllerIAMPolicy \
--approve

crds apply

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

install aws loadbalancer ingress

  • helm chart add
helm repo add eks https://aws.github.io/eks-charts
  • using service account
    위에서 eksctl create iamserviceaccount를 하였으므로 kubectl get sa aws-load-balancer-controller -n kube-system로 잘 생성이 되었는지 확인하고 아래 명령어 입력
helm install aws-load-balancer-controller eks/aws-load-balancer-controller --set clusterName=test-eksctl2 -n kube-system --set serviceAccount.create=false --set serviceAccount.name=aws-load-balancer-controller
  • not using service account
helm upgrade -i aws-load-balancer-controller eks/aws-load-balancer-controller -n kube-system --set clusterName=test-eksctl2

delete helm

helm delete aws-load-balancer-controller -n kube-system

ingress test sample(deployment/service/ingress)

export EKS_CLUSTER_VERSION=$(aws eks describe-cluster --name test-eksctl2 --query cluster.version --output text)

if [ "`echo "${EKS_CLUSTER_VERSION} < 1.19" | bc`" -eq 1 ]; then     
    curl -s https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/main/docs/examples/2048/2048_full.yaml \
    | sed 's=alb.ingress.kubernetes.io/target-type: ip=alb.ingress.kubernetes.io/target-type: instance=g' \
    | kubectl apply -f -
fi

if [ "`echo "${EKS_CLUSTER_VERSION} >= 1.19" | bc`" -eq 1 ]; then     
    curl -s https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/main/docs/examples/2048/2048_full_latest.yaml \
    | sed 's=alb.ingress.kubernetes.io/target-type: ip=alb.ingress.kubernetes.io/target-type: instance=g' \
    | kubectl apply -f -
fi
반응형