EKS 환경에서 Ingress를 구성해보자.
curl -o iam-policy.json https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.4.4/docs/install/iam_policy.json
aws iam create-policy \
--policy-name $ACCOUNT-AWSLoadBalancerControllerIAMPolicy \
--policy-document file://iam-policy.json
eksctl create iamserviceaccount \
--cluster $ACCOUNT-cluster \
--namespace kube-system \
--name aws-load-balancer-controller \
--attach-policy-arn arn:aws:iam::$AWSNUM:policy/$ACCOUNT-AWSLoadBalancerControllerIAMPolicy \
--approve
kubectl get sa -n kube-system aws-load-balancer-controller
여기서 위와 같이 ALBC 정책을 부여하니 Ingress 생성에 지장이 있었음.
eksctl delete iamserviceaccount \
--cluster $ACCOUNT-cluster \
--region $AWSREGION \
--name aws-load-balancer-controller \
--namespace kube-system
eksctl create iamserviceaccount \
--cluster $ACCOUNT-cluster \
--namespace kube-system \
--name aws-load-balancer-controller \
--attach-policy-arn arn:aws:iam::aws:policy/AdministratorAccess \
--approve
kubectl get sa -n kube-system aws-load-balancer-controller
kubectl apply --validate=false -f https://github.com/jetstack/cert-manager/releases/download/v1.5.4/cert-manager.yaml
wget https://github.com/kubernetes-sigs/aws-load-balancer-controller/releases/download/v2.4.4/v2_4_4_full.yaml
spec:
containers:
- args:
- --cluster-name=<NAME>-cluster
- --ingress-class=alb
image: amazon/aws-alb-ingress-controller:v2.4.4
아래 부분 삭제
---
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
app.kubernetes.io/component: controller
app.kubernetes.io/name: aws-load-balancer-controller
name: aws-load-balancer-controller
namespace: kube-system
kubectl apply -f v2_4_4_full.yaml
# running 확인
kubectl get deployment -n kube-system aws-load-balancer-controller
주의! Ingress Controller 는 NameSpace에 종속되지 않는 자원이다.
따라서 다른 네임스페이스의 Ingress를 붙여도 전혀 무관하며 우리는 Ingress의 IP로 접속하면 된다.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: lb-ingress
annotations:
alb.ingress.kubernetes.io/scheme: internet-facing
alb.ingress.kubernetes.io/target-type: ip
kubernetes.io/ingress.class: alb
spec:
rules:
- http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: sample-dp
port:
number: 8080
kubectl apply -f ingress.yaml -n <name-space>
# running 확인
kubectl get ingress -n <name-space>
kubectl describe ingress -n <name-space>