1

I'm having hard times with the application's release process. The app is being developed in .NET Core and uses 'appsettings.json' that holds connection string to a database. The app should be deployed to Kubernetes cluster in Azure. We have a build and release processes in Azure DevOps so the process is automated, although the problem belongs to a necessity to deploy the same to multiple environments (DEV/QA/UAT) and every env is using its own database. When we build Docker image, the 'appsettings.json' that holds a connection string is being baked-in to the image. The next step pushes the image to a container repository which Release process then uses to deploy the image to a cluster (the steps are classics).

Replacing or putting the connection parameters into the variables on the build step is not a big deal. However, this is a Release process that controls the deployment to multiple environments. I don't see how I can substitute the connection string to a database in the Release pipeline... or better to say, how to deploy to three different environments with database connection string properly set for each of them.

Please suggest how it can be achieved. The only option I came up with is having three separate build pipelines for every env which doesn't look pretty. The entire idea behind Release is that you can manage the approval process before rolling out the changes to the next environment.

John Bull
  • 933
  • 1
  • 12
  • 20
  • 3
    That sounds like you’re looking for a ConfigMap to hold the JSON settings file. Don’t include it in the image (or have a path to generate it from environment variables). – David Maze Dec 07 '18 at 17:50
  • 1
    What about replacing image `ENTRYPOINT`? You can create a shell script where you take connection string from environment or arguments (not build args, but those args which you define as container args in deployment k8s resource), write it to config file inside image, and then start you database. It'll read from newly edited file. I'm doing similar thing for applications which read config from file. – Egor Stambakio Dec 07 '18 at 18:21
  • Sorry Egor, didn't get the comment about ENTRYPOINT – John Bull Dec 07 '18 at 18:44
  • 2
    @JohnBull look at this bin: https://pastebin.com/wU2bbuEh - example with `helm` templating. – Egor Stambakio Dec 07 '18 at 18:57

1 Answers1

2

Decided to proceed with Kubernetes secrets. Found a good article around this issue here: https://strive2code.net/post/2018/12/07/devops-friday-build-a-deployment-pipeline-using-k8s-secrets

John Bull
  • 933
  • 1
  • 12
  • 20