반응형
#/bin/bash
echo '>>> CREATE ALBIngressControllerIAMPolicy '
aws iam create-policy \
--policy-name ALBIngressControllerIAMPolicy \
--policy-document https://raw.githubusercontent.com/kubernetes-sigs/aws-alb-ingress-controller/v1.1.3/docs/examples/iam-policy.json
echo ''
echo '>>> Connecting ALBIngressControllerIAMPolicy To WorkerNode Role'
NG_ROLE=`kubectl -n kube-system describe configmap aws-auth | grep rolearn`
ACCOUNT=${NG_ROLE:24:12}
WN_ROLE=${NG_ROLE:42}
echo "ACCOUNT : $ACCOUNT"
echo "WORKER NODE ROLE : $WN_ROLE"
echo "NODE GROUP ROLE : $NG_ROLE"
aws iam attach-role-policy \
--policy-arn arn:aws:iam::${ACCOUNT}:policy/ALBIngressControllerIAMPolicy \
--role-name ${WN_ROLE}
echo ''
echo '>>> Create ClusterRole for ALB Ingress Controller'
kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/aws-alb-ingress-controller/v1.1.3/docs/examples/rbac-role.yaml
echo ''
echo '>>> Create ALB Ingress Controller'
CLUSTER_NAME='eks-test' # write your's cluster name
AWS_REGION='ap-northeast-2' # write cluster's region
VPC_ID=`eksctl get cluster --name ${CLUSTER_NAME} --region ${AWS_REGION} --output json | jq -r '.[0].ResourcesVpcConfig.VpcId'`
echo "CLUSTER NAME : $CLUSTER_NAME"
echo "VPC ID : $VPC_ID"
echo "AWS REGION : $AWS_REGION"
echo ''
echo '>>> Remove Old alb-ingress-controller.yaml file && New alb-ingress-controller.yaml file Download'
rm -rf alb-ingress-controller.yaml* &&
curl -O https://raw.githubusercontent.com/kubernetes-sigs/aws-alb-ingress-controller/v1.1.3/docs/examples/alb-ingress-controller.yaml &&
# alb-ingress-controller.yaml
sed -i -e "s/# - --cluster-name=devCluster/- --cluster-name=$CLUSTER_NAME/g" alb-ingress-controller.yaml &&
sed -i -e "s/# - --aws-vpc-id=vpc-xxxxxx/- --aws-vpc-id=$VPC_ID/g" alb-ingress-controller.yaml &&
sed -i -e "s/# - --aws-region=us-west-1/- --aws-region=$AWS_REGION/g" alb-ingress-controller.yaml &&
kubectl apply -f ./alb-ingress-controller.yaml
echo '>>> FINISH'
sleep 5
echo '>>> Checking Create ALB Ingress Controller'
kubectl get pods -n kube-system | grep alb
https://www.notion.so/bscnote/AWS-EKS-ALB-Ingress-Controller-544fb36ec6594be5b8ffd64cdc53789c
반응형
'개발관련 > Kubernetes' 카테고리의 다른 글
kubectl에서 연결할 쿠버네티스 클러스터 변경하는 방법 (0) | 2020.01.17 |
---|---|
Dockerfile 여러개 두고 골라서 쓰는 방법 (0) | 2020.01.16 |
Kubernetes 환경 구성하기 (0) | 2019.11.15 |
Kubernetes 네트워킹 이해하기 (0) | 2019.11.15 |
Kubernetes에서 AWS ECR의 이미지를 내려받을 때 rpc error: code = Unknown desc = failed to pull and unpack image 에러 발생 경우 해결방법 (0) | 2019.11.12 |