<p>I'm currently working on setting up a CI/CD pipeline to my client's new Kubernetes clusters that they host on Harbor using Helm and Azure DevOps Server, and I'm a bit stuck on how to deal with application variables (appsettings in .NET Core) in a streamlined way. Currently those variables are stored in DevOps as Release Variables, and some of the Prod variables are managed by another organization.</p>
<p>My thinking has been that I want separate Build and Deploy pipes, with the Build being responsible for restoring, building, triggering unit tests, and finally pushing a Docker image to the on-prem registry. Then, have multiple Deploy pipelines representing the various environments (Dev, Test, Stage, Prod) and applications that may want to use that Docker image, utilizing their own configuration.</p>
<p>However, I haven't been able to find a way that allows me to inject the variables from the release pipeline into the dockerized application on the release steps, since by then what I have is not my raw application but rather the Docker image of it. I've previously used ConfigMaps to resolve this, but since I can't have files locally to represent the Prod environment, I would need some way to override variables, or generate a ConfigMap, from Azure Devops' release variables.</p>
<p>I somehow feel like this must be a common scenario, and yet most solutions I find are either related to maintaining environment-oriented configmaps or values files in your application's repo, or using functions seemingly unique to Azure Cloud.</p>
<p>One solution would be to move the <code>docker build</code>/<code>push</code> step into the release pipelines, and injecting variables into the application before being dockerized. However this feels like a hack that will just result in a myriad of Docker images of the same application but with a tweaked appsettings file, that somehow will have to be versioned across multiple environments.</p>

Julius Mikkelä
<p>You could try a way to handle this through <a href="https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/deploy/kubernetes-manifest?view=azure-devops" rel="nofollow noreferrer">Kubernetes manifest task</a>.</p>
<blockquote>
<p>Use a Kubernetes manifest task in a build or release pipeline to bake
and deploy manifests to Kubernetes clusters.</p>
</blockquote>
<p>If your builds and deployments all run in Azure Pipelines so you do have a previous layer where we can do these replacements before applying the manifests to the cluster.</p>
<p>Variables can be defined at several scope levels where the more immediate levels will override the farthest.</p>
<p>It's also able to apply the same manifest to two environments (staging and production) but with different settings</p>
<p>You could also take a look at below blogs：</p>
<ul>
<li><a href="https://medium.com/@katlimruiz/how-to-inject-variables-in-kubernetes-manifest-with-azure-pipelines-e598755be9b" rel="nofollow noreferrer">How to inject variables in Kubernetes manifest with Azure
Pipelines?</a></li>
<li><a href="https://jfarrell.net/2018/12/22/deploying-to-kubernetes-with-azure-devops-a-first-pass/" rel="nofollow noreferrer">Deploying to Kubernetes with Azure DevOps: A first pass</a></li>
</ul>
