I have a kubernetes configuration in json format file which i want to deployed in kubernetes cluster using C# kubernetes clinet api.Below is my config data file.But i want to read this values from appsettings.json. Values is always null when i tried to read this from appsetting.json using Microsoft.Extensions.Configuration .Below is yaml file
{
"yaml":{
"apiVersion": "batch/v1beta1",
"kind": "CronJob",
"metadata": {
"creationTimestamp": "2020-08-04T06:29:19Z",
"name": "esignature-cron",
"namespace": "esignature"
},
"spec": {
"concurrencyPolicy": "Forbid",
"failedJobsHistoryLimit": 1,
"jobTemplate": {
"metadata": {
"creationTimestamp": null
},
"spec": {
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"app": "your-periodic-batch-job"
}
},
"spec": {
"containers": [
{
"image": "pystore.azurecr.io/py-app1:1.0.0",
"imagePullPolicy": "IfNotPresent",
"name": "redmine-cron",
"resources": {},
"terminationMessagePath": "/dev/termination-log",
"terminationMessagePolicy": "File"
}
],
"dnsPolicy": "ClusterFirst",
"imagePullSecrets": [
{
"name": "dockerpull"
}
],
"restartPolicy": "OnFailure",
"schedulerName": "default-scheduler",
"securityContext": {},
"terminationGracePeriodSeconds": 30
}
}
}
},
"schedule": "*/1 * * * *",
"successfulJobsHistoryLimit": 3,
"suspend": false
}
}
"ConnectionString":"test"
}
C# code
using Microsoft.Extensions.Configuration;
namespace yamlread.Services.Implementation
{
public class yamlread : Iyamlread
{
public IConfiguration Configuration { get; }
public string yaml { get; set;}
public yamlread( IConfiguration config)
{
Configuration =config;
yaml=Configuration["yaml"]
}