lagom configuration override

5/22/2018

Is there any way to deploy lagom projects on kubernetes in different environments (ie. dev,stage,prod) such that I can use one image with multiple configuration overrides?

For example, let's say I have an environment variable, foo=bar-{{env}}. I want to build and publish one image and override configurations so that in dev foo=bar-dev and in prod foo=bar-prod.

Currently, my understanding is that the application.conf is tied to the image and cannot be overridden. If this is correct, is there a way to work around this so that I do not need to create multiple images, one for each environment?

-- bgao3
docker
kubernetes
lagom

2 Answers

6/3/2018

Alternatively, you can set typesafe config system property variable to override application.conf file

  • application.conf: default conf file use in development

    foo: bar-dev
  • application.prod.conf:

    include "application.conf"
    foo: bar-prod

Set dockerfile system variable:

 ENTRYPOINT java -Dconfig.resource="$CONFIG_FILE"

In kubernetes yml

 env:
     - name: CONFIG_FILE
       value: "application.prod.conf"
-- sepulrator
Source: StackOverflow

5/23/2018

You can do this in a few ways:

Static:

You can create 3 deployments in 3 namespaces and add the env variable to each deployment. You can manage these variables manually for each deployment:

apiVersion: v1
kind: Pod
metadata:
  namespace: dev
  name: envar-demo
  labels:
    purpose: demonstrate-envars
spec:
  containers:
  - name: java-demo-container
    image: my-super-java-app
    env:
    - name: foo
      value: "bar-dev"
    - name: JAVA_HOME
      value: "/opt/java/jdk1.7.0_05/bin/java"

Helm:

You can make helm chart and use 3 files with variables to deploy your application. To develop charts, you could read the official documentation or find some examples in official Kubernetes repo

-- Nick Rak
Source: StackOverflow