0

Let's look at the following configuration:

We have a Kubernetes Deployment which runs some application. We have 2 such Deployments, each running a different version of the application. Also, we have a Kubernetes Service that routes traffic to these deployments.

Additionally, we have the following VirtualService:

hosts:
- my-svc.default.svc.cluster.local
http:
- route:
  - destination:
      host: my-svc.default.svc.cluster.local
      subset: v2
    weight: 20
  - destination:
      host: my-svc-default.svc.cluster.local  
      subset: v1
    weight: 80

Additionally, we have a DestinationRule for the service:

host: my-svc.default.svc.cluster.local
subsets:
 - name: v1
   labels:
     version: v1
 - name: v2
   labels:
     version: v2

Now if I'll run some pod (call it a test pod) inside the cluster and try to access my-svc, what will happen? The Envoy proxy in the test pod will capture that traffic, apply the VirtualService and DestinatonRule configurations on it, and route the traffic accordingly.

Now what if I'll create another Deployment and Service - or you know what, just a Service - called mock. Now I'll change the hosts field in the VirtualService as such:

hosts:
- mock.default.svc.cluster.local
http:
...

In this case, what will happen when we address the mock service from the test pod? Reminder: there is nothing behind the mock service! The same will happen. The Envoy proxy in the test pod will capture the traffic and say: "oh, it's destined to mock.default.svc.cluster.local, so I need to apply the rules in the VirtualService on it." and then it will route it to my-svc.

So my question/wonder is, basically you can configure the hosts field in the VirtualService without actually having anything behind it?

YoavKlein
  • 2,005
  • 9
  • 38
  • Yes this can be done if you want to reserve FQDN(Fully Qualified Domain Name) for your service as per the architecture requirements. However, if you hit this host, since it doesn't have any backend configured you will receive errors. – Kranthiveer Dontineni Apr 20 '23 at 11:53

0 Answers0