使用 AWS NLB 配置 Istio Ingress

描述如何在 AWS 上使用网络负载均衡器配置 Istio Ingress。

Apr 20, 2018 | By Julien SENON

本文提供了使用 AWS 网络负载均衡器配置 Ingress Istio 的说明。

可以使用网络负载均衡器 (NLB) 来代替传统的负载均衡器。您可以查看不同的 AWS 负载均衡器 之间的比较以获取更多的解释。

先行条件

以下说明需要 Kubernetes 1.9.0 或更高版本 的集群。

IAM Policy

您需要在主角色上应用策略,以便能够配置网络负载均衡器。

  1. 在 AWS iam 控制台中,点击策略并单击“创建新策略”:

    {< image width=“80%” link="./createpolicystart.png" caption=“Create a new policy” >}}

  2. 选择 json

    {

    Select json
    Select json

  3. 拷贝以下内容:

    {
        "Version": "2012-10-17",
        "Statement": [
            {
                "Sid": "kopsK8sNLBMasterPermsRestrictive",
                "Effect": "Allow",
                "Action": [
                    "ec2:DescribeVpcs",
                    "elasticloadbalancing:AddTags",
                    "elasticloadbalancing:CreateListener",
                    "elasticloadbalancing:CreateTargetGroup",
                    "elasticloadbalancing:DeleteListener",
                    "elasticloadbalancing:DeleteTargetGroup",
                    "elasticloadbalancing:DescribeListeners",
                    "elasticloadbalancing:DescribeLoadBalancerPolicies",
                    "elasticloadbalancing:DescribeTargetGroups",
                    "elasticloadbalancing:DescribeTargetHealth",
                    "elasticloadbalancing:ModifyListener",
                    "elasticloadbalancing:ModifyTargetGroup",
                    "elasticloadbalancing:RegisterTargets",
                    "elasticloadbalancing:SetLoadBalancerPoliciesOfListener"
                ],
                "Resource": [
                    "*"
                ]
            },
            {
                "Effect": "Allow",
                "Action": [
                    "ec2:DescribeVpcs",
                    "ec2:DescribeRegions"
                ],
                "Resource": "*"
            }
        ]
    }
    
  4. 点击审核策略,填写所有字段,接着点击创建策略:

    Validate policy
    Validate policy
  5. 点击角色,选择您的主角色节点,然后点击附加策略:

    Attach policy
    Attach policy
  6. 现在,您的策略就已经附加到了主节点。

重写 Istio Ingress 服务

要使用 AWS nlb 负载均衡器,必须在 Istio 安装中添加一个 AWS 特定的注释。 这些说明解释了如何添加注释。

将其保存为文件 override.yaml: 您需要使用以下内容来重写 istio-ingress 服务:

gateways:
  istio-ingressgateway:
    serviceAnnotations:
      service.beta.kubernetes.io/aws-load-balancer-type: "nlb"

使用 Helm 生成清单:

$ helm template install/kubernetes/helm/istio --namespace istio -f override.yaml > $HOME/istio.yaml

Share this blog on social!