简体   繁体   中英

Set ALB's DNS name for aws-alb-ingress-controller

I am implementing an ingress controller with AWS and following this tutorial.

When creating an ingress as shown here , a host name should be given.

spec:
  rules:
  - host: echoserver.example.com #How to let kubernate assign ALB's DNS name and not give our own DNS name.
    http:
      paths:
      - path: /
        backend:
          serviceName: echoserver
          servicePort: 80

But I want to give the ALB's generated DNS name as I don't have my own DNS name. Is there any way to do it ? I tried ommiting the host attribute. But when I describe the ingress as mentioned in my tutorial mentioned above (section 13) running

 kubectl describe ing -n echoserver echoserver  

The value of Address in the response of above command is empty, therefore no way to hit the ingress.

UPDATE :

I created a ALB (through the aws UI, and allowed to forward requests to a target group which is created as default) and set its DNS name to the host name(in simple letters) in ingress yaml file. But I can't see it works. I follow the steps mentioned in above above tutorial .

kubectl logs -n kube-system \
    $(kubectl get po -n kube-system | \
    egrep -o alb-ingress[a-zA-Z0-9-]+) | \
    egrep -o '\[ALB-INGRESS.*$'

When the above log command executed only the following output returned:

[ALB-INGRESS] [controller] [INFO]: Log level read as "", defaulting to INFO. To change, set LOG_LEVEL environment variable to WARN, ERROR, or DEBUG.
[ALB-INGRESS] [controller] [INFO]: Ingress class set to alb
[ALB-INGRESS] [controller] [INFO]: albNamePrefix undefined, defaulting to f0591ff6

As per step 12, when the log command executed,

kubectl logs -n kube-system \
    $(kubectl get po -n kube-system | \
    egrep -o alb-ingress[a-zA-Z0-9-]+) | \
    egrep -o '\[ALB-INGRESS.*$' | \
    grep 'echoserver\/echoserver'

there is no any logs.

Also, when following command executed:
kubectl describe ing -n echoserver echoserver
The response is:

Name:             echoserver
Namespace:        echoserver
Address:
Default backend:  default-http-backend:80 (172.17.0.4:8080)
Rules:
  Host                                                Path  Backends
  ----                                                ----  --------
  ingress-alb-3455057285.us-east-2.elb.amazonaws.com
                                                      /   echoserver:80 ()
Annotations:
Events:

Any idea please where things go wrong ?
I did not set any IAM roles here. If it is required, let me know how should I do it.

It's not possible to use ingresses like this, ingresses expect a DNS name as they need to be able to route traffic.

You can get around this by simply editing your hosts file for a bit of a hack:

my_fake_dns <ip_of_alb>

You might want to try using a Service of type LoadBalancer , which automatically generate an ELB (not an ALB) or an NLB for you.

It would be quite easy to create a shell script that does the following:

  1. Describe your AWS load balancer

    ELBv1

     aws elb describe-load-balancers --load-balancer-name my-load-balancer 

    ELBv2

     aws elbv2 describe-load-balancers --load-balancer-arns arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188 
  2. Filter LB DNS name from the step 1 output:

    ELBv1

     jq '.LoadBalancerDescriptions[].DNSName' 

    ELBv2

     jq '.LoadBalancers[].DNSName' 
  3. Insert results from the step 3 to your ingress yaml template file

  4. Apply resulting YAML file from the step 4 to your cluster.

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