I'm using kubectl to deploy ASP.Net core apps to K8S cluster. At the current moment I hardcode container PORTs and ConnectionString for DataBase like this:
apiVersion: apps/v1
kind: Deployment
metadata:
name: mydeploy
spec:
replicas: 1
selector:
matchLabels:
app: mydeploy
template:
metadata:
labels:
app: mydeploy
spec:
containers:
- name: mydeploy
image: harbor.com/my_app:latest
env:
- name: MyApp__ConnectionString
value: "Host=postgres-ap-svc;Port=5432;Database=db;Username=postgres;Password=password"
ports:
- containerPort: 5076
But the good solution I think - to use such variables from appsettings.json
file (ASP.Net config file).
So my question - How to load this vars from JSON file and use in yaml file?
JSON file is like this:
{
"MyApp": {
"ConnectionString": "Host=postgres-ap-svc;Port=5432;Database=db;Username=postgres;Password=password"
},
"ClientBaseUrls": {
"MyApp": "http://mydeploy-svc:5076/api",
}
}