I am new to openshift and kubernetes.

I have a secret in openshift and made it avaliable to the pod as an environment variable.

What is the best practice to get that value into a properies file (java) before the containers service starts?

Is there a better way than using sed on the propertyfile before startup?

1 Answer 1


There are two ways you can manage this :

  • Like you said, make the secret data available trough environnement variables and run sed or envsubst on the file before startup.
  • Or, you could create a secret that would hold your whole PropertyFile content, and then use that secret trough a volume to mount its content as a file in your Pod (see this example in the documentation for more informations). But since you only have one secret data in your PropertyFile, this might be overkill, depending on your setup.

I wouldn't know what option is the best in your situation, but these the one I would suggest.

  • I have worked with linux for 20 years, how have I never heard of envsubst before.
    – Nifle
    Dec 27, 2023 at 15:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.