建立叢集後,如何對 Amazon EKS 環境中的錯誤進行疑難排解?

3 分的閱讀內容
0

建立叢集後,我的 Amazon Elastic Kubernetes Service (Amazon EKS) 環境中出現錯誤。

簡短描述

您可以使用 AWSPremiumSupport-TroubleshootEKSCluster 自動化工作流程,針對 Amazon EKS 環境的常見錯誤進行疑難排解。該工作流程提供詳細報告,其中列出錯誤、警告和 Amazon Web Services (AWS) 建議的最佳實務連結。

**注意:**若要使用 AWSPremiumSupport-TroubleshootEKSCluster 自動化工作流程,必須訂閱企業或商業支援方案

如果您遇到下列任何問題,可以使用 AWSPremiumSupport-TroubleshootEKSCluster 自動化工作流程:

  • 您的 Kubernetes 叢集自動資源配置器無法正常運作。
  • 您的內部負載平衡器未在私有子網路或公有子網路中建立。
  • 您不知道工作節點是否使用最新的 Amazon Machine Image (AMI)。
  • aws-node pod 中出現存取遭拒錯誤。
  • 您無法提取 Amazon Elastic Container Registry (Amazon ECR) 映像。
  • 您的受管理節點無法穩定,或者您的自我管理節點不會加入叢集。

AWSPremiumSupport-TroubleshootEKSCluster 自動化工作流程會執行下列檢查:

  • 針對面向內部和網際網路的負載平衡器和工作者安全群組,檢查 Auto Scaling 群組是否有 Cluster AutoScaler 子網路標籤。
    **重要事項:**如果您有一個以上的安全群組與工作節點關聯,則必須將標籤套用至其中一個安全群組。 將標籤的鍵設定為 kubernetes.io/cluster/your-cluster-name。將值設定為 owned。如果您只有一個安全群組與您的工作節點關聯,則此標籤為選用。
  • 檢查工作節點是否有最新的 AMI。
  • 檢查安全群組規則是否有最小和建議的設定。例如,工作流程會從叢集的安全群組 (即連接至叢集的所有安全群組),以及從工作者安全群組檢查輸入和輸出。
  • 檢查自訂網路存取控制清單 (network ACL) 組態。
  • 檢查工作節點上的 AWS Identity and Access Management (IAM) 政策,包括 AmazonEKSWorkerNodePolicyAmazonEC2ContainerRegistryReadOnly 政策
  • 檢查工作節點是否可以透過檢查子網路所在的路由表,來連線至網際網路。

解決方案

讓您的工作節點可供探索

若要讓您的工作節點可供探索,請使用 AWSPremiumSupport-TroubleshootEKSCluster 自動化工作流程和您的 Amazon EKS 叢集:

1.    開啟 Amazon EC2 主控台

2.    在導覽窗格中,選擇 Instances (執行個體)。

3.    針對您的工作節點選取 Amazon Elastic Compute Cloud (Amazon EC2) 執行個體,然後選擇 Tags (標籤) 索引標籤。

4.    選擇 Add/Edit Tags (新增/編輯標籤)。

5.    在 Key (鍵) 中,輸入 kubernetes.io/cluster/your-cluster-name。在 Value (值) 中,輸入 'owned'/ 'shared'

6.    選擇 Save (儲存)。

AWSPremiumSupport-TroubleshootEKSCluster 自動化工作流程會依據下列政策執行。此政策必須包含存取叢集的最小許可。該叢集只能透過 AutomationAssumeRole 存取。

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "AWSPremiumSupportTroubleshootEKSCluster",
      "Effect": "Allow",
      "Action": [
        "eks:ListNodegroups",
        "eks:DescribeCluster",
        "eks:DescribeNodegroup",
        "iam:GetInstanceProfile",
        "iam:ListInstanceProfiles",
        "iam:ListAttachedRolePolicies",
        "autoscaling:DescribeAutoScalingGroups",
        "ec2:DescribeInstanceTypes",
        "ec2:DescribeInstances",
        "ec2:DescribeNatGateways",
        "ec2:DescribeSecurityGroups",
        "ec2:DescribeVpcs",
        "ec2:DescribeSubnets",
        "ec2:DescribeNetworkAcls",
        "ec2:DescribeRouteTables"
      ],
      "Resource": "*"
    },
    {
      "Sid": "GetPublicSSMParams",
      "Effect": "Allow",
      "Action": "ssm:GetParameter",
      "Resource": [
        "arn:aws:ssm:*:*:parameter/aws/service/eks/optimized-ami/*/amazon-linux-2/recommended/image_id",
        "arn:aws:ssm:*:*:parameter/aws/service/ami-windows-latest/Windows_Server-2019-English-Core-EKS_Optimized-*/image_id",
        "arn:aws:ssm:*:*:parameter/aws/service/ami-windows-latest/Windows_Server-2019-English-Full-EKS_Optimized-*/image_id",
        "arn:aws:ssm:*:*:parameter/aws/service/ami-windows-latest/Windows_Server-1909-English-Core-EKS_Optimized-*/image_id",
        "arn:aws:ssm:*:*:parameter/aws/service/eks/optimized-ami/*/amazon-linux-2-gpu/recommended/image_id"
      ]
    },
    {
      "Sid": "UploadObjectToS3",
      "Effect": "Allow",
      "Action": [
        "s3:GetBucketPolicyStatus",
        "s3:GetBucketAcl",
        "s3:PutObject"
      ],
      "Resource": [
        "<BUCKET_ARN>",
        "<BUCKET_ARN>/AWSPremiumSupport-TroubleshootEKSCluster-*"
      ]
    }
  ]
}

從 AWS Systems Manager 主控台執行自動化工作流程

1.    開啟 Systems Manager 主控台

2.    在導覽窗格中,選擇 Automation (自動化)。

**注意:**如果 Systems Manager 首頁先開啟,請選擇選單圖示以開啟導覽窗格,然後選擇 Automation (自動化)。

3.    選擇 Execute automation (執行自動化)。

4.    在 Automation document (自動化文件) 搜尋方塊中,輸入 AWSPremiumSupport-TroubleshootEKSCluster,然後按 Enter 鍵。

5.    從搜尋結果中,選取 AWSPremiumSupport-TroubleshootEKSCluster

**注意:**文件擁有者為 Amazon

6.    在 Document description (文件描述) 索引標籤中,確認 Document version (文件版本) 設定為 Default version at runtime (在執行時間為預設版本)。

7.    選擇 Next (下一步)。

8.    在 Execute automation document (執行自動化文件) 區段,選擇 Simple execution (簡單執行)。

9.    在 Input parameters (輸入參數) 區段中,設定下列參數:

ClusterName 設定為叢集的名稱。此叢集必須在您的 AWS 帳戶中執行。
AutomationAssumeRole 設定為您要用於工作流程的 IAM 角色。
(選用) 如有需要,請將 BucketName 設定為您要上傳報告的 Amazon Simple Storage Service (Amazon S3) 儲存貯體。

注意:如果您想要指定 AutomationAssumeRole,則建立可套用至政策的 IAM 角色和 S3 儲存貯體。然後,將報告上傳至您自己的 S3 儲存貯體 (BucketName),以進行 SSM 自動化。

10.    選擇 Execute (執行)。

11.    若要監控進度,請選擇正在執行的 Automation (自動化),然後選擇 Steps (步驟) 標籤。

12.    程序完成後,選擇 Descriptions (說明) 索引標籤,然後選擇 View output (檢視輸出) 以檢視結果。

**注意:**結果會顯示為報告,其中列出叢集的所有錯誤和警告。

從 AWS CLI 執行自動化工作流程

**注意:**如果您在執行 AWS Command Line Interface (AWS CLI) 命令時收到錯誤,請確保您使用的是最新的 AWS CLI 版本。如果您想要指定 AutomationAssumeRole,並將報告上傳至您自己的 S3 儲存貯體 (S3BucketName),以執行自動化工作流程,請建立可套用至政策的 IAM 角色和 S3 儲存貯體。

如果您想要在 S3 儲存貯體中報告,請執行此命令:

aws ssm start-automation-execution --document-name "AWSPremiumSupport-TroubleshootEKSCluster" --document-version "\$DEFAULT" --parameters '{"ClusterName":["your-eks-cluster"],"AutomationAssumeRole":["arn:aws:iam::123456789012:role/eks-troubleshooter-role"],"S3BucketName":["your_bucket"]}' --region your_region

如果您不想將報告上傳至 S3 儲存貯體,請執行此命令:

aws ssm start-automation-execution --document-name "AWSPremiumSupport-TroubleshootEKSCluster" --document-version "\$DEFAULT" --parameters '{"ClusterName":["your-eks-cluster"],"AutomationAssumeRole":["arn:aws:iam::123456789012:role/eks-troubleshooter-role"]}' --region your_region

AWS 官方
AWS 官方已更新 8 個月前