Shadowing real DNS names with a Kubernetes Service - for running a local subset for development

8/22/2018

I'm trying to set up a Kubernetes cluster containing a subset of our CI environment. Specifically I'm trying to run some combination of:

  • Database
  • BL
  • Staff UI
  • Staff UI Aggregator (There are a number of Staff UI Services for different components, and this pulls them together)
  • Config UI
  • Config UI Aggregator (There are a number of Config UI Services for different components, and this pulls them together)

What I'm wanting to achieve is:

  • If the BL service is running, Staff UI and Config UI talk to it
  • If the BL service is not running, Staff UI and Config UI talk to the version in our CI environment.

What I can't do is change the DNS names that Staff UI and Config UI use to resolve the BL - and that DNS name is fully qualified.

So, what I'm wanting to do is:

  • If BL is running, then the Kubernetes DNS resolves "bl.dev.company.com" to the BL Service
  • If BL is not running then the Kubernetes DNS doesn't resolve "bl.dev.company.com" and it goes to the CI environment version instead.

So far, I've failed to get either of those steps to work :(

I'm not listing the things I've tried deliberately because there's a fair chance I've tried the correct solution, not fully understood it, done it badly and thus it's not worked.

This is using Kubernetes 1.10.3, running as part of "Docker for Desktop Edge Channel" on macOS.

I can get this to work using docker-compose, via links, but it's not as flexible. Additionally the longer term goal is to move the CI environment to a Kubernetes cluster of its own, so this would be a step towards that.

-- Graham
docker
kubectl
kubernetes

1 Answer

8/24/2018

You could add host records to the StaffUI/ConfigUI pods /etc/hosts with the DNS name you need and the ClusterIP of the intermediate Kubernetes Service.

Then you can update the service configuration during the BL deployment by changing the Service selector or setting ExternalName/externalIP.

-- VAS
Source: StackOverflow