question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Doesn't reload config file in k8s

See original GitHub issue

I’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

  1. 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>();
}
  1. 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}"
    }
  ]
}'
  1. 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 
  1. Run. Everything works. But now I need to change a route in configMap and apply
"UpstreamPathTemplate": "/usersnew/{everything}"
  1. 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:closed
  • Created 5 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found