简体   繁体   中英

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

I am currently deploying Apache Airflow on K8s (on EKS). I have managed to successfully deploy an Ingress Controller (usedAWS 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 usingstable 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.

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.

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