简体   繁体   中英

EKS cluster is not showing my an IP on the Ingress controller

I am new to K8S so please be gentle. I have a test hello world Flask app and I would like to deploy it on EKS. I am using the AWS load Balancer Controller Addon using the link below. At the end when I check the deployment it shows up without any issues as the link describes. https://docs.aws.amazon.com/eks/latest/userguide/aws-load-balancer-controller.html

When I apply the three files below they all apply correctly and I see the pods up, but on the ingress I dont see an external IP address and cant access my Flask app.

My goal is to have AWS create a dummy DNS name and then I can point my public DNS name to it as an CNAM entry. Also the Ingress should be in port 80 and then that should forward to port 5000 for the Flask app internally.

What am I missing? Could someone please point me in the right direction?

ingress.yaml

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: "flask-test-ingress"
  annotations:
    kubernetes.io/ingress.class: alb
    alb.ingress.kubernetes.io/scheme: internet-facing
    alb.ingress.kubernetes.io/target-type: ip
    alb.ingress.kubernetes.io/listen-ports: '[{"HTTP": 80}, {"HTTPS": 443}]'
  labels:
    app: hello-world
spec:
  rules:
    - host: testing.somesite.com
      http:
        paths:
            - path: /
              pathType: Prefix
              backend:
                service:
                  name: "hello-world-service"
                  port:
                    number: 80

deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: hello-world
spec:
  selector:
    matchLabels:
      app: hello-world
  replicas: 2
  template:
    metadata:
      labels:
        app: hello-world
    spec:
      containers:
      - name: hello-world
        image: gitlab.privaterepo.com:5050/jmartinez/flask_helloworld:v4
        ports:
        - containerPort: 5000
          protocol: TCP
      imagePullSecrets:
      - name: regcred

service.yaml

apiVersion: v1
kind: Service
metadata:
  name: hello-world-service
spec:
  selector:
    app: hello-world
  type: NodePort
  ports:
  - protocol: "TCP"
    port: 80
    targetPort: 5000
    nodePort: 30000

Finally got it working. When I realized that the ALB was not created automatically I researched and found the solution. I had to remove the ingress.class value from the annotations as well as remove the host. So now my ingress looks like the following. After deleting the old ingress and reapplying this one, I waited about 10 minutes and my hello world app is now running.

ingress.yaml

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: "flask-test-ingress"
  annotations:
    alb.ingress.kubernetes.io/scheme: internet-facing
    alb.ingress.kubernetes.io/target-type: ip
  labels:
    app: hello-world
spec:
  ingressClassName: alb
  rules:
    - http:
        paths:
            - path: /
              pathType: Prefix
              backend:
                service:
                  name: "hello-world-service"
                  port:
                    number: 80

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM