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

배포 환경 구현 #1

Closed
8 tasks done
junha-ahn opened this issue Aug 1, 2023 · 4 comments
Closed
8 tasks done

배포 환경 구현 #1

junha-ahn opened this issue Aug 1, 2023 · 4 comments
Assignees
Labels
enhancement New feature or request Major Major topic

Comments

@junha-ahn
Copy link
Member

junha-ahn commented Aug 1, 2023

Description

학습 내용을 통해 아래와 같은 CD pipeline 및 인프라 구성도 작성

1_bmfZlifjlBzqka4heoRg-w

EKS CICD Pipeline은 ticketing-backend 프로젝트에 Git actions 작성

infra

To do

다음 이슈

  • 모니터링 구축
  • 트래픽 테스트 환경 구축
  • 로그 파이프라인 구축
  • 트래픽 테스트 자동화

Test Checklist

@hihahayoung
Copy link
Collaborator

hihahayoung commented Aug 7, 2023

IAM 관련 오류

infra-hihahayoung으로 aws configure를 마치고

$ aws eks update-kubeconfig --region ap-northeast-2 --name ticketing-eks
Updated context arn:aws:eks:ap-northeast-2:213060417361:cluster/ticketing-eks in /home/vscode/.kube/config

$ kubectl get nodes
NAME                                             STATUS   ROLES    AGE     VERSION
ip-10-0-73-107.ap-northeast-2.compute.internal   Ready    <none>   2m11s   v1.27.3-eks-a5565ad
ip-10-0-93-166.ap-northeast-2.compute.internal   Ready    <none>   3m54s   v1.27.3-eks-a5565ad

eks-admin-hihahayoung 으로 aws configure를 마치고

$ aws eks update-kubeconfig --region ap-northeast-2 --name ticketing-eks
An error occurred (AccessDeniedException) when calling the DescribeCluster operation: User: arn:aws:iam::213060417361:user/hihahayoung is not authorized to perform: eks:DescribeCluster on resource: arn:aws:eks:ap-northeast-2:213060417361:cluster/ticketing-eks

@junha-ahn
Copy link
Member Author

IAM 문제 해결

메시지에서 사용자는 Amazon EKS DescribeCluster API 작업을 호출할 권한이 없습니다.

@hihahayoung
Copy link
Collaborator

hihahayoung commented Aug 7, 2023

해당 문제는 hihahayoung 계정이 저희가 이미 생성해 놓은 eks-admin 계정을 Assume하지 못해 발생합니다. 도대체 왜??
바로 aws configure를 알맞게 수정하지 않아서 생기는 문제였던 것이죠...

  1. 사용할 프로필 등록 (이미 access key와 secret key 등록은 마친 상태여야 함.)
aws configure --profile hihahayoung
  1. 제대로 등록되었나 확인
aws sts get-caller-identity --profile hihahayoung

  1. config file 수정 (중요)
vim ~/.aws/config
  1. hihahayoung을 eks-admin을 assume할 수 있도록 등록
[profile eks-admin] 
role_arn = arn:aws:iam::213060417361:role/eks-admin
source_profile = hihahayoung
  1. 실제로 assume 되는지 확인
aws sts get-caller-identity --profile eks-admin
  1. Kubernetes config update
aws eks update-kubeconfig \
  --name ticketing-main-eks \
  --region ap-northeast-2 \
  --profile eks-admin
  1. kubectl 권한 확인 (yes가 출려되면 만사 오케이)
kubectl auth can-i "*" "*"

참고자료:
https://stevenshim.github.io/awscli-profile/

@f-lab-clone f-lab-clone deleted a comment from hihahayoung Aug 7, 2023
@junha-ahn
Copy link
Member Author

junha-ahn commented Aug 10, 2023

ticketing-infra-iam-group KMS 권한 이슈

Plan: 5 to add, 0 to change, 0 to destroy.
╷
│ Error: reading KMS Key (08f9d650-7c2a-462d-9d5e-cb578ab15bca): reading KMS Key (08f9d650-7c2a-462d-9d5e-cb578ab15bca): AccessDeniedException: User: arn:aws:iam::213060417361:user/ticketing-junha is not authorized to perform: kms:DescribeKey on resource: arn:aws:kms:ap-northeast-2:213060417361:key/08f9d650-7c2a-462d-9d5e-cb578ab15bca because no resource-based policy allows the kms:DescribeKey action
│       status code: 400, request id: 8c37d1ce-0c2c-4d28-8912-dba304d865ef
│ 
│   with module.eks.module.kms.aws_kms_key.this[0],
│   on .terraform/modules/eks.kms/main.tf line 8, in resource "aws_kms_key" "this":
│    8: resource "aws_kms_key" "this" {
│ 

https://registry.terraform.io/modules/terraform-aws-modules/ecr/aws/latest

  • KMS 관련 설정 필요
  • ticketing-infra-iam-group 권한 연결

필요 예상 작업

  1. ticketing infra team terraform import 모듈화
  2. hihahayoung 계정을 통해 KMS 관련 권한 설정 후 terraform apply
    • kms_key_owners 등 추측
  3. (2) 실패시 eks-cluster 삭제 후 다시 생성

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Major Major topic
Projects
Status: Done
Development

No branches or pull requests

3 participants