Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

로컬 머신에서 External-DNS & Core-DNS로 k8s 내부 service, ingress 노출하기 #2

Closed
BaeKY opened this issue Dec 21, 2022 · 4 comments

Comments

@BaeKY
Copy link
Owner

BaeKY commented Dec 21, 2022

개요

  • Local Machine이나 Home Lab에서 구성한 k8s에 CI/CD, Container Registry 등을 구성 예정
  • EKS처럼 ingress에 host를 할당하였을때 자동으로 외부로 도메인이 노출되는걸 원함
  • ip, port 대신 DNS로 편하게 관리하자

참고자료

@BaeKY
Copy link
Owner Author

BaeKY commented Dec 22, 2022

Official tutorial - ExternalDNS with CoreDNS

  • minikube에서 etcd-operator를 설치하라는데 etcd-operator가 너무 오래된 Chart라 쓰기가 꺼려진다.(심지어 Helm v2로 install 하는듯)
  • 다른방법을 찾아보자

@BaeKY
Copy link
Owner Author

BaeKY commented Dec 22, 2022

etcd-cluster 직접 구축하기

  • 여기에서 statefulset으로 etcd-cluster 직접 구축함.

BaeKY added a commit that referenced this issue Dec 24, 2022
- #2
- etcd-cluster
- core-dns
- external-dns
@BaeKY
Copy link
Owner Author

BaeKY commented Jan 3, 2023

내 Macbook에서 Custom DNS 사용하기

  • 여기 참고
  • DNS 서버를 구성한 뒤에 sudo로 아래 스크립트를 실행.
    #!/bin/bash
    
    # 원하는 도메인 입력
    # *.local은 Macos에서 기본적으로 사용중이다(IANA). 나는 localhost 로 결정
    DOMAIN=localhost
    
    # 10.0.0.1에 DNS서버를 구축해둔 상태에서
    NS_IP=10.0.0.1
    
    RESOLVER_NAME=$DOMAIN
    RESOLVER_CONTENT="
    domain $DOMAIN
    search $DOMAIN
    nameserver $NS_IP"
    
    sudo mkdir -p /private/etc/resolver
    echo "$RESOLVER_CONTENT" | sudo tee -a $RESOLVER_NAME &>/dev/null
    
    # https://vninja.net/2020/02/06/macos-custom-dns-resolvers/
    # 위 링크처럼 DNS Refresh
    sudo killall -HUP mDNSResponder
    
    # 등록 확인
    scutil --dns | grep "domain   : $DOMAIN" -A 5 -B 1 | awk '{$1=$1;print}'

BaeKY added a commit that referenced this issue Jan 3, 2023
BaeKY added a commit that referenced this issue Jan 3, 2023
@BaeKY
Copy link
Owner Author

BaeKY commented Jan 3, 2023

결과

  • 아래와 같이 구성됨
    external-dns drawio

DNS 동작 시나리오

  1. ingress.rules[].host를 설정하거나 service(type: LoadBalancer)에 external-dns.alpha.kubernetes.io/hostname annotation을 추가한다.
  2. external-dns가 ingress, service의 host 변경을 감지하여 etcd에 해당 내용을 write.
  3. core-dns서버로 dns request가 날아오면 etcd의 내용을 읽어서 전달함.

@BaeKY BaeKY closed this as completed Jan 3, 2023
@BaeKY BaeKY mentioned this issue Jan 4, 2023
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant