简体   繁体   中英

How to add new subdomain to existing kubernetes cluster

totally beginner with kubernetes and i believe this should be a simple question for any kubernetes expert

to put a long story short: i have inherited a kubernetes cluster after my CTO quit his job. My goal is to make a new app accessible at a new subdomain for our company

context:

  1. the app in question has a service definition and deployment definition that have been applied to the cluster (ex: kubectl apply -f new-service.yaml)
  2. the pod is running the app as far as i can tell (shows up in my kubectl get pods output as ready and running)
  3. and i can ping that pod from other pods in the cluster

my problem:

i do not know how to make the ingress router "work"... i have updated my ingress yaml configuration by adding the host and service name, and I have used the command kubectl apply -f ingress.yaml to update the ingress configuration. but the new host is unreachable. I have even gone so far as to add a new host (a subdomain of our company) with a serviceName of an already functioning service that is accessible on a different subdomain -- hoping that i would see the already working app on my new subdomain. however, this new subdomain does not direct me to the app, chrome gives me the following output:

server IP address could not be found.

ERR_NAME_NOT_RESOLVED

is there something i'm missing here? shouldn't i be able to add a new host to the bottom of my ingress yaml and give it a serviceName of an already working service? and then be able to access that already running app from a different subdomain?

any help at all would be so greatly appreciated -- this is the last step for me in a long journey! here is a snip of what i added to the ingress yaml -- this matches the other entry exactly except the hostname is www3 and not www

- host: www3.changed-for-privacy.com
      http:
        paths:
          - path: /*
            backend:
              serviceName: changed-for-privacy-www
              servicePort: 80

I believe what you are doing on the side of Kubernetes is perfectly okay. A request for a certain domain, if/when received in your Ingress is correctly being routed to the backend service.

What is noteworthy is the error you show from Chrome . This means the address resolution problem is on your client side, not the cluster. You need to make sure that you setup local DNS resolution on your laptop so that your www3.changed-for-privacy.com will resolve to a knownIPAddress . For example, if you've set your Ingress externalIP to 192.168.10.10 . Then you have to add an entry to your /etc/hosts/ file (if you're on linux) as follows:

www3.changed-for-privacy.com 192.168.10.10

This will ensure that requests for your domain from the browser land on the Ingress external IP (which should be routable of course) and you might find out that your cluster is working fine!

As a more permanent solution, you will of course require that your application domain is registered, so that a public DNS record for it will exist, which will map to the public externalIP of your Ingress object and you will not have this problem.

Question has been resolved!

Fortunately this had nothing to do with kubernetes! My domain is pointing to cloudflare nameservers... which I did not realize at the time. I assumed the domain was pointing to AWS nameservers. I was looking in Route 53 in AWS and was dumbfounded to see that adding a new CNAME record caused DNS name resolution errors when trying to hit the domain in the browser.

Adding the new A records in cloudflare solved my problem

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