1

我正在尝试使用 alb Ingress 控制器在 eks 上实现一个简单的“hello world”。

我的目标是..

  1. 创建集群
  2. 部署 Ingress 以使用 ELB 访问

做了以下事情

  1. 创建 EKS 集群
  2. 添加了“alb 入口控制器”
C:\workspace\eks>kubectl get po -n kube-system
NAME                                      READY   STATUS    RESTARTS   AGE
alb-ingress-controller-5f96d7df77-mdrw2   1/1     Running   0          4m1s
  1. 创建的应用程序如下
apiVersion: apps/v1
kind: Deployment
metadata:
  name: "2048-deployment"
  namespace: "2048-game"
  labels:
    app: "2048"
spec:
  replicas: 1
  selector:
    matchLabels:
      app: "2048"
  template:
    metadata:
      labels:
        app: "2048"
    spec:
      containers:
      - image: alexwhen/docker-2048
        imagePullPolicy: Always
        name: "2048"
        ports:
        - containerPort: 80

  1. 服务如下
apiVersion: v1
kind: Service
metadata:
  name: "service-2048"
  namespace: "2048-game"
spec:
  ports:
    - port: 80
      targetPort: 80
      protocol: TCP
  type: NodePort
  selector:
    app: "2048"


  1. 入口控制器如下
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: "2048-ingress"
  namespace: "2048-game"
  annotations:
    kubernetes.io/ingress.class: alb
    alb.ingress.kubernetes.io/scheme: internet-facing
  labels:
    app: 2048-ingress
spec:
  rules:
    - http:
        paths:
          - path: /*
            backend:
              serviceName: "service-2048"
              servicePort: 80

  1. 输出如下,没有得到主机地址作为ELB。并且无法从外部访问
C:\sample>kubectl get ingress/2048-ingress -n 2048-game
NAME           HOSTS   ADDRESS   PORTS   AGE
2048-ingress   *                 80      71s

更新 :

在 alb-ingress-controller-5f96d7df77-mdrw2 日志中发现以下错误。无法找到如何更改

 kubebuilder/controller "msg"="Reconciler error" "error"="failed to build LoadBalancer configuration due to failed to resolve 2 qualified subnet for ALB. Subnets must contains these tags: 'kubernetes.io/cluster/ascluster': ['shared' or 'owned'] and 'kubernetes.io/role/elb': ['' or '1']. See https://kubernetes-sigs.github.io/aws-alb-ingress-controller/guide/controller/config/#subnet-auto-discovery for more details. Resolved qualified subnets: '[]'"  "controller"="alb-ingress-controller" "request"={"Namespace":"default","Name":"ingress-default-dev"}
4

2 回答 2

2

如果您的子网没有用kubernetes.io/cluster/<cluster-name>=sharedetc 标记...您也可以尝试在入口文件注释中传递子网,如下所示

alb.ingress.kubernetes.io/subnets: subnet-xxxxxx, subnet-xxxxxx
于 2020-08-31T19:52:04.157 回答
2

eks 节点所在的子网应使用以下标记

https://docs.aws.amazon.com/eks/latest/userguide/network_reqs.html#vpc-subnet-tagging

于 2020-08-26T15:41:57.120 回答