Rails Configuration in Kubernetes

  • What’s the best way to build an image? Every developer for themselves? A base image shared with the team?
  • Where to put the code? In the container or mounted as a volume? (BTW, is it only me, or do you have to google Docker Volume syntax every time?)
  • Issues with Node.js and compiling assets, webpacker, and running webpacker development server in containers.
  • Docker Compose failing to shutdown containers randomly and consuming four times more resources compared to running Rails web and Sidekiq outside containers.
  • Have a private gem? Welcome to the nightmare of SSH key sharing inside of a container image.
  • Load configuration from YAML or single-value files and present them to the application in a `Settings.foo.bar` syntax.
  • Verify configuration against strongly-typed validation before the application starts.
  • Support environment variable overrides (very useful in containerized environments)
  • Support JSON as a native data type inside YAML.
  • Support ERB with its YAML configuration files.
if %w(development test).include?($environment)     Konfig.configuration.mode = :yaml     Konfig.configuration.workdir = File.join($rails_root, 'config', 'settings') 
# set the konfig log level to WARN
konfig_logger = ActiveSupport::Logger.new(STDOUT) konfig_logger.level = ::Logger::WARN Konfig.configuration.logger = konfig_logger else
Konfig.configuration.mode = :directory # this is mounted by Kubernetes from ConfigMap or Secrets Konfig.configuration.workdir = "/app/config/settings/configuration" end
Konfig.configuration.schema do
required(:foo).schema do required(:bar).filled(:string) required(:buzz).filled(:string) required(:fuzz).filled(:boolean) end end
puts Settings.foo.bar



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Cloud 66

Cloud 66

DevOps-as-a-Service to help developers build, deploy and maintain apps on any Cloud. Sign-up for a free trial by visting: www.cloud66.com