[운송장 정보보호 서비스] EKS-RDS 연동 및 Route53 연결

신현식·2023년 5월 31일
0

캡스톤디자인

목록 보기
3/7
post-thumbnail

EKS-RDS 연동

📢 EKS-RDS 연동 & 외부 IP에서 RDS접속

Route53 연결

📢 Route53을 이용해 도메인 설정 & TTL 설정
이번 프로젝트에서는 user와 deliver 2개의 도메인이 필요하였다. 따라서 2개의 도메인를 각각 구매해준 다음 TTL 또한 2개 모두 수행해주었다.

  • EKS에 External-DNS
    EKS는 파드를 띄워서 External-DNS를 통해 도메인과 연결한다. 파드를 배포하는 부분에서 2개의 도메인을 설정해주었기 때문에 내용을 다음과 같이 수정하였다.
    • RBAC이 활성화 되어있다는 전제하에 ClusterRole과 ClusterRoleBinding을 이용한다.
# External-DNS 파드용 파일 작성
vi external-dns.yaml

apiVersion: v1
kind: ServiceAccount
metadata:
  name: external-dns
  namespace: external-dns
  # If you're using Amazon EKS with IAM Roles for Service Accounts, specify the following annotation.
  # Otherwise, you may safely omit it.
  annotations:
    # Substitute your account ID and IAM service role name below.
    eks.amazonaws.com/role-arn: arn:aws:iam::<Account ID>:role/<생성한 Role> 
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: external-dns
  namespace: external-dns
rules:
  - apiGroups: [""]
    resources: ["services", "endpoints", "pods"]
    verbs: ["get", "watch", "list"]
  - apiGroups: ["extensions", "networking.k8s.io"]
    resources: ["ingresses"]
    verbs: ["get", "watch", "list"]
  - apiGroups: [""]
    resources: ["nodes"]
    verbs: ["list", "watch"]

---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: external-dns-viewer
  namespace: external-dns
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: external-dns
subjects:
  - kind: ServiceAccount
    name: external-dns
    namespace: external-dns

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: exqress-deliver-dns
  namespace: external-dns
spec:
  strategy:
    type: Recreate
  selector:
    matchLabels:
      app: external-dns
  template:
    metadata:
      labels:
        app: external-dns
    spec:
      serviceAccountName: external-dns
      containers:
        - name: exqress-deliver-dns
          image: k8s.gcr.io/external-dns/external-dns:v0.10.2 # external-dns를 가능하게 하는 파드를 생성하는 이미지, 버전이 지속적으로 바뀌기때문에 고려해서 지정
          args:
            - --source=service
            - --source=ingress
            - --domain-filter= exqress-deliver.com # 등록한 deliver 도메인 입력
            - --provider=aws
            - --policy=upsert-only
            - --aws-zone-type=public # only look at public hosted zones (valid values are public, private or no value for both)
            - --registry=txt
            - --txt-owner-id= <호스팅 영역 ID> # Route53 호스팅영역 ID입력
      securityContext:
        fsGroup: 65534 # For ExternalDNS to be able to read Kubernetes and AWS token files

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: exqress-dns
  namespace: external-dns
spec:
  strategy:
    type: Recreate
  selector:
    matchLabels:
      app: external-dns
  template:
    metadata:
      labels:
        app: external-dns
    spec:
      serviceAccountName: external-dns
      containers:
        - name: exqress-dns
          image: k8s.gcr.io/external-dns/external-dns:v0.10.2 # external-dns를 가능하게 하는 파드를 생성하는 이미지, 버전이 지속적으로 바뀌기때문에 고려해서 지정
          args:
            - --source=service
            - --source=ingress
            - --domain-filter= exqress.com  # 등록한 user 도메인 입력
            - --provider=aws
            - --policy=upsert-only
            - --aws-zone-type=public # only look at public hosted zones (valid values are public, private or no value for both)
            - --registry=txt
            - --txt-owner-id= <호스팅 영역 ID> # Route53 호스팅영역 ID입력
      securityContext:
        fsGroup: 65534 # For ExternalDNS to be able to read Kubernetes and AWS token files

front-ingress에서 미리 호스트를 등록해 두었고 또한 https를 위한 어노테이션도 설정해두었기 때문에 https://<도메인>으로 잘 접속이 되는 것을 확인할 수 있다.

  • 결과적으로 외부 사용자가 도메인을 입력하여 접속하는 것은 프론트엔드로 구성된 웹페이지이게 프론트엔드 파드를 외부에 노출시키는 Ingress(=ALB)를 수정한다.
    백엔드 파드를 외부에 노출시키는 Ingress(=ALB)는 도메인과 연결할 필요없이 추후에 프론트엔드와 연결한다.
profile
전공 소개

0개의 댓글