Best practice for configuration of each environment?

Hi,
we have multiple, more than 10 services running on Kubernates.
And for now have three environments(development, staging, production).
So probably we need three application.conf file, and currently one is in the project for the development.
Maybe we can make three files like application-dev.conf and application-prod.conf and let k8s use those file explicitly.
My question is what is the best practice for k8s environment?
Any advice or documentation will be welcomed.
Thank you.

1 Like

Hi,

Your goal should be to have docker image transparent to k8s environment. One image version for any k8s environment.

To achieve this k8s environment specific configuration should not be configured in application.conf that is bundled in a docker image.

You could configure it using environment variables specified in k8s deployment resource that will be, in this case, specific per k8s environment.

Br,
Alan

2 Likes

@aklikic is right absolutely.
But we use k8s ConfigMap for environment specific config. It’s very useful, IMHO.

  1. ConfigMap
apiVersion: v1
data:
conf: |
 foo.bar = "value"
 play.http.secret.key = "play-http-secret-key-test"
kind: ConfigMap
metadata:
name: service-config
  1. Add ConfigMap data to a Volume
    For example volume /opt/docker/conf/config/application.conf
  2. Add include to base configuration file
include file("/opt/docker/conf/config/application.conf")
  1. Profit! :smile:
3 Likes

Hi Alan, thank you for your reply and sharing your thoughts!

Hi Sergey, thank you for sharing your experience.
Currently we are digging into what you gave to me, and I have couple of more questions. If you can let us know more, really appreciate!
So far as I understood,
-make xxx.conf file based on configMap like populate-a-volume-with-data-stored-in-a-configmap using volumeMounts.mountPath
-add include of xxx.conf file to the base configuration file(application.conf)
My question is,

  1. Is my understanding correct and proper way to do?
  2. for example if we have our application.conf file in projectFolder/src/main/resources/application.conf and we want to add xxx.conf file to same resources folder, mountPath should be
    mountPath: /src/main/resources/xxx.conf right?
    image
  3. is there some kind of naming convention for the conf file of Lagom?
    Any advice will be welcome!

Jason

Hi, Jason!

  1. Yep :wink:
  2. I’m not sure that it is possible, because resource files adding to jar. You can’t mount ConfigMap as one file in the jar.
  3. No. But usually adding semantic of the environment to the name of the file. For example application-prod.conf or just production.conf. It’s your choice :wink:

Best regards,
Sergey

1 Like

Really thank you Sergey, it was really helpful!!
Hope you have a great day!

Jason Lee