engineerd / kubecontroller-csharp

Lightweight Kubernetes controller for CRDs
https://radu-matei.com/blog/kubernetes-controller-csharp/
38 stars 9 forks source link

Exception thrown by ListNamespacedCustomObjectWithHttpMessagesAsync #1

Open radu-matei opened 5 years ago

radu-matei commented 5 years ago
radu:kubecontroller-csharp$ dotnet run --project KubeController.Sample/

Unhandled Exception: System.Net.Http.HttpRequestException: Connection refused ---> System.Net.Sockets.SocketException: Connection refused
   at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
   --- End of inner exception stack trace ---
   at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
   at System.Threading.Tasks.ValueTask`1.get_Result()
   at System.Net.Http.HttpConnectionPool.CreateConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Threading.Tasks.ValueTask`1.get_Result()
   at System.Net.Http.HttpConnectionPool.WaitForCreatedConnectionAsync(ValueTask`1 creationTask)
   at System.Threading.Tasks.ValueTask`1.get_Result()
   at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
   at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at k8s.WatcherDelegatingHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at Microsoft.Rest.RetryDelegatingHandler.<>c__DisplayClass11_0.<<SendAsync>b__1>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.Rest.RetryDelegatingHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
   at k8s.Kubernetes.ListNamespacedCustomObjectWithHttpMessagesAsync(String group, String version, String namespaceParameter, String plural, String fieldSelector, String labelSelector, String resourceVersion, Nullable`1 timeoutSeconds, Nullable`1 watch, String pretty, Dictionary`2 customHeaders, CancellationToken cancellationToken)
   at Engineerd.KubeController.Controller`1.StartAsync(CancellationToken token) in /mnt/c/projects/go/src/github.com/engineerd/kubecontroller-csharp/KubeController/Controller.cs:line 29
   at Engineerd.KubeController.Sample.Program.Main() in /mnt/c/projects/go/src/github.com/engineerd/kubecontroller-csharp/KubeController.Sample/Program.cs:line 30
   at Engineerd.KubeController.Sample.Program.<Main>()
alexeyzimarev commented 3 years ago

Where do you execute the application? It supposes to be hosted in Kubernetes.

alexeyzimarev commented 3 years ago

Sorry, I see that you build the config from the local file. We normally detect where the app runs and if it runs in Kubernetes, use this KubernetesClientConfiguration.InClusterConfig()