How to create Kubernetes load balancer on aws

前端 未结 2 1692
名媛妹妹
名媛妹妹 2021-01-11 14:50

Kubernetes create a load balancer, for each service; automatically in GCE. How can I manage something similar on AWS?

Kubernetes service basically use the kubeproxy

2条回答
  •  猫巷女王i
    2021-01-11 15:06

    Minimal example:

    kind: Service
    apiVersion: v1
    metadata:
      name: my-service
    spec:
      type: LoadBalancer
      selector:
        app: MyApp
      ports:
      - protocol: TCP
        port: 80
        targetPort: 9376
    

    The relevant docs:

    • Create an External Load Balancer
    • Type LoadBalancer

    As of writing the best way to learn about all the service.beta.kubernetes.io annotations is to read the source code:

    • cloudprovider/providers/aws/aws.go

    For the controller to be able to manage the ELB it will need permissions set in the master instances IAM Role, e.g.:

    ...
    {
      "Action": "elasticloadbalancing:*",
      "Resource": "*",
      "Effect": "Allow"
    },
    {
      "Action": [
        "ecr:GetAuthorizationToken",
        "ecr:BatchCheckLayerAvailability",
        "ecr:GetDownloadUrlForLayer",
        "ecr:GetRepositoryPolicy",
        "ecr:DescribeRepositories",
        "ecr:ListImages",
        "ecr:BatchGetImage"
      ],
      "Resource": "*",
      "Effect": "Allow"
    },
    ...
    

    The cloud provider should be set with --cloud-provider=aws on kube-apiserver.

提交回复
热议问题