簡體   English   中英

帶有 IRSA 授權錯誤的 AWS ALB 入口控制器

[英]AWS ALB Ingress Controller with IRSA authorization error

我正在嘗試使用IRSA方法而不是 kube2iam 設置 AWS ALB 入口控制器。 然而,由於缺乏文檔,所以我走到了死胡同。

到目前為止我做了什么:

  • 為我的集群配置了 OIDC 提供程序

eksctl utils associate-iam-oidc-provider --cluster devops --approve

  • 使用模板創建了正確的策略

  • 創建將被 Ingress Controller 使用並關聯策略的 IAM 服務帳戶

eksctl create iamserviceaccount --name alb-ingress --namespace default --cluster devops --attach-policy-arn arn:aws:iam::112233445566:policy/eks-ingressController-iam-policy-IngressControllerPolicy-1111111111 --approve

  • 提供了部署所需的 rbac 規則

kubectl apply -f rbac-role.yaml

  • 使用此模板部署了 AWS Ingress Controller。 關注所以ServiceAccount匹配我之前創建的服務帳戶。

到這里為止的一切都部署得很好。 現在我嘗試部署我的 Ingress 服務,但我收到此錯誤(在控制器日志中)

kubebuilder/controller "msg"="Reconciler error" "error"="failed to build LoadBalancer configuration due to failed to get AWS tags. Error: AccessDeniedException: User: arn:aws:sts::1122334455:assumed-role/eksctl-devops-nodegroup-ng-1-work-NodeInstanceRole-J08FDJHIWPI7/i-000000000000 is not authorized to perform: tag:GetResources\n\tstatus code: 400, request id: 94d614a1-c05d-4b92-8ad6-86b450407f6a"  "Controller"="alb-ingress-controller" "Request"={"Namespace":"superset","Name":"superset-ingress"}

顯然該節點沒有創建 ALB 的適當權限,我想如果我將我的策略附加到日志中聲明的角色,它將起作用。 但這違背了使用 IRSA 方法的全部目的,對嗎?

我希望入口控制器 pod 需要適當的權限 - 通過使用服務帳戶 - 來創建 ALB 而不是節點。 我在這里錯過了什么嗎?

所以,萬一有人遇到同樣的問題。

解決的辦法是,在創建時RBAC角色,從RBAC的role.yaml注釋掉(如提供在這里),它會創建服務帳戶的最后一部分。

由於我們已經使用 eksctl 創建了一個服務帳戶並將 aws 策略附加到它,我們也可以將 rbac 權限附加到此服務帳戶。 然后這個服務賬號就可以在 ingress 控制器 pod 中正常使用來發揮它的魔力了。

根據文檔需要獲得對 ALB 進行 CRUD 的許可。 如果您想嘗試僅為 ALB 驅動程序 Pod 提供一個具有創建 ALB 權限的角色,但我尚未對其進行測試,並且我不確定這是否重要,如果您的整個調度程序已被授予使用 ALB 驅動程序/pod 的權限,您可以在 AWS 上創建這些對象。

我沒有使用 EKS 3.0 的集群創建工具,而是我有自己的 CFT,由於我的組織有額外的安全要求,我用它來創建工作人員。

我已經創建並將波紋管管理策略附加到需要創建 ALB 的工作人員並且它可以正常工作。

  ALBPolicy:
    Type: "AWS::IAM::ManagedPolicy"
    Properties:
      Description: Allows workers to CRUD alb's
      PolicyDocument:
        Version: "2012-10-17"
        Statement:
          -
            Effect: "Allow"
            Action:
              - "acm:DescribeCertificate"
              - "acm:ListCertificates"
              - "acm:GetCertificate"
            Resource: "*"
          -
            Effect: "Allow"
            Action:
              - "ec2:AuthorizeSecurityGroupIngress"
              - "ec2:CreateSecurityGroup"
              - "ec2:CreateTags"
              - "ec2:DeleteTags"
              - "ec2:DeleteSecurityGroup"
              - "ec2:DescribeAccountAttributes"
              - "ec2:DescribeAddresses"
              - "ec2:DescribeInstances"
              - "ec2:DescribeInstanceStatus"
              - "ec2:DescribeInternetGateways"
              - "ec2:DescribeNetworkInterfaces"
              - "ec2:DescribeSecurityGroups"
              - "ec2:DescribeSubnets"
              - "ec2:DescribeTags"
              - "ec2:DescribeVpcs"
              - "ec2:ModifyInstanceAttribute"
              - "ec2:ModifyNetworkInterfaceAttribute"
              - "ec2:RevokeSecurityGroupIngress"
            Resource: "*"
          -
            Effect: "Allow"
            Action:
              - "elasticloadbalancing:AddListenerCertificates"
              - "elasticloadbalancing:AddTags"
              - "elasticloadbalancing:CreateListener"
              - "elasticloadbalancing:CreateLoadBalancer"
              - "elasticloadbalancing:CreateRule"
              - "elasticloadbalancing:CreateTargetGroup"
              - "elasticloadbalancing:DeleteListener"
              - "elasticloadbalancing:DeleteLoadBalancer"
              - "elasticloadbalancing:DeleteRule"
              - "elasticloadbalancing:DeleteTargetGroup"
              - "elasticloadbalancing:DeregisterTargets"
              - "elasticloadbalancing:DescribeListenerCertificates"
              - "elasticloadbalancing:DescribeListeners"
              - "elasticloadbalancing:DescribeLoadBalancers"
              - "elasticloadbalancing:DescribeLoadBalancerAttributes"
              - "elasticloadbalancing:DescribeRules"
              - "elasticloadbalancing:DescribeSSLPolicies"
              - "elasticloadbalancing:DescribeTags"
              - "elasticloadbalancing:DescribeTargetGroups"
              - "elasticloadbalancing:DescribeTargetGroupAttributes"
              - "elasticloadbalancing:DescribeTargetHealth"
              - "elasticloadbalancing:ModifyListener"
              - "elasticloadbalancing:ModifyLoadBalancerAttributes"
              - "elasticloadbalancing:ModifyRule"
              - "elasticloadbalancing:ModifyTargetGroup"
              - "elasticloadbalancing:ModifyTargetGroupAttributes"
              - "elasticloadbalancing:RegisterTargets"
              - "elasticloadbalancing:RemoveListenerCertificates"
              - "elasticloadbalancing:RemoveTags"
              - "elasticloadbalancing:SetIpAddressType"
              - "elasticloadbalancing:SetSecurityGroups"
              - "elasticloadbalancing:SetSubnets"
              - "elasticloadbalancing:SetWebACL"
            Resource: "*"
          -
            Effect: "Allow"
            Action:
              - "iam:CreateServiceLinkedRole"
              - "iam:GetServerCertificate"
              - "iam:ListServerCertificates"
            Resource: "*"
          -
            Effect: "Allow"
            Action:
              - "cognito-idp:DescribeUserPoolClient"
            Resource: "*"
          -
            Effect: "Allow"
            Action:
              - "waf-regional:GetWebACLForResource"
              - "waf-regional:GetWebACL"
              - "waf-regional:AssociateWebACL"
              - "waf-regional:DisassociateWebACL"
            Resource: "*"
          -
            Effect: "Allow"
            Action:
              - "tag:GetResources"
              - "tag:TagResources"
            Resource: "*"
          -
            Effect: "Allow"
            Action:
              - "waf:GetWebACL"
            Resource: "*"

使用此控制器的 v1.1.8 版時,我遇到了類似的錯誤(不完全相同):

kubebuilder/控制器 "msg"="協調器
error"="失敗為負載均衡器獲取 WAFv2 webACL arn:aws:elasticloadbalancing:...: AccessDeniedException: User: arn:aws:sts:::assumed-role/eks-node-group-role/ 未被授權執行: wafv2:GetWebACLForResource 在資源上:arn:aws:wafv2:us-east-2::regional/webacl/*\\n\\tstatus code: 400, request id: ..."
"controller"="alb-ingress-controller" "request"={"Namespace":"default","Name":"aws-alb-ingress"}

我會添加它,因為我認為它可以幫助那些在相同錯誤消息下進行搜索的人。

上述錯誤的原因是該控制器的v1.1.7版本需要節點組角色的*PolicyALBIngress策略中的新 IAM 權限

(!) 請注意,即使沒有使用 wafv2 注釋,也需要新的 IAM 權限。

解決方案1

wafv2的部分添加到策略中:

{
  "Effect": "Allow",
  "Action": [
    "wafv2:GetWebACL",
    "wafv2:GetWebACLForResource",
    "wafv2:AssociateWebACL",
    "wafv2:DisassociateWebACL"
  ],
  "Resource": "*"
}

解決方案2

WAFV2 支持可以通過這里提到的控制器標志禁用。

A) 如果您通過 kubectl 安裝它,請將- --feature-gates=waf=falsespec -> containers -> args部分。

B) 如果通過 helm 安裝,請在 helm upgrade 命令中添加--set extraArgs."feature-gates"='waf=false'


請注意,此要求已在 eksctl工具中更新(也可在此處查看)。


補充參考

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM