How to connect to a Kubernetes service via hostname instead of address?

1/25/2021

I am currently deploying Apache Airflow on K8s (on EKS). I have managed to successfully deploy an Ingress Controller (used AWS Load Balancer Controller) and an ingress, and I can access the ingress through the internet. My objective is to be able to access the host and a path rather than the address.

In other words, right now to access the web-server I need to input an address like: internal-k8s-airflow-deployment-aws-region.elb.amazonaws.com. My goal is to access it using something like: meow.myimaginarywebsite.com/airflow.

What I have tried to do

I am using stable airflow Helm chart (not particularly looking for an answer referencing the chart), and I have modified the values for the web-server like:

web:
    ## annotations for the web Ingress
    annotations:
      kubernetes.io/ingress.class: "alb"
      alb.ingress.kubernetes.io/target-type: "ip"

    labels: { }

    ## the path for the web Ingress
    path: "/airflow"

    ## the hostname for the web Ingress
    host: "meow.myimaginarywebsite.com"
    livenessPath: ""

    tls:
      enabled: false

Running kubectl get ingress -n dp-airflow I get:

NAME             CLASS    HOSTS                      ADDRESS                                                                               PORTS   AGE
airflow-web      <none>   meow.myimaginarywebsite.com   internal-k8s-airflow-deployment-aws-region.elb.amazonaws.com   80      141m

I have tried curling meow.myimaginarywebsite.com or meow.myimaginarywebsite.com/airflow but got: Could not resolve host: meow.myimaginarywebsite.com/airflow

For more context, It's worth mentioning that meow.myimaginarywebsite.com is a hosted zone. For example, running aws route53 list-hosted-zones I get (I also verified that these hosted zones are associated with the VPC I am deploying EKS on):

{
    "HostedZones": [
        {
            "Id": "/hostedzone/ABCEEIAMAREDACTEDIDEEE",
            "Name": "meow.myimaginarywebsite.com.",
            "CallerReference": "terraform-2012012012012",
            "Config": {
                "Comment": "Managed by Terraform",
                "PrivateZone": true
            },
            "ResourceRecordSetCount": 3
        }
    ]
}

It's worth mentioning that I am new to this task, so I would benefit the most from a conceptual understanding of what I need to do or guidance to be on the right track. To re-state my objective, I basically want to be able to put something like meow.myimaginarywebsite.com/airflow into the browser and then be able to connect to the webserver, rather than something like: internal-k8s-airflow-deployment-aws-region.elb.amazonaws.com. I am also happy to provide further details.

-- alt-f4
amazon-web-services
kubernetes

1 Answer

1/25/2021

First of all, you need to add A or ALIAS record to Route 53 zone like that:

meow.myimaginarywebsite.com --> internal-k8s-airflow-deployment-aws-region.elb.amazonaws.com

After that at least you should be fine with DNS resolution.

-- Vasili Angapov
Source: StackOverflow