首页 > 解决方案 > Ingress with subdomains

问题描述

I use Google Cloud for deploy company app.

The goal: every branch deployed on some subdomain(example.com): task-123.example.com, etc.

I copy Cloud DNS namespace to the domain registrar. I pass the static IP address(via kubernetes.io/ingress.global-static-ip-name: "test-static-ip") for Ingress and pass it to domain registrar to A record. But I can't understand how to make subdomain works.

Every branch creates Ingress with static IP, but with different URLs for the host.

I made CNAME *.example.com which refers to example.com, but its not works.

Help me, please. Sorry for my English.

标签: google-app-enginekubernetesgoogle-kubernetes-enginekubernetes-ingress

解决方案


You want *.example.com to point to the ingress controller so branch1.example.com and branch2.example.com will both hit the ingress controller. This is achieved with wildcard DNS.

Each branch in your scenario should have its own routing rule (ingress resource) with a host section defined for its specific branch. The ingress controller is updated when a new ingress resource is created and its routing rules then reflect the additional rule. So creating a new branch with a new ingress resource for that host will tell the ingress controller to route traffic for that specific host to a Service specific to that branch. (Or you can define all the branch rules in one go with a fanout ingress - see ingress-nginx - create one ingress per host? Or combine many hosts into one ingress and reload? )

That's 'how it works'. I'm not sure if that is your question though? It's hard to diagnose the problem you're having. Presumably you have an Ingress, a Service and a Deployment? To help with that I think you'd need to post those and explain (either as an update or a separate question) what behaviour you see (a 404 maybe)?


推荐阅读