GKE ב-AWS משתמש בתפקידי AWS IAM כדי ליצור ולנהל את האשכולות ומאגרי הצמתים. הדף הזה מיועד לאדמינים של זהויות וחשבונות, לאופרטורים ולמפתחים שרוצים ליצור ולנהל מדיניות שקשורה להרשאות משתמשים. מידע נוסף על תפקידים נפוצים ומשימות לדוגמה שאנחנו מתייחסים אליהם ב Google Cloud תוכן, זמין במאמר תפקידים נפוצים של משתמשים ומשימות ב-GKE.
בדף הזה מוסבר איך ליצור את תפקידי ברירת המחדל הבאים:
- תפקיד סוכן שירות של GKE Multi-Cloud API
- ממשק GKE Multi-Cloud API משתמש בתפקיד הזה ב-AWS IAM כדי לנהל משאבים באמצעות ממשקי AWS API. התפקיד הזה משמש חשבון שירות בניהול Google שנקרא סוכן שירות.
- תפקיד IAM ב-AWS במישור הבקרה
- רמת הבקרה של האשכול משתמשת בתפקיד הזה כדי לשלוט במאגרי הצמתים.
- תפקיד IAM ב-AWS של מאגר הצמתים
- רמת הבקרה משתמשת בתפקיד הזה כדי ליצור מכונות וירטואליות של מאגר הצמתים.
בדף הזה מוסבר איך ליצור תפקידים במצבים הבאים:
- קבוצת הרשאות שמוגדרת כברירת מחדל, שימושית לבדיקות
- הרשאות להפעלה של משאבים עם תגי AWS מסוימים
אתם יכולים לבחור באחת מהאפשרויות האלה כדי לעמוד בדרישות של מדיניות האבטחה של הארגון. מידע נוסף על תגים זמין במאמר תיוג משאבי AWS.
אפשר גם להגדיר את ההרשאות של תפקידי ה-IAM ב-AWS שמשמשים את GKE ב-AWS בהתאם לדרישות של הארגון. למידע נוסף, ראו תפקידים ב-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 בשם של מדיניות AWS IAM של GKE Multi-Cloud API.
אפשר גם להגביל את המשאבים שהמדיניות הזו חלה עליהם לחשבון מסוים. כדי לעשות את זה, מגדירים את הערך של Resource ל-arn:aws:iam::ACCOUNT_ID:* ומחליפים את ACCOUNT_ID במזהה חשבון AWS.
היקף התגים
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 ולמזהה חשבון. כדי להגביל את המדיניות לאזור ולמזהה חשבון, מחליפים את הערכים של Resource (משאב), כמו 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 Auto Scaling, מריצים את הפקודה הבאה:
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 Load Balancer.
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 שנוצר על ידי הפקודה הזו לשימוש בהמשך.
יוצרים מדיניות כדי לשלוט בגישה למשאבים של שירות ניהול מפתחות (KMS) של 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: שם ה-ARN של מפתח ההצפנה של מישור הבקרה של KMS. אם אתם משתמשים רק במפתח KMS אחד עבור האשכול, צריך להשתמש ב-ARN של המפתח הזה עבור כל הערכים כאן. -
NODE_POOL_CONFIG_KMS_KEY_ARN: מפתח ההצפנה של ההגדרה של מאגר הצמתים של KMS -
CONTROL_PLANE_MAIN_VOLUME_KMS_KEY_ARN: מספר ה-ARN של מפתח ההצפנה הראשי של עוצמת הקול במישור הבקרה של KMS
שומרים את ה-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עם ה-ARN של מדיניות ה-API של כל מדיניות שיצרתם בעבר -
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-name CONTROL_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-name CONTROL_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-name CONTROL_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-name CONTROL_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 ARN -
CONTROL_PLANE_CONFIG_KMS_KEY_ARN: KMS control plane encryption key ARN -
CONTROL_PLANE_MAIN_VOLUME_KMS_KEY_ARN: מפתח ההצפנה הראשי של עוצמת הקול במישור הבקרה של KMS
מעתיקים את הערך של כל
Policy.Arnלשימוש בפקודה הבאה.-
אם אתם משתמשים בשרת proxy מסוג 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-arn CONTROL_PLANE_POLICY_ARN \ --role-name CONTROL_PLANE_ROLEמחליפים את מה שכתוב בשדות הבאים:
CONTROL_PLANE_ROLE-
CONTROL_PLANE_POLICY_ARNעם הערךPolicy.Arnמהפקודה הקודמת
כדי ליצור פרופיל מופע של IAM, מריצים את הפקודה הבאה.
aws iam create-instance-profile \ --instance-profile-name CONTROL_PLANE_PROFILEמחליפים את
CONTROL_PLANE_PROFILEבשם של פרופיל מישור הבקרה של GKE Multi-Cloud.לבסוף, מוסיפים את התפקיד החדש לפרופיל המכונה שזה עתה יצרתם.
aws iam add-role-to-instance-profile \ --instance-profile-name CONTROL_PLANE_PROFILE \ --role-name CONTROL_PLANE_ROLEמחליפים את מה שכתוב בשדות הבאים:
CONTROL_PLANE_PROFILECONTROL_PLANE_ROLE
תשתמשו בשם פרופיל המופע שתבחרו כאן בהמשך, במהלך יצירת האשכול.
יצירת התפקיד של מאגר הצמתים
כדי ליצור את התפקיד של מאגר הצמתים עם הרשאות ברירת המחדל:
יוצרים תפקיד לשימוש המכונות הווירטואליות במאגר הצמתים.
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בשם התפקיד של מאגר הצמתים.יוצרים מדיניות עם ההרשאות שנדרשות למכונות וירטואליות במאגר הצמתים. בוחרים אם להתחבר ישירות למישור הבקרה או להשתמש בשרת proxy של 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.
Proxy ל-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 } ] }' aws iam create-policy --policy-name NODE_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 של הגדרות ה-proxy. מידע נוסף זמין במאמר יצירת הגדרות של שרת proxy.
מעתיקים את הערך של כל 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/AmazonEC2ContainerRegistryReadOnlyמחליפים את
NODE_POOL_ROLEבשם של תפקיד מאגר הצמתים.-
יוצרים פרופיל מכונה לתפקיד הזה.
aws iam create-instance-profile \ --instance-profile-name NODE_POOL_PROFILEמחליפים את
NODE_POOL_PROFILEבשם הפרופיל של מאגר הצמתים.מוסיפים את התפקיד החדש לפרופיל המופע.
aws iam add-role-to-instance-profile \ --instance-profile-name NODE_POOL_PROFILE \ --role-name NODE_POOL_ROLEמחליפים את מה שכתוב בשדות הבאים:
-
NODE_POOL_PROFILE: השם של פרופיל מאגר הצמתים. -
NODE_POOL_ROLE: השם של התפקיד במאגר הצמתים.
-