AWS용 GKE는 AWS IAM 역할을 사용하여 클러스터 및 노드 풀을 만들고 관리합니다. 이 페이지에서는 다음과 같은 기본 역할을 만드는 방법을 설명합니다.
- GKE Multi-Cloud API 서비스 에이전트 역할
- GKE Multi-Cloud API는 이 AWS IAM 역할을 사용해서 AWS API를 사용하여 리소스를 관리합니다. 이 역할은 서비스 에이전트라고 하는 Google 관리 서비스 계정에 사용됩니다.
- 제어 영역 AWS IAM 역할
- 클러스터 제어 영역은 이 역할을 사용해서 노드 풀을 제어합니다.
- 노드 풀 AWS IAM 역할
- 제어 영역은 이 역할을 사용하여 노드 풀 VM을 만듭니다.
이 페이지에서는 다음 상황에서 역할을 만드는 방법을 보여줍니다.
- 테스트에 유용한 기본 권한 집합
- 특정 AWS 태그를 사용하여 리소스에서 작동하는 권한
조직의 보안 정책을 충족하기 위해 이러한 옵션 중 하나를 선택할 수 있습니다. 태그에 대한 자세한 내용은 AWS 리소스 태그 지정을 참조하세요.
선택적으로 조직 요구사항을 충족하기 위해 AWS용 GKE에 사용되는 AWS IAM 역할의 권한 범위를 지정할 수 있습니다. 자세한 내용은 AWS IAM 역할을 참조하세요.
시작하기 전에
특정 태그를 사용하여 리소스에서 작동하는 권한을 만들도록 선택하면 태그 및 값을 선택해야 합니다. 그런 후 이러한 값을 사용해서 클러스터 내 리소스에 태그를 지정하여 액세스를 제한합니다.
GKE Multi-Cloud API 서비스 에이전트 역할 만들기
GKE Multi-Cloud API 서비스 에이전트 역할을 만들려면 다음 명령어를 사용하여 Google Cloud 제품 번호를 검색하고 이를 사용해서 역할을 만듭니다.
PROJECT_ID="$(gcloud config get-value project)"
PROJECT_NUMBER=$(gcloud projects describe "$PROJECT_ID" \
--format "value(projectNumber)")
aws iam create-role --role-name API_ROLE \
--assume-role-policy-document '{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "",
"Effect": "Allow",
"Principal": {
"Federated": "accounts.google.com"
},
"Action": "sts:AssumeRoleWithWebIdentity",
"Condition": {
"StringEquals": {
"accounts.google.com:sub": "service-'$PROJECT_NUMBER'@gcp-sa-gkemulticloud.iam.gserviceaccount.com"
}
}
}
]
}'
API_ROLE
을 이 역할의 이름으로 바꿉니다.
나중에 사용할 수 있도록 이 명령어로 생성된 Amazon 리소스 이름(ARN)을 저장합니다.
범위가 지정된 권한 만들기
기본 권한을 사용하여 또는 특정 태그를 갖는 리소스로 범위가 지정된 GKE Multi-Cloud API 서비스 에이전트 역할에 대해 정책을 만들려면 아래를 선택합니다. 그런 후 다음 명령어를 실행하세요.
aws iam create-policy --policy-name API_POLICY \
--policy-document '{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "",
"Effect": "Allow",
"Action": [
"ec2:AuthorizeSecurityGroupEgress",
"ec2:AuthorizeSecurityGroupIngress",
"ec2:CreateLaunchTemplate",
"ec2:CreateNetworkInterface",
"ec2:CreateSecurityGroup",
"ec2:CreateTags",
"ec2:CreateVolume",
"ec2:DeleteLaunchTemplate",
"ec2:DeleteNetworkInterface",
"ec2:DeleteSecurityGroup",
"ec2:DeleteTags",
"ec2:DeleteVolume",
"ec2:DescribeAccountAttributes",
"ec2:DescribeInstances",
"ec2:DescribeInternetGateways",
"ec2:DescribeKeyPairs",
"ec2:DescribeLaunchTemplates",
"ec2:DescribeNetworkInterfaces",
"ec2:DescribeSecurityGroupRules",
"ec2:DescribeSecurityGroups",
"ec2:DescribeSubnets",
"ec2:DescribeVpcs",
"ec2:GetConsoleOutput",
"ec2:ModifyInstanceAttribute",
"ec2:ModifyNetworkInterfaceAttribute",
"ec2:RevokeSecurityGroupEgress",
"ec2:RevokeSecurityGroupIngress",
"ec2:RunInstances",
"iam:AWSServiceName",
"iam:CreateServiceLinkedRole",
"iam:GetInstanceProfile",
"iam:PassRole",
"autoscaling:CreateAutoScalingGroup",
"autoscaling:CreateOrUpdateTags",
"autoscaling:DeleteAutoScalingGroup",
"autoscaling:DeleteTags",
"autoscaling:DescribeAutoScalingGroups",
"autoscaling:DisableMetricsCollection",
"autoscaling:EnableMetricsCollection",
"autoscaling:TerminateInstanceInAutoScalingGroup",
"autoscaling:UpdateAutoScalingGroup",
"elasticloadbalancing:AddTags",
"elasticloadbalancing:CreateListener",
"elasticloadbalancing:CreateLoadBalancer",
"elasticloadbalancing:CreateTargetGroup",
"elasticloadbalancing:DeleteListener",
"elasticloadbalancing:DeleteLoadBalancer",
"elasticloadbalancing:DeleteTargetGroup",
"elasticloadbalancing:DescribeListeners",
"elasticloadbalancing:DescribeLoadBalancers",
"elasticloadbalancing:DescribeTargetGroups",
"elasticloadbalancing:DescribeTargetHealth",
"elasticloadbalancing:ModifyTargetGroupAttributes",
"elasticloadbalancing:RemoveTags",
"kms:DescribeKey",
"kms:Encrypt",
"kms:GenerateDataKeyWithoutPlaintext"
],
"Resource": "*"
}
]
}'
API_POLICY
를 GKE Multi-Cloud API AWS IAM 정책 이름으로 바꿉니다.
선택적으로 Resource
값을 arn:aws:iam::ACCOUNT_ID:*
로 설정하여 이 정책이 적용되는 리소스를 특정 계정으로 제한하고 ACCOUNT_ID를 AWS 계정 ID로 바꿀 수 있습니다.
aws iam create-policy --policy-name API_POLICY _ec2 \
--policy-document '{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ec2:DescribeAccountAttributes",
"ec2:DescribeInstances",
"ec2:DescribeInternetGateways",
"ec2:DescribeKeyPairs",
"ec2:DescribeLaunchTemplates",
"ec2:DescribeNetworkInterfaces",
"ec2:DescribeSecurityGroups",
"ec2:DescribeSecurityGroupRules",
"ec2:DescribeSubnets",
"ec2:DescribeVpcs",
"ec2:GetConsoleOutput"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": ["ec2:CreateSecurityGroup"],
"Resource": ["arn:aws:ec2:*:*:security-group/*"],
"Condition": {
"StringEquals": {
"aws:RequestTag/ACCESS_CONTROL_TAG_KEY ": "ACCESS_CONTROL_TAG_VALUE "
}
}
},
{
"Effect": "Allow",
"Action": ["ec2:CreateSecurityGroup"],
"Resource": ["arn:aws:ec2:*:*:vpc/*"]
},
{
"Effect": "Allow",
"Action": [
"ec2:AuthorizeSecurityGroupEgress",
"ec2:AuthorizeSecurityGroupIngress",
"ec2:DeleteSecurityGroup",
"ec2:RevokeSecurityGroupEgress",
"ec2:RevokeSecurityGroupIngress"
],
"Resource": ["arn:aws:ec2:*:*:security-group/*"],
"Condition": {
"StringEquals": {
"aws:ResourceTag/ACCESS_CONTROL_TAG_KEY ": "ACCESS_CONTROL_TAG_VALUE "
}
}
},
{
"Effect": "Allow",
"Action": [
"ec2:AuthorizeSecurityGroupEgress",
"ec2:AuthorizeSecurityGroupIngress"
],
"Resource": ["arn:aws:ec2:*:*:security-group-rule/*"],
"Condition": {
"StringEquals": {
"aws:RequestTag/ACCESS_CONTROL_TAG_KEY ": "ACCESS_CONTROL_TAG_VALUE "
}
}
},
{
"Effect": "Allow",
"Action": ["ec2:CreateLaunchTemplate"],
"Resource": ["arn:aws:ec2:*:*:launch-template/*"],
"Condition": {
"StringEquals": {
"aws:RequestTag/ACCESS_CONTROL_TAG_KEY ": "ACCESS_CONTROL_TAG_VALUE "
}
}
},
{
"Effect": "Allow",
"Action": [
"ec2:DeleteLaunchTemplate"
],
"Resource": ["arn:aws:ec2:*:*:launch-template/*"],
"Condition": {
"StringEquals": {
"aws:ResourceTag/ACCESS_CONTROL_TAG_KEY ": "ACCESS_CONTROL_TAG_VALUE "
}
}
},
{
"Effect": "Allow",
"Action": ["ec2:RunInstances"],
"Resource": ["arn:aws:ec2:*:*:image/ami-*"],
"Condition": {
"StringEquals": {
"ec2:Owner": ["099720109477", "amazon"]
}
}
},
{
"Effect": "Allow",
"Action": ["ec2:RunInstances"],
"Resource": [
"arn:aws:ec2:*:*:subnet/*"
],
"Condition": {
"ArnLike": {
"ec2:LaunchTemplate": "arn:aws:ec2:*:*:launch-template/*"
}
}
},
{
"Effect": "Allow",
"Action": ["ec2:RunInstances"],
"Resource": [
"arn:aws:ec2:*:*:instance/*",
"arn:aws:ec2:*:*:key-pair/*",
"arn:aws:ec2:*:*:launch-template/*",
"arn:aws:ec2:*:*:network-interface/*",
"arn:aws:ec2:*:*:security-group/*",
"arn:aws:ec2:*:*:volume/*"
],
"Condition": {
"Bool": {
"ec2:IsLaunchTemplateResource": "true"
}
}
},
{
"Effect": "Allow",
"Action": [
"ec2:CreateVolume"
],
"Resource": ["arn:aws:ec2:*:*:volume/*"],
"Condition": {
"StringEquals": {
"aws:RequestTag/ACCESS_CONTROL_TAG_KEY ": "ACCESS_CONTROL_TAG_VALUE "
}
}
},
{
"Effect": "Allow",
"Action": [
"ec2:DeleteVolume"
],
"Resource": ["arn:aws:ec2:*:*:volume/*"],
"Condition": {
"StringEquals": {
"aws:ResourceTag/ACCESS_CONTROL_TAG_KEY ": "ACCESS_CONTROL_TAG_VALUE "
}
}
},
{
"Effect": "Allow",
"Action": [
"ec2:CreateNetworkInterface"
],
"Resource": ["arn:aws:ec2:*:*:network-interface/*"],
"Condition": {
"StringEquals": {
"aws:RequestTag/ACCESS_CONTROL_TAG_KEY ": "ACCESS_CONTROL_TAG_VALUE "
}
}
},
{
"Effect": "Allow",
"Action": ["ec2:CreateNetworkInterface"],
"Resource": ["arn:aws:ec2:*:*:security-group/*"],
"Condition": {
"StringEquals": {
"aws:ResourceTag/ACCESS_CONTROL_TAG_KEY ": "ACCESS_CONTROL_TAG_VALUE "
}
}
},
{
"Effect": "Allow",
"Action": ["ec2:CreateNetworkInterface"],
"Resource": ["arn:aws:ec2:*:*:subnet/*"]
},
{
"Effect": "Allow",
"Action": [
"ec2:DeleteNetworkInterface",
"ec2:ModifyNetworkInterfaceAttribute"
],
"Resource": [
"arn:aws:ec2:*:*:network-interface/*",
"arn:aws:ec2:*:*:security-group/*"
],
"Condition": {
"StringEquals": {
"aws:ResourceTag/ACCESS_CONTROL_TAG_KEY ": "ACCESS_CONTROL_TAG_VALUE "
}
}
},
{
"Action": [
"ec2:CreateTags"
],
"Effect": "Allow",
"Resource": [
"arn:aws:ec2:*:*:launch-template/*",
"arn:aws:ec2:*:*:network-interface/*",
"arn:aws:ec2:*:*:security-group/*",
"arn:aws:ec2:*:*:security-group-rule/*",
"arn:aws:ec2:*:*:volume/*"
],
"Condition": {
"StringEquals": {
"aws:RequestTag/ACCESS_CONTROL_TAG_KEY ": "ACCESS_CONTROL_TAG_VALUE "
}
}
},
{
"Action": [
"ec2:CreateTags"
],
"Effect": "Allow",
"Resource": [
"arn:aws:ec2:*:*:instance/*"
],
"Condition": {
"StringEquals": {
"ec2:CreateAction" : "RunInstances"
}
}
},
{
"Action": [
"ec2:CreateTags",
"ec2:DeleteTags"
],
"Effect": "Allow",
"Resource": [
"arn:aws:ec2:*:*:instance/*",
"arn:aws:ec2:*:*:launch-template/*",
"arn:aws:ec2:*:*:network-interface/*",
"arn:aws:ec2:*:*:security-group/*",
"arn:aws:ec2:*:*:security-group-rule/*",
"arn:aws:ec2:*:*:volume/*"
],
"Condition": {
"StringEquals": {
"aws:ResourceTag/ACCESS_CONTROL_TAG_KEY ": "ACCESS_CONTROL_TAG_VALUE "
}
}
},
{
"Effect": "Allow",
"Action": [
"ec2:ModifyInstanceAttribute"
],
"Resource": [
"arn:aws:ec2:*:*:instance/*",
"arn:aws:ec2:*:*:security-group/*"
],
"Condition": {
"StringEquals": {
"aws:ResourceTag/ACCESS_CONTROL_TAG_KEY ": "ACCESS_CONTROL_TAG_VALUE "
}
}
}
]
}'
다음을 바꿉니다.
API_POLICY
: GKE Multi-Cloud API AWS IAM 정책의 프리픽스입니다.ACCESS_CONTROL_TAG_KEY
: 이 정책에 적용되는 태그 키입니다.ACCESS_CONTROL_TAG_VALUE
: 이 정책에 적용되는 태그 값입니다.
선택적으로 AWS 리전 및 계정 ID로 이 정책을 더 제한할 수 있습니다. 정책을 리전 및 계정 ID로 제한하려면 arn:aws:ec2:*:*:security-group/*
과 같은 리소스 값을 arn:aws:ec2:AWS_REGION:ACCOUNT_ID:security-group/*
으로 바꿉니다.
다음 명령어에서 사용하도록 이 명령에 대해 생성된 ARN을 복사합니다.
태그 사용을 위한 추가 정책 만들기
태그를 사용하여 액세스를 제한할 경우 다음 단계에 따라 추가 정책을 만듭니다. 기본 정책을 사용하는 경우 GKE Multi-Cloud API 역할에 정책 연결로 건너뜁니다.
다음 명령어를 사용하여 AWS IAM에 대해 액세스를 제어하도록 정책을 만듭니다.
aws iam create-policy --policy-name
API_POLICY _iam \
--policy-document '{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["iam:CreateServiceLinkedRole"],
"Resource": [
"arn:aws:iam::*:role/aws-service-role/autoscaling.amazonaws.com/AWSServiceRoleForAutoScaling"
],
"Condition": {
"StringEquals": {
"iam:AWSServiceName": "autoscaling.amazonaws.com"
}
}
},
{
"Effect": "Allow",
"Action": ["iam:CreateServiceLinkedRole"],
"Resource": [
"arn:aws:iam::*:role/aws-service-role/elasticloadbalancing.amazonaws.com/AWSServiceRoleForElasticLoadBalancing"
],
"Condition": {
"StringEquals": {
"iam:AWSServiceName": "elasticloadbalancing.amazonaws.com"
}
}
},
{
"Effect": "Allow",
"Action": ["iam:PassRole"],
"Resource": ["arn:aws:iam::*:role/*"],
"Condition": {
"StringEquals": {
"iam:PassedToService": "ec2.amazonaws.com"
}
}
}
,
{
"Effect": "Allow",
"Action": ["iam:GetInstanceProfile"],
"Resource": ["arn:aws:iam::*:instance-profile/*"]
}
]
}'다음 명령어를 사용하여 AWS EC2 자동 확장 리소스에 대해 액세스를 제어하도록 정책을 만듭니다.
aws iam create-policy --policy-name
API_POLICY _autoscaling \
--policy-document '{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["autoscaling:DescribeAutoScalingGroups"],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": [
"autoscaling:CreateAutoScalingGroup",
"autoscaling:CreateOrUpdateTags"
],
"Resource": [
"arn:aws:autoscaling:*:*:autoScalingGroup:*:autoScalingGroupName/gke-*"
],
"Condition": {
"StringEquals": {
"aws:RequestTag/ACCESS_CONTROL_TAG_KEY ": "ACCESS_CONTROL_TAG_VALUE "
}
}
},
{
"Effect": "Allow",
"Action": [
"autoscaling:CreateOrUpdateTags",
"autoscaling:DeleteAutoScalingGroup",
"autoscaling:DeleteTags",
"autoscaling:DisableMetricsCollection",
"autoscaling:EnableMetricsCollection",
"autoscaling:TerminateInstanceInAutoScalingGroup",
"autoscaling:UpdateAutoScalingGroup"
],
"Resource": [
"arn:aws:autoscaling:*:*:autoScalingGroup:*:autoScalingGroupName/gke-*"
],
"Condition": {
"StringEquals": {
"aws:ResourceTag/ACCESS_CONTROL_TAG_KEY ": "ACCESS_CONTROL_TAG_VALUE "
}
}
}
]
}'나중에 사용할 수 있도록 이 명령어로 생성된 ARN을 저장합니다.
AWS Elastic 부하 분산기 리소스에 대해 액세스를 제어하는 정책을 만듭니다.
aws iam create-policy --policy-name
API_POLICY _elasticloadbalancing \
--policy-document '{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"elasticloadbalancing:DescribeListeners",
"elasticloadbalancing:DescribeLoadBalancers",
"elasticloadbalancing:DescribeTargetGroups",
"elasticloadbalancing:DescribeTargetHealth"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": [
"elasticloadbalancing:CreateTargetGroup",
"elasticloadbalancing:AddTags"
],
"Resource": ["arn:aws:elasticloadbalancing:*:*:targetgroup/gke-*"],
"Condition": {
"StringEquals": {
"aws:RequestTag/ACCESS_CONTROL_TAG_KEY ": "ACCESS_CONTROL_TAG_VALUE "
}
}
},
{
"Effect": "Allow",
"Action": [
"elasticloadbalancing:AddTags",
"elasticloadbalancing:DeleteTargetGroup",
"elasticloadbalancing:ModifyTargetGroupAttributes",
"elasticloadbalancing:RemoveTags"
],
"Resource": ["arn:aws:elasticloadbalancing:*:*:targetgroup/gke-*"],
"Condition": {
"StringEquals": {
"aws:ResourceTag/ACCESS_CONTROL_TAG_KEY ": "ACCESS_CONTROL_TAG_VALUE "
}
}
},
{
"Effect": "Allow",
"Action": [
"elasticloadbalancing:CreateListener",
"elasticloadbalancing:CreateLoadBalancer",
"elasticloadbalancing:AddTags"
],
"Resource": [
"arn:aws:elasticloadbalancing:*:*:listener/net/gke-*",
"arn:aws:elasticloadbalancing:*:*:loadbalancer/net/gke-*"
],
"Condition": {
"StringEquals": {
"aws:RequestTag/ACCESS_CONTROL_TAG_KEY ": "ACCESS_CONTROL_TAG_VALUE "
}
}
},
{
"Effect": "Allow",
"Action": [
"elasticloadbalancing:AddTags",
"elasticloadbalancing:DeleteListener",
"elasticloadbalancing:DeleteLoadBalancer",
"elasticloadbalancing:RemoveTags"
],
"Resource": [
"arn:aws:elasticloadbalancing:*:*:listener/net/gke-*",
"arn:aws:elasticloadbalancing:*:*:loadbalancer/net/gke-*"
],
"Condition": {
"StringEquals": {
"aws:ResourceTag/ACCESS_CONTROL_TAG_KEY ": "ACCESS_CONTROL_TAG_VALUE "
}
}
}
]
}'나중에 사용할 수 있도록 이 명령어로 생성된 ARN을 저장합니다.
AWS 키 관리 서비스 리소스에 대해 액세스를 제어하는 정책을 만듭니다.
각 개별 키의 권한에 대한 자세한 내용은 특정 권한으로 KMS 키 만들기를 참조하세요.
aws iam create-policy --policy-name
API_POLICY _kms \
--policy-document '{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["kms:DescribeKey"],
"Resource": ["arn:aws:kms:*:*:key/*"]
},
{
"Effect": "Allow",
"Action": ["kms:Encrypt"],
"Resource":CONTROL_PLANE_CONFIG_KMS_KEY_ARN
},
{
"Effect": "Allow",
"Action": ["kms:Encrypt"],
"Resource":NODE_POOL_CONFIG_KMS_KEY_ARN
},
{
"Effect": "Allow",
"Action": ["kms:GenerateDataKeyWithoutPlaintext"],
"Resource":CONTROL_PLANE_MAIN_VOLUME_KMS_KEY_ARN
}
]
}'다음을 바꿉니다.
CONTROL_PLANE_CONFIG_KMS_KEY_ARN
: KMS 제어 영역 구성 암호화 키 ARN. 클러스터에 KMS 키를 하나만 사용하는 경우 여기에서 모든 값에 해당 키의 ARN을 사용하세요.NODE_POOL_CONFIG_KMS_KEY_ARN
: KMS 노드 풀 구성 암호화 키 ARNCONTROL_PLANE_MAIN_VOLUME_KMS_KEY_ARN
: KMS 제어 영역 기본 볼륨 암호화 키 ARN
나중에 사용할 수 있도록 이 명령어로 생성된 ARN을 저장합니다.
GKE Multi-Cloud API 역할에 정책 연결
이전 단계에서 만든 각 정책에 대해 다음 명령어를 실행하여 GKE Multi-Cloud API 역할에 정책을 연결합니다.
aws iam attach-role-policy \
--policy-arn API_POLICY_ARN \
--role-name API_ROLE
바꾸기
API_POLICY_ARN
을 이전에 만든 각 정책의 API 정책 ARN으로 바꿉니다.API_ROLE
을 GKE Multi-Cloud API 서비스 에이전트 역할 이름으로 바꿉니다.
클러스터 또는 노드 풀 만들기
태그 지정된 리소스로 범위가 지정된 역할 및 정책을 만드는 경우 클러스터 또는 노드 풀을 만들 때 태그를 지정해야 합니다. 클러스터 및 노드 풀 만들기 명령어에 대해 --tags
매개변수를 사용하여 이를 수행합니다.
클러스터 만들기
클러스터를 만들려면 다음 안내에 따라 클러스터를 만들고 다음과 같이 --tags
매개변수를 포함합니다.
gcloud container aws clusters create CLUSTER_NAME \
...
--tags="ACCESS_CONTROL_TAG_KEY =ACCESS_CONTROL_TAG_VALUE "
다음을 바꿉니다.
ACCESS_CONTROL_TAG_KEY
: 이 정책에 적용되는 태그 키입니다.ACCESS_CONTROL_TAG_VALUE
: 이 정책에 적용되는 태그 값입니다.
노드 풀 만들기
노드 풀을 만들려면 안내에 따라 노드 풀을 만들고 다음과 같이 --tags
매개변수를 포함합니다.
gcloud container aws node-pools create NODE_POOL_NAME \
...
--tags "ACCESS_CONTROL_TAG_KEY =ACCESS_CONTROL_TAG_VALUE "
다음을 바꿉니다.
ACCESS_CONTROL_TAG_KEY
: 이 정책에 적용되는 태그 키입니다.ACCESS_CONTROL_TAG_VALUE
: 이 정책에 적용되는 태그 값입니다.
제어 영역 역할 만들기
기본 권한을 사용하여 제어 영역 역할을 만들려면 다음 단계를 수행합니다.
이 역할을 만들려면 다음 명령어를 실행합니다.
aws iam create-role --role-name
CONTROL_PLANE_ROLE \
--assume-role-policy-document '{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "",
"Effect": "Allow",
"Principal": {
"Service": "ec2.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}'CONTROL_PLANE_ROLE
을 제어 영역 역할의 이름으로 바꿉니다.이 역할에 대한 IAM 정책을 만듭니다. 데이터베이스 및 구성 암호화를 위한 여러 KMS 키를 만든 경우 모든 ARN을 쉼표로 구분된 목록으로 포함합니다.
제어 영역에 직접 연결할지 또는 제어 영역에 직접 연결하고 태그를 사용할지를 선택합니다.
aws iam create-policy --policy-name
CONTROL_PLANE_POLICY \
--policy-document '{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "",
"Effect": "Allow",
"Action": [
"ec2:AttachNetworkInterface",
"ec2:AttachVolume",
"ec2:AuthorizeSecurityGroupIngress",
"ec2:CreateRoute",
"ec2:CreateSecurityGroup",
"ec2:CreateSnapshot",
"ec2:CreateTags",
"ec2:CreateVolume",
"ec2:DeleteRoute",
"ec2:DeleteSecurityGroup",
"ec2:DeleteSnapshot",
"ec2:DeleteTags",
"ec2:DeleteVolume",
"ec2:DescribeAccountAttributes",
"ec2:DescribeAvailabilityZones",
"ec2:DescribeDhcpOptions",
"ec2:DescribeInstances",
"ec2:DescribeInstanceTypes",
"ec2:DescribeInternetGateways",
"ec2:DescribeLaunchTemplateVersions",
"ec2:DescribeRegions",
"ec2:DescribeRouteTables",
"ec2:DescribeSecurityGroups",
"ec2:DescribeSnapshots",
"ec2:DescribeSubnets",
"ec2:DescribeTags",
"ec2:DescribeVolumes",
"ec2:DescribeVolumesModifications",
"ec2:DescribeVpcs",
"ec2:DetachVolume",
"ec2:ModifyInstanceAttribute",
"ec2:ModifyVolume",
"ec2:RevokeSecurityGroupIngress",
"autoscaling:DescribeAutoScalingGroups",
"autoscaling:DescribeAutoScalingInstances",
"autoscaling:DescribeLaunchConfigurations",
"autoscaling:DescribeTags",
"autoscaling:SetDesiredCapacity",
"autoscaling:TerminateInstanceInAutoScalingGroup",
"elasticloadbalancing:AddTags",
"elasticloadbalancing:ApplySecurityGroupsToLoadBalancer",
"elasticloadbalancing:AttachLoadBalancerToSubnets",
"elasticloadbalancing:ConfigureHealthCheck",
"elasticloadbalancing:CreateListener",
"elasticloadbalancing:CreateLoadBalancer",
"elasticloadbalancing:CreateLoadBalancerListeners",
"elasticloadbalancing:CreateLoadBalancerPolicy",
"elasticloadbalancing:CreateTargetGroup",
"elasticloadbalancing:DeleteListener",
"elasticloadbalancing:DeleteLoadBalancer",
"elasticloadbalancing:DeleteLoadBalancerListeners",
"elasticloadbalancing:DeleteTargetGroup",
"elasticloadbalancing:DeregisterInstancesFromLoadBalancer",
"elasticloadbalancing:DeregisterTargets",
"elasticloadbalancing:DescribeListeners",
"elasticloadbalancing:DescribeLoadBalancerAttributes",
"elasticloadbalancing:DescribeLoadBalancerPolicies",
"elasticloadbalancing:DescribeLoadBalancers",
"elasticloadbalancing:DescribeTargetGroups",
"elasticloadbalancing:DescribeTargetHealth",
"elasticloadbalancing:DetachLoadBalancerFromSubnets",
"elasticloadbalancing:ModifyListener",
"elasticloadbalancing:ModifyLoadBalancerAttributes",
"elasticloadbalancing:ModifyTargetGroup",
"elasticloadbalancing:RegisterInstancesWithLoadBalancer",
"elasticloadbalancing:RegisterTargets",
"elasticloadbalancing:SetLoadBalancerPoliciesForBackendServer",
"elasticloadbalancing:SetLoadBalancerPoliciesOfListener",
"elasticfilesystem:CreateAccessPoint",
"elasticfilesystem:DeleteAccessPoint",
"elasticfilesystem:DescribeAccessPoints",
"elasticfilesystem:DescribeFileSystems",
"elasticfilesystem:DescribeMountTargets",
"kms:CreateGrant",
"kms:Decrypt",
"kms:Encrypt",
"kms:GrantIsForAWSResource"
],
"Resource": "*"
}
]
}'다음을 바꿉니다.
CONTROL_PLANE_POLICY
를 제어 영역 정책의 이름으로 바꿉니다.
aws iam create-policy --policy-name
CONTROL_PLANE_POLICY _autoscaling \
--policy-document '{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"autoscaling:DescribeAutoScalingGroups",
"autoscaling:DescribeAutoScalingInstances",
"autoscaling:DescribeLaunchConfigurations",
"autoscaling:DescribeTags"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": [
"autoscaling:SetDesiredCapacity",
"autoscaling:TerminateInstanceInAutoScalingGroup"
],
"Resource": [
"arn:aws:autoscaling:*:*:autoScalingGroup:*:autoScalingGroupName/gke-*"
],
"Condition": {
"StringEquals": {
"aws:ResourceTag/ACCESS_CONTROL_TAG_KEY ": "ACCESS_CONTROL_TAG_VALUE "
}
}
}
]
}'
aws iam create-policy --policy-nameCONTROL_PLANE_POLICY _ec2 \
--policy-document '{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ec2:DescribeAccountAttributes",
"ec2:DescribeAvailabilityZones",
"ec2:DescribeDhcpOptions",
"ec2:DescribeInstances",
"ec2:DescribeInstanceTypes",
"ec2:DescribeInternetGateways",
"ec2:DescribeLaunchTemplateVersions",
"ec2:DescribeRegions",
"ec2:DescribeRouteTables",
"ec2:DescribeSecurityGroups",
"ec2:DescribeSnapshots",
"ec2:DescribeSubnets",
"ec2:DescribeTags",
"ec2:DescribeVolumes",
"ec2:DescribeVolumesModifications",
"ec2:DescribeVpcs"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": ["ec2:AttachNetworkInterface"],
"Resource": [
"arn:aws:ec2:*:*:instance/*",
"arn:aws:ec2:*:*:network-interface/*"
]
},
{
"Effect": "Allow",
"Action": [
"ec2:CreateVolume",
"ec2:CreateTags",
"ec2:AttachVolume",
"ec2:DeleteVolume",
"ec2:DetachVolume",
"ec2:ModifyVolume"
],
"Resource": ["arn:aws:ec2:*:*:volume/*"]
},
{
"Effect": "Allow",
"Action": ["ec2:AttachVolume", "ec2:DetachVolume"],
"Resource": ["arn:aws:ec2:*:*:instance/*"]
},
{
"Effect": "Allow",
"Action": ["ec2:CreateSecurityGroup", "ec2:CreateTags"],
"Resource": ["arn:aws:ec2:*:*:security-group/*"]
},
{
"Effect": "Allow",
"Action": ["ec2:CreateSecurityGroup"],
"Resource": ["arn:aws:ec2:*:*:vpc/*"]
},
{
"Effect": "Allow",
"Action": [
"ec2:AuthorizeSecurityGroupIngress",
"ec2:DeleteSecurityGroup",
"ec2:RevokeSecurityGroupIngress"
],
"Resource": ["arn:aws:ec2:*:*:security-group/*"]
},
{
"Effect": "Allow",
"Action": ["ec2:CreateSnapshot", "ec2:CreateTags", "ec2:DeleteSnapshot"],
"Resource": ["arn:aws:ec2:*:*:snapshot/*"]
},
{
"Effect": "Allow",
"Action": ["ec2:CreateSnapshot"],
"Resource": ["arn:aws:ec2:*:*:volume/*"]
},
{
"Effect": "Allow",
"Action": ["ec2:CreateRoute", "ec2:DeleteRoute"],
"Resource": ["arn:aws:ec2:*:*:route-table/*"]
},
{
"Effect": "Allow",
"Action": ["ec2:ModifyInstanceAttribute"],
"Resource": [
"arn:aws:ec2:*:*:instance/*",
"arn:aws:ec2:*:*:security-group/*",
"arn:aws:ec2:*:*:volume/*"
]
},
{
"Effect": "Allow",
"Action": ["ec2:DeleteTags"],
"Resource": [
"arn:aws:ec2:*:*:security-group/*",
"arn:aws:ec2:*:*:snapshot/*",
"arn:aws:ec2:*:*:volume/*"
]
}
]
}'
aws iam create-policy --policy-nameCONTROL_PLANE_POLICY _elasticloadbalancing \
--policy-document '{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"elasticloadbalancing:DescribeLoadBalancers",
"elasticloadbalancing:DescribeLoadBalancerAttributes",
"elasticloadbalancing:DescribeListeners",
"elasticloadbalancing:DescribeLoadBalancerPolicies",
"elasticloadbalancing:DescribeTargetGroups",
"elasticloadbalancing:DescribeTargetHealth"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": [
"elasticloadbalancing:AddTags",
"elasticloadbalancing:AttachLoadBalancerToSubnets",
"elasticloadbalancing:ApplySecurityGroupsToLoadBalancer",
"elasticloadbalancing:CreateListener",
"elasticloadbalancing:CreateLoadBalancer",
"elasticloadbalancing:CreateLoadBalancerPolicy",
"elasticloadbalancing:CreateLoadBalancerListeners",
"elasticloadbalancing:ConfigureHealthCheck",
"elasticloadbalancing:DeleteLoadBalancer",
"elasticloadbalancing:DeleteLoadBalancerListeners",
"elasticloadbalancing:DetachLoadBalancerFromSubnets",
"elasticloadbalancing:DeregisterInstancesFromLoadBalancer",
"elasticloadbalancing:ModifyLoadBalancerAttributes",
"elasticloadbalancing:RegisterInstancesWithLoadBalancer",
"elasticloadbalancing:SetLoadBalancerPoliciesForBackendServer",
"elasticloadbalancing:SetLoadBalancerPoliciesOfListener"
],
"Resource": ["arn:aws:elasticloadbalancing:*:*:loadbalancer/*"]
},
{
"Effect": "Allow",
"Action": [
"elasticloadbalancing:AddTags",
"elasticloadbalancing:CreateTargetGroup",
"elasticloadbalancing:DeleteTargetGroup",
"elasticloadbalancing:DeregisterTargets",
"elasticloadbalancing:ModifyTargetGroup",
"elasticloadbalancing:RegisterTargets"
],
"Resource": ["arn:aws:elasticloadbalancing:*:*:targetgroup/*"]
},
{
"Effect": "Allow",
"Action": [
"elasticloadbalancing:DeleteListener",
"elasticloadbalancing:ModifyListener"
],
"Resource": ["arn:aws:elasticloadbalancing:*:*:listener/*"]
}
]
}'
aws iam create-policy --policy-nameCONTROL_PLANE_POLICY _elasticfilesystem \
--policy-document '{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"elasticfilesystem:DescribeAccessPoints",
"elasticfilesystem:DescribeFileSystems",
"elasticfilesystem:DescribeMountTargets"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": [
"elasticfilesystem:CreateAccessPoint"
],
"Resource": [
"arn:aws:elasticfilesystem:*:*:file-system/*"
]
},
{
"Effect": "Allow",
"Action": [
"elasticfilesystem:DeleteAccessPoint"
],
"Resource": [
"arn:aws:elasticfilesystem:*:*:access-point/*"
]
}
]
}'
aws iam create-policy --policy-nameCONTROL_PLANE_POLICY _kms \
--policy-document '{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["kms:Decrypt", "kms:Encrypt"],
"Resource":DATABASE_KMS_KEY_ARN
},
{
"Effect": "Allow",
"Action": ["kms:Decrypt"],
"Resource":CONTROL_PLANE_CONFIG_KMS_KEY_ARN
},
{
"Effect": "Allow",
"Action": ["kms:CreateGrant"],
"Resource":CONTROL_PLANE_MAIN_VOLUME_KMS_KEY_ARN ,
"Condition": {
"Bool": {
"kms:GrantIsForAWSResource": "true"
}
}
}
]
}'다음을 바꿉니다.
CONTROL_PLANE_POLICY
: 제어 영역 정책의 이름입니다.ACCESS_CONTROL_TAG_KEY
: 이 정책에 적용되는 태그 키입니다.ACCESS_CONTROL_TAG_VALUE
: 이 정책에 적용되는 태그 값입니다.DATABASE_KMS_KEY_ARN
: KMS etcd 암호화 키 ARNCONTROL_PLANE_CONFIG_KMS_KEY_ARN
: KMS 제어 영역 암호화 키 ARNCONTROL_PLANE_MAIN_VOLUME_KMS_KEY_ARN
: KMS 제어 영역 기본 볼륨 암호화 키 ARN
다음 명령어에 사용할 각
Policy.Arn
값을 복사합니다.HTTP 프록시를 사용하는 경우 AWS Secrets Manager의 추가 정책을 만듭니다.
aws iam create-policy --policy-name
CONTROL_PLANE_POLICY _secretsmanager \
--policy-document '{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"secretsmanager:GetSecretValue"
],
"Resource":PROXY_CONFIG_ARN
}
]
}'다음을 바꿉니다.
KMS_KEY_ARN
을 KMS etcd 암호화 키 ARN으로 바꿉니다.CONTROL_PLANE_POLICY
를 제어 영역 정책의 이름으로 바꿉니다.
다음 명령어에 사용할 각
Policy.Arn
의 값을 복사합니다.새 정책을 해당 역할에 연결합니다.
aws iam attach-role-policy \
--policy-arnCONTROL_PLANE_POLICY_ARN \
--role-nameCONTROL_PLANE_ROLE 다음을 바꿉니다.
CONTROL_PLANE_ROLE
CONTROL_PLANE_POLICY_ARN
을 이전 명령어의Policy.Arn
값으로 바꿉니다.
IAM 인스턴스 프로필을 만들기 위해 다음 명령어를 실행합니다.
aws iam create-instance-profile \
--instance-profile-nameCONTROL_PLANE_PROFILE CONTROL_PLANE_PROFILE
을 GKE Multi-Cloud 제어 영역 프로필의 이름으로 바꿉니다.마지막으로 바로 전에 만든 인스턴스 프로필에 새 역할을 추가합니다.
aws iam add-role-to-instance-profile \
--instance-profile-nameCONTROL_PLANE_PROFILE \
--role-nameCONTROL_PLANE_ROLE 다음을 바꿉니다.
CONTROL_PLANE_PROFILE
CONTROL_PLANE_ROLE
나중에 클러스터를 만들 때 여기에서 선택한 인스턴스 프로필 이름이 사용됩니다.
노드 풀 역할 만들기
기본 권한을 사용하여 노드 풀 역할을 만들려면 다음 단계를 따르세요.
사용할 노드 풀에서 VM의 역할을 만듭니다.
aws iam create-role --role-name
NODE_POOL_ROLE \
--assume-role-policy-document '{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "",
"Effect": "Allow",
"Principal": {
"Service": "ec2.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}'NODE_POOL_ROLE
을 노드 풀 역할 이름으로 바꿉니다.노드 풀 VM에 필요한 권한으로 정책을 만듭니다. 제어 영역에 직접 연결할지 또는 HTTP 프록시를 사용할지를 선택합니다.
aws iam create-policy --policy-name
NODE_POOL_POLICY _kms \
--policy-document '{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["kms:Decrypt"],
"Resource":NODE_POOL_CONFIG_KMS_KEY_ARN
}
]
}'다음을 바꿉니다.
NODE_POOL_POLICY
: 노드 풀 정책 이름NODE_POOL_CONFIG_KMS_KEY_ARN
: KMS 노드 풀 구성 암호화 키 ARN
aws iam create-policy --policy-name
NODE_POOL_POLICY _kms \
--policy-document '{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["kms:Decrypt"],
"Resource":NODE_POOL_CONFIG_KMS_KEY_ARN
}
]
}'
aws iam create-policy --policy-nameNODE_POOL_POLICY _secretsmanager \
--policy-document '{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"secretsmanager:GetSecretValue"
],
"Resource":PROXY_CONFIG_ARN
}
]
}'다음을 바꿉니다.
KMS_KEY_ARN
: 노드 풀의 KMS 키NODE_POOL_POLICY
: 노드 풀 정책 이름PROXY_CONFIG_ARN
: 프록시 구성 ARN. 자세한 내용은 프록시 구성 만들기를 참조하세요.
다음 명령어에 사용할 각 Policy.Arn 값을 복사합니다.
역할을 정책에 연결합니다.
aws iam attach-role-policy --role-name
NODE_POOL_ROLE \
--policy-arn "NODE_POOL_POLICY_ARN "다음을 바꿉니다.
NODE_POOL_ROLE
: 노드 풀 역할 이름NODE_POOL_POLICY_ARN
: 이전 명령어의Policy.Arn
값
워크로드가 ECR 컨테이너 레지스트리로 작동해야 하는 경우 ECR 액세스에 대한 다음 정책을 연결합니다.
다음 권한을 사용하여 정책을 만듭니다.
aws iam create-policy --policy-name
NODE_POOL_POLICY _ecr \
--policy-document '{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ecr-public:GetAuthorizationToken",
"sts:GetServiceBearerToken"
],
"Resource": "*"
}
]
}'Policy.Arn
값을NODE_POOL_ECR_POLICY_ARN
으로 복사합니다.만든 노드 풀 역할에 연결합니다.
aws iam attach-role-policy --role-name
NODE_POOL_ROLE \
--policy-arn "NODE_POOL_ECR_POLICY_ARN "다음을 바꿉니다.
NODE_POOL_ROLE
: 노드 풀 역할 이름NODE_POOL_ECR_POLICY_ARN
: 이전 명령어의Policy.Arn
값
비공개 레지스트리 액세스를 위해 AmazonEC2ContainerRegistryReadOnly를 노드 풀 역할에 연결합니다.
aws iam attach-role-policy --role-name
NODE_POOL_ROLE \
--policy-arn arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnlyNODE_POOL_ROLE
을 노드 풀 역할 이름으로 바꿉니다.이 역할에 대해 인스턴스 프로필을 만듭니다.
aws iam create-instance-profile \
--instance-profile-nameNODE_POOL_PROFILE NODE_POOL_PROFILE
을 노드 풀 프로필 이름으로 바꿉니다.새 역할을 인스턴스 프로필에 추가합니다.
aws iam add-role-to-instance-profile \
--instance-profile-nameNODE_POOL_PROFILE \
--role-nameNODE_POOL_ROLE 다음을 바꿉니다.
NODE_POOL_PROFILE
: 노드 풀 프로필 이름NODE_POOL_ROLE
: 노드 풀 역할 이름