I am new to this Rancher/kubernetes. Wanted to store DB connection string from appsetting-UAT.json file to Rancher secrets and wanted to fetch at runtime in UAT environment.Please find below code:
Microsoft.Extension.Configuration.UserSecrets
Added the below code where we generally fetch DB connection from Appsettings.json
file
var config= new ConfigurationBuilder() .SetBasePath(StartupHostEnvironment.ContentBasePath) .AddJsonFile("appsetting.json",optional:true, reloadOnChange: true) .AddJsonFile(
quot;appsetting.{StartupHostEnvironment.EnvironmentName}.json",optional:true) .AddUserSecrets<myBusinessApp>() .AddEnvironmentVariables() .Build();_myAppsettings=config.GetSection(_Service.MyAppService).Get<_Service>();
Changes in Deployment.yaml
file under UAT environment section:
Also added the secret key in Rancher, under secret->selecting opaque(key/value pair).
but I'm unable to fetch the secrets from Rancher.
Any suggestion will be helpful.