Multiple default URL values in Rails?

12/17/2019

I'm in the process of migrating a Rails application to Kubernetes, and as a part of that I want to set up readiness and liveliness probes.

However, we use some convoluted logic to set our app URL (multiple environments, clouds, and clients), so we pass as an environment variable that's set elsewhere. I could template that inside our Helm chart, but with the sheer variance in our URLs, it just won't be very practical. I'm hoping to use an easier solution, namely to set a second URL to be used purely for an internal healthcheck.

This is what I have now:

  config.action_controller.asset_host = ENV['APPLICATION_URL']
  config.action_controller.default_url_options = { host: ENV['APPLICATION_URL'] }

What I'm hoping to be able to do:

  config.action_controller.asset_host = [    ENV['APPLICATION_URL'],
    kube-healthcheck.ourdomain.local
  ]
  config.action_controller.default_url_options = { 
    host: [
      ENV['APPLICATION_URL'],
      kube-healthcheck.ourdomain.local
    ]
  }

However all the googling I've done only shows how to set it for multiple subdomains, such as http://server%d.ourdomain.com where you have multiple servers like server1, server2, etc.

Any suggestions?

Edit: Running Kubernetes 1.14 in EKS, though eventually we plan to make this multi-cloud (Azure AKS and Google GKE).

-- maplebird
kubernetes
ruby-on-rails

0 Answers