【问题标题】:AWS ALB Ingress Controller with IRSA authorization error带有 IRSA 授权错误的 AWS ALB 入口控制器
【发布时间】:2019-12-05 11:28:19
【问题描述】:

我正在尝试使用 IRSA 方法而不是 kube2iam 设置 AWS ALB 入口控制器。但是由于缺少一些文档,所以我走到了死胡同。

到目前为止我做了什么:

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

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

  • 使用the template创建了正确的策略

  • 创建了将由 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

  • 使用 this template 部署了 AWS 入口控制器。注意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 方法的全部目的,对吗?

我希望 Ingress Controller pod 需要适当的权限(通过使用服务帐户)来创建 ALB 而不是节点。我在这里遗漏了什么吗?

【问题讨论】:

    标签: amazon-web-services kubernetes kubernetes-ingress amazon-eks


    【解决方案1】:

    在使用此控制器的 v1.1.8 版本时,我遇到了类似的错误(不完全相同):

    kubebuilder/controller "msg"="Reconciler
    错误"="获取失败 负载均衡器的 WAFv2 webACL arn:aws:elasticloadbalancing:...: AccessDeniedException:用户: arn:aws:sts:::假定角色/eks-node-group-role/ 无权执行: wafv2:GetWebACLForResource 对资源: arn:aws:wafv2:us-east-2::regional/webacl/*\n\tstatus 代码: 400,请求 ID:..."
    “控制器”=“alb-入口控制器” "request"={"Namespace":"default","Name":"aws-alb-ingress"}

    我会添加它,因为我认为它可以帮助在相同错误消息下搜索的人。

    上述错误的原因是节点组角色 *PolicyALBIngress policy中此控制器needs new IAM permissions的版本v1.1.7

    (!) 请注意,即使不使用 wafv2 注释,也需要新的 IAM 权限。

    解决方案 1

    在策略中添加wafv2允许操作部分:

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

    解决方案 2

    可以通过控制器标志禁用 WAFV2 支持,如 here 所述。

    A) 如果您通过 kubectl 安装它,请将 - --feature-gates=waf=false 添加到 spec -> containers -> args 部分。

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


    请注意,此要求已成为 updated in the eksctl 工具(也可在 here 中查看)。


    附加reference

    【讨论】:

      【解决方案2】:

      所以,万一有人遇到同样的问题。

      解决方案是,在创建 rbac 角色时,从 rbac-role.yaml(提供 here)中注释掉创建服务帐户的最后一部分。

      由于我们已经使用 eksctl 创建了一个服务帐户并附加了 aws 策略,因此我们也可以将 rbac 权限附加到该服务帐户。然后这个服务账号就可以在 ingress controller pod 中正常使用来发挥它的魔力了。

      【讨论】:

        【解决方案3】:

        根据文档需要对 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: "*"
        
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2020-01-06
          • 2020-10-11
          • 2020-09-27
          • 2021-07-18
          • 1970-01-01
          • 2020-10-13
          • 1970-01-01
          相关资源
          最近更新 更多