Amazon EMR on EKS에 대한 클러스터 액세스 활성화 - Amazon EMR

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

Amazon EMR on EKS에 대한 클러스터 액세스 활성화

Kubernetes 역할을 생성하고, 이 역할을 Kubernetes 사용자에게 바인딩하며, Kubernetes 사용자를 서비스 연결 역할 AWSServiceRoleForAmazonEMRContainers에 매핑하는 등의 작업을 수행함으로써 Amazon EMR on EKS에서 클러스터의 특정 네임스페이스에 액세스할 수 있도록 허용해야 합니다. emr-containers에서 IAM ID 매핑 명령을 서비스 이름으로 사용하면 이러한 작업이 eksctl에서 자동화됩니다. 다음 명령을 사용하여 이러한 작업을 쉽게 수행할 수 있습니다.

eksctl create iamidentitymapping \ --cluster my_eks_cluster \ --namespace kubernetes_namespace \ --service-name "emr-containers"

my_eks_cluster를 Amazon EKS 클러스터 이름으로, kubernetes_namespace를 Amazon EMR 워크로드 실행을 위해 생성한 Kubernetes 네임스페이스로 바꿉니다.

중요

이 기능을 사용하려면 이전 eksctl 설치 단계를 사용하여 최신 eksctl을 다운로드해야 합니다.

Amazon EMR on EKS에서 클러스터 액세스를 활성화하는 수동 단계

다음 수동 단계를 사용하여 Amazon EMR on EKS에 대한 클러스터 액세스를 활성화할 수도 있습니다.

  1. 특정 네임스페이스에서 Kubernetes 역할 생성

    Amazon EKS 1.22 - 1.29

    Amazon EKS 1.22 - 1.29에서는 다음 명령을 실행하여 특정 네임스페이스에 쿠버네티스 역할을 생성합니다. 이 역할은 Amazon EMR on EKS에 필요한 RBAC 권한을 부여합니다.

    namespace=my-namespace cat - >>EOF | kubectl apply -f - >>namespace "${namespace}" apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: name: emr-containers namespace: ${namespace} rules: - apiGroups: [""] resources: ["namespaces"] verbs: ["get"] - apiGroups: [""] resources: ["serviceaccounts", "services", "configmaps", "events", "pods", "pods/log"] verbs: ["get", "list", "watch", "describe", "create", "edit", "delete", "deletecollection", "annotate", "patch", "label"] - apiGroups: [""] resources: ["secrets"] verbs: ["create", "patch", "delete", "watch"] - apiGroups: ["apps"] resources: ["statefulsets", "deployments"] verbs: ["get", "list", "watch", "describe", "create", "edit", "delete", "annotate", "patch", "label"] - apiGroups: ["batch"] resources: ["jobs"] verbs: ["get", "list", "watch", "describe", "create", "edit", "delete", "annotate", "patch", "label"] - apiGroups: ["extensions", "networking.k8s.io"] resources: ["ingresses"] verbs: ["get", "list", "watch", "describe", "create", "edit", "delete", "annotate", "patch", "label"] - apiGroups: ["rbac.authorization.k8s.io"] resources: ["roles", "rolebindings"] verbs: ["get", "list", "watch", "describe", "create", "edit", "delete", "deletecollection", "annotate", "patch", "label"] - apiGroups: [""] resources: ["persistentvolumeclaims"] verbs: ["get", "list", "watch", "describe", "create", "edit", "delete", "deletecollection", "annotate", "patch", "label"] EOF
    Amazon EKS 1.21 and below

    Amazon EKS 1.21 이하에서는 다음 명령을 실행하여 특정 네임스페이스에 Kubernetes 역할을 생성합니다. 이 역할은 Amazon EMR on EKS에 필요한 RBAC 권한을 부여합니다.

    namespace=my-namespace cat - >>EOF | kubectl apply -f - >>namespace "${namespace}" apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: name: emr-containers namespace: ${namespace} rules: - apiGroups: [""] resources: ["namespaces"] verbs: ["get"] - apiGroups: [""] resources: ["serviceaccounts", "services", "configmaps", "events", "pods", "pods/log"] verbs: ["get", "list", "watch", "describe", "create", "edit", "delete", "deletecollection", "annotate", "patch", "label"] - apiGroups: [""] resources: ["secrets"] verbs: ["create", "patch", "delete", "watch"] - apiGroups: ["apps"] resources: ["statefulsets", "deployments"] verbs: ["get", "list", "watch", "describe", "create", "edit", "delete", "annotate", "patch", "label"] - apiGroups: ["batch"] resources: ["jobs"] verbs: ["get", "list", "watch", "describe", "create", "edit", "delete", "annotate", "patch", "label"] - apiGroups: ["extensions"] resources: ["ingresses"] verbs: ["get", "list", "watch", "describe", "create", "edit", "delete", "annotate", "patch", "label"] - apiGroups: ["rbac.authorization.k8s.io"] resources: ["roles", "rolebindings"] verbs: ["get", "list", "watch", "describe", "create", "edit", "delete", "deletecollection", "annotate", "patch", "label"] - apiGroups: [""] resources: ["persistentvolumeclaims"] verbs: ["get", "list", "watch", "describe", "create", "edit", "delete", "deletecollection", "annotate", "patch", "label"] EOF
  2. 네임스페이스로 범위가 지정된 Kubernetes 역할 바인딩 생성

    다음 명령을 실행하여 지정된 네임스페이스에서 Kubernetes 역할 바인딩을 생성합니다. 이 역할 바인딩은 이전 단계에서 생성한 역할에 정의된 권한을 emr-containers 사용자에게 부여합니다. 이 사용자는 Amazon EMR on EKS에 대한 서비스 연결 역할을 식별하고, 이를 통해 Amazon EMR on EKS에서 사용자가 생성한 역할로 정의된 작업을 수행할 수 있습니다.

    namespace=my-namespace cat - <<EOF | kubectl apply -f - --namespace "${namespace}" apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: name: emr-containers namespace: ${namespace} subjects: - kind: User name: emr-containers apiGroup: rbac.authorization.k8s.io roleRef: kind: Role name: emr-containers apiGroup: rbac.authorization.k8s.io EOF
  3. Kubernetes aws-auth 구성 맵 업데이트

    다음 옵션 중 하나를 사용하여 Amazon EMR on EKS 서비스 연결 역할을 이전 단계에서 Kubernetes 역할에 바인딩된 emr-containers 사용자와 매핑할 수 있습니다.

    옵션 1: eksctl 사용

    다음 eksctl 명령을 실행하여 Amazon EMR on EKS 서비스 연결 역할을 emr-containers 사용자와 매핑합니다.

    eksctl create iamidentitymapping \ --cluster my-cluster-name \ --arn "arn:aws:iam::my-account-id:role/AWSServiceRoleForAmazonEMRContainers" \ --username emr-containers

    옵션 2: eksctl 사용 안 함

    1. 다음 명령을 실행하여 aws-auth 구성 맵을 텍스트 편집기에서 엽니다.

      kubectl edit -n kube-system configmap/aws-auth
      참고

      다음과 같은 오류 메시지가 Error from server (NotFound): configmaps "aws-auth" not found 표시되는 경우 Amazon EKS 사용 설명서의 사용자 역할 추가 단계를 참조하여 ConfigMap 스톡을 적용하십시오.

    2. Amazon EMR on EKS 서비스 연결 역할 세부 정보를 data 아래 ConfigMapmapRoles 섹션에 추가합니다. 파일에 이미 존재하지 않는 경우 이 섹션을 추가합니다. 데이터 아래의 업데이트된 mapRoles 섹션은 다음 예제와 같습니다.

      apiVersion: v1 data: mapRoles: | - rolearn: arn:aws:iam::<your-account-id>:role/AWSServiceRoleForAmazonEMRContainers username: emr-containers - ... <other previously existing role entries, if there's any>.
    3. 파일을 저장하고 텍스트 편집기를 종료합니다.

EKS 기반 Amazon EMR에 대한 클러스터 액세스를 자동으로 활성화합니다.

Amazon EMR은 Amazon EKS 클러스터 액세스 관리 (CAM) 와 통합되므로 필요한 AuthN 및 AuthZ 정책 구성을 자동화하여 Amazon EKS 클러스터의 네임스페이스에서 Amazon EMR Spark 작업을 실행할 수 있습니다. Amazon EKS 클러스터 네임스페이스에서 가상 클러스터를 생성하면 Amazon EMR이 필요한 모든 권한을 자동으로 구성하므로 현재 워크플로에 추가 단계를 추가할 필요가 없습니다.

참고

Amazon EKS 액세스 엔트리는 최대 100개의 네임스페이스만 지원합니다. 가상 클러스터가 100개 이상인 경우 Amazon EMR은 새 가상 클러스터를 생성할 때 액세스 입력 API를 사용하지 않습니다. ListVirtualClustersAPI 작업 또는 list-virtual-clusters CLI 명령을 실행할 때 eksAccessEntryIntegrated 파라미터를 true로 설정하여 액세스 항목 통합이 활성화된 클러스터를 확인할 수 있습니다. 이 명령은 해당하는 모든 가상 클러스터의 고유 식별자를 반환합니다.

필수 조건

  • 버전 2.15.3 이상을 실행하고 있는지 확인하십시오. AWS CLI

  • Amazon EKS 클러스터는 버전 1.23 이상이어야 합니다.

설치

Amazon EMR과 Amazon EKS의 AccessEntry API 작업 간의 통합을 설정하려면 다음 항목을 완료해야 합니다.

  • Amazon EKS 클러스터가 로 API_AND_CONFIG_MAP 설정되어 있는지 확인하십시오. authenticationMode

    aws eks describe-cluster --name <eks-cluster-name>

    아직 설정되어 있지 않으면 authenticationMode 로 설정하십시오. API_AND_CONFIG_MAP

    aws eks update-cluster-config --name <eks-cluster-name> --access-config authenticationMode=API_AND_CONFIG_MAP

    인증 모드에 대한 자세한 내용은 클러스터 인증 모드를 참조하십시오.

  • CreateVirtualClusterDeleteVirtualCluster API 작업을 실행하는 데 사용하는 IAM 역할에도 다음 권한이 있는지 확인하십시오.

    { "Effect": "Allow", "Action": [ "eks:DescribeAccessEntry", "eks:CreateAccessEntry", "eks:DeleteAccessEntry", "eks:ListAssociatedAccessPolicies", "eks:AssociateAccessPolicy", "eks:DisassociateAccessPolicy" ], "Resource": "*" }

개념 및 용어

다음은 Amazon EKS CAM과 관련된 용어 및 개념 목록입니다.

  • 가상 클러스터 (VC) — Amazon EKS에서 생성된 네임스페이스의 논리적 표현입니다. Amazon EKS 클러스터 네임스페이스에 대한 1:1 링크입니다. 이를 사용하여 지정된 네임스페이스 내의 Amazon EKS 클러스터에서 Amazon EMR 워크로드를 실행할 수 있습니다.

  • 네임스페이스 — 단일 EKS 클러스터 내에서 리소스 그룹을 격리하는 메커니즘입니다.

  • 액세스 정책 — EKS 클러스터 내 IAM 역할에 액세스 및 작업을 부여하는 권한.

  • 액세스 항목 — 역할 arn으로 생성된 항목입니다. 액세스 항목을 액세스 정책에 연결하여 Amazon EKS 클러스터에서 특정 권한을 할당할 수 있습니다.

  • EKS 액세스 입력 통합 가상 클러스터 — Amazon EKS의 액세스 입력 API 작업을 사용하여 만든 가상 클러스터입니다.