Doesn't reload config file in k8s
See original GitHub issueI’m using k8s to deploy image with Ocelot. I need to change route configs without restart Ocelot. So, from docs I found that:
.AddJsonFile(Path.Combine("configurations", "ocelot.json"), true, true)
should work, but it doesn’t.
Steps to Reproduce the Problem
- Program.cs
private static IWebHostBuilder CreateWebHostBuilder(string[] args)
{
return WebHost.CreateDefaultBuilder(args)
.ConfigureAppConfiguration((hostingContext, config) =>
{
config
.SetBasePath(hostingContext.HostingEnvironment.ContentRootPath)
.AddJsonFile("appsettings.json", true, true)
.AddJsonFile(Path.Combine("configurations", "ocelot.json"), true, true)
.AddEnvironmentVariables();
})
.UseStartup<Startup>();
}
- Create ConfigMap
apiVersion: v1
kind: ConfigMap
metadata:
name: ocelot-api
labels:
module: ocelot
app: api
data:
ocelot: '{
"ReRoutes": [
{
"DownstreamPathTemplate": "/{everything}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "users-api",
"Port": 7511
}
],
"UpstreamPathTemplate": "/users/{everything}"
}
]
}'
- A part of my Deployment
spec:
containers:
- name: master
env:
- name: ASPNETCORE_ENVIRONMENT
value: Development
image: apigateway-ocelot
ports:
- containerPort: 80
volumeMounts:
- name: config
mountPath: /app/configurations
volumes:
- name: config
configMap:
name: ocelot-api
items:
- key: ocelot
path: ocelot.json
- Run. Everything works. But now I need to change a route in configMap and apply
"UpstreamPathTemplate": "/usersnew/{everything}"
- The mounted file is changed. But Ocelot returns 404 and old route works.
Specifications
- Version: 11.0.2
- Platform: docker
- Subsystem: k8s
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Auto reload configuration changes without restarting pod ...
1 Answer. You can do it without restarting the POD using configmap only, however still it more depends on your application end. You...
Read more >Auto-Reload Configuration Problem in .NET Core ...
First, let's discuss how to do Kubernetes Auto-reload ConfigMap. They are included as environment variables when Kubernetes ConfigMap is created and added on ......
Read more >Kubernetes. Auto-reload of the configuration doesn't work ...
Result: Auto-reload doesn't work. Note: if we have a default kubeconfig file - then reload works ok by "Save" and the notification appears...
Read more >ConfigMap from file used in deployment does not update ...
Running Kubernetes 1.14 and created a ConfigMap: kubectl create configmap esquire-config --from-file=config.js=configs/env.cloud-dev.js.
Read more >Nginx config reload without downtime
Run service nginx reload or /etc/init.d/nginx reload. It will do a hot reload of the configuration without downtime.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
seen the note about subpaths here https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap#mounted-configmaps-are-updated-automatically
/k8s