티스토리 뷰

728x90

EKS를 사용하다보면 pod가 생성될 때마다 ip가 변경되어 /etc/hosts에서 바꿔주거나 coredns에서 해당 ip를 변경해줘야한다.

728x90


이러한 문제는 AWS NLB를 생성하고 해당 NLB에 elastic ip(고정 ip)를 할당하여 해결할 수 있다.

 


1. KubeConfig 파일 변경

우선 nlb를 사용하기 때문에 kubeconfig 파일 내용도 바꿔줘야한다.
여기서 "insecure-skip-tls-verify"로 바꿔서 쓰는 이유는 쿠버네티스에서 apiServer와 kubectl 이 서로 통신할 때 인증서가 따로 필요하지 않기 때문에 true로 바꿔서 사용할 수 있다.

# As-Is
apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: SE1wB...
    server: https://1G497238697S6G789AS5ASD7F678.sk1.ap-northeast-2.eks.amazoneaws.com

# To-Be
apiVersion: v1
clusters:
- cluster:
    insecure-skip-tls-verify: true
    server: https://hyun-dev-nlb-eks-api-4akwh3uihraw.elb.ap-northeast-2.eks.amazoneaws.com



2. /etc/hosts 파일 변경

kubectl을 사용하는 서버의 hosts 파일을 변경하여 kubeconfig에서 domain not found 에러가 발생하지 않도록 한다.

# As-Is
10.163.34.36  1G497238697S6G789AS5ASD7F678.sk1.ap-northeast-2.eks.amazoneaws.com
10.163.56.125 1G497238697S6G789AS5ASD7F678.sk1.ap-northeast-2.eks.amazoneaws.com

# To-Be
10.163.34.210 hyun-dev-nlb-eks-api-4akwh3uihraw.elb.ap-northeast-2.eks.amazoneaws.com

 

3. kubectl 명령으로 정상적으로 작동하는지 확인

해당 명령어의 정상 출력을 확인하면 된다.

kubectl get ns

 


4. kubernetes CoreDNS에서 변경

kubernetes에서 사용하는 내부 도메인 서버인 coreDNS를 업데이트 해준다.

kubectl edit configmap coredns -n kube-system
# As-Is
10.163.34.36  1G497238697S6G789AS5ASD7F678.sk1.ap-northeast-2.eks.amazoneaws.com
10.163.56.125 1G497238697S6G789AS5ASD7F678.sk1.ap-northeast-2.eks.amazoneaws.com

# To-Be
10.163.34.210 hyun-dev-nlb-eks-api-4akwh3uihraw.elb.ap-northeast-2.eks.amazoneaws.com


5. ArgoCD Cluster Server 정보 변경

정보를 업데이트 할 때는 --upsert 옵션을 쓰면 된다.

argocd login argocd.hyun.xyz --grpc-web --username 'adminname' --password 'password' --insecure
argocd cluster add arn:aws:eks:ap-northeast-2:1087357612:cluster/hyun-dev-eks --kubeconfig $HOME/.kube/hyun-01.config --name hyun-01-cluster --grpc-web --upsert


6. kubernetes 의 Cluster 접근 권한 허용

kubectl edit cm -n argocd argocd-rbac-cm -o yaml
# As-Is
p, role:hyun, clusters,  get, https://1G497238697S6G789AS5ASD7F678.sk1.ap-northeast-2.eks.amazoneaws.com, allow

# To-Be
p, role:hyun, clusters,  get, https://hyun-dev-nlb-eks-api-4akwh3uihraw.elb.ap-northeast-2.eks.amazoneaws.com, allow


7. ArgoCD Project Destination 변경

argocd proj create hyun01 --description '첫 번째 ARGOCD 프로젝트' --dest https://hyun-dev-nlb-eks-api-4akwh3uihraw.elb.ap-northeast-2.eks.amazoneaws.com,* --src http://bitbucket.hyun.com/scm/hyun/* --upsert

 

728x90

'CI CD > ArgoCD' 카테고리의 다른 글

ArgoCD 계정 등록 / 프로젝트 생성 / 앱 생성  (0) 2024.01.03
300x250
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크