Skip to content
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

deployed on K8S,Connection failed #682

Open
fzwu opened this issue Aug 1, 2024 · 0 comments
Open

deployed on K8S,Connection failed #682

fzwu opened this issue Aug 1, 2024 · 0 comments

Comments

@fzwu
Copy link

fzwu commented Aug 1, 2024

Output of dotnet --info:

Host:
  Version:      6.0.27
  Architecture: x64
  Commit:       80de56dadb

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.27 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.27 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

What version of Docker.DotNet?:
3.125.15

 ---> System.Net.Sockets.SocketException (99): Cannot assign requested address
   at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.CreateException(SocketError error, Boolean forAsyncThrow)
   at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ConnectAsync(Socket socket)
   at System.Net.Sockets.Socket.ConnectAsync(EndPoint remoteEP, CancellationToken cancellationToken)
   at System.Net.Sockets.Socket.ConnectAsync(EndPoint remoteEP)
   at System.Net.Sockets.SocketTaskExtensions.ConnectAsync(Socket socket, EndPoint remoteEP)
   at Docker.DotNet.DockerClient.<>c__DisplayClass6_0.<<-ctor>b__1>d.MoveNext()
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
   at Docker.DotNet.DockerClient.<>c__DisplayClass6_0.<.ctor>b__1(String host, Int32 port, CancellationToken cancellationToken)
   at Microsoft.Net.Http.Client.ManagedHandler.ProcessRequestAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
   at Microsoft.Net.Http.Client.ManagedHandler.ProcessRequestAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at Microsoft.Net.Http.Client.ManagedHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
   at Microsoft.Net.Http.Client.ManagedHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.HttpMessageInvoker.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.HttpClient.<SendAsync>g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken)
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
   at System.Net.Http.HttpClient.<SendAsync>g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken)
   at System.Net.Http.HttpClient.SendAsync(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken)
   at Docker.DotNet.DockerClient.PrivateMakeRequestAsync(TimeSpan timeout, HttpCompletionOption completionOption, HttpMethod method, String path, IQueryString queryString, IDictionary`2 headers, IRequestContent data, CancellationToken cancellationToken)
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
   at Docker.DotNet.DockerClient.PrivateMakeRequestAsync(TimeSpan timeout, HttpCompletionOption completionOption, HttpMethod method, String path, IQueryString queryString, IDictionary`2 headers, IRequestContent data, CancellationToken cancellationToken)
   at Docker.DotNet.DockerClient.MakeRequestForRawResponseAsync(HttpMethod method, String path, IQueryString queryString, IRequestContent body, IDictionary`2 headers, CancellationToken token)
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
   at Docker.DotNet.ImageOperations.CreateImageAsync(ImagesCreateParameters parameters, Stream imageStream, AuthConfig authConfig, IDictionary`2 headers, IProgress`1 progress, CancellationToken cancellationToken)
   at Docker.DotNet.ImageOperations.CreateImageAsync(ImagesCreateParameters parameters, Stream imageStream, AuthConfig authConfig, IProgress`1 progress, CancellationToken cancellationToken)
   at Docker.DotNet.ImageOperations.CreateImageAsync(ImagesCreateParameters parameters, AuthConfig authConfig, IProgress`1 progress, CancellationToken cancellationToken)

Steps to reproduce the issue:

  1. The application is deployed in the K8S cluster, and docker is installed on all nodes in the K8S cluster.
    2.Cannot assign requested address

What actually happened?:

_client =new DockerClientConfiguration(new Uri(DockerApiUri()))
.CreateClient();

await _client.Images.CreateImageAsync(
new ImagesCreateParameters
{
FromImage =$"{imageRegistryHost}/{imageRegistryProject}/{image.MicroserviceName}",
Tag = imagetag,
},
new AuthConfig
{
ServerAddress = "registry.mtywcloud.com",
Username = "dev",
Password = "2022"
},
new Progress());

private string DockerApiUri()
{
var isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);

    if (isWindows) return "npipe://./pipe/docker_engine";

    var isLinux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);

    if (isLinux) return "unix:/var/run/docker.sock";

    throw new Exception(
        "Was unable to determine what OS this is running on, does not appear to be Windows or Linux!?");
}

What did you expect to happen?:

Additional information:

@fzwu fzwu changed the title deployed on K8S,Cannot assign requested address deployed on K8S,Connection failed Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant