-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
reload on configmap change not working #82
Comments
Hi - does this sample work correctly for you? https://github.com/tintoy/dotnet-kube-client/tree/develop/samples/ConfigFromConfigMap I know it's not ASP.NET Core, but it'll at least tell me whether config-map reloads work for you at all (and we can go from there). |
BTW, if you want to see changes to config after the app is started, you need to inject |
BTW, here's the smallest example I could make: public class Startup
{
public Startup(IConfiguration configuration) => Configuration = configuration;
public IConfiguration Configuration { get; }
public void ConfigureServices(IServiceCollection services)
{
services.AddOptions();
services.Configure<MyOptions>(Configuration);
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.Use(next => async context =>
{
MyOptions options = context.RequestServices.GetRequiredService<IOptionsMonitor<MyOptions>>().CurrentValue;
await context.Response.WriteAsync(
$"Foo: '{options.Foo}', Bar: '{options.Bar}'"
);
});
}
}
public class MyOptions
{
public string Foo { get; set; }
public string Bar { get; set; }
}
public static class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureAppConfiguration(config =>
{
KubeClientOptions clientOptions = K8sConfig.Load().ToKubeClientOptions(
defaultKubeNamespace: "default"
);
config.AddKubeConfigMap(clientOptions, "my-config-map", reloadOnChange: true);
})
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
} |
Thanks for responding, I have tried it an ASP.NET Core application using IOptionsMonitor but i am still not seeing the update. I have read your blog too. Following is the git repo for my attempt: Not sure if i am missing something obvious. Thanks for your help in advance. |
Just out of curiosity, if you try the example code I posted above, does that work for you? |
Running into a similar issue where reloadOnChange appears to stop working after a while. I think it may be related to the fact that watches timeout after a while. Does the client retry on watch expiration? kubernetes/kubernetes#42552
|
No - I don’t think we attempt to retry. I guess we could implement that if I can figure out exactly what a timeout response looks like though. |
I tried setting it up in a demo asp.net core app, the configuration does not reload when the config map changes. Do you have any working samples for ASP.NET Core Web App
The text was updated successfully, but these errors were encountered: