Azure/Bridge-To-Kubernetes

`dsc connect` problems with connectivity to cluster

petr-buchin opened this issue · 0 comments

Describe the bug
I'm trying to use dsc cli tool directly to route traffic to my local machine. I provide correct arguments to dsc connect command. However, it ends up with a strange error about my kubeconfig:

An unexpected error occurred: 'Failed to perform action on the cluster using the current kubeconfig. You may need to log in by running a kubectl command.'

I can confirm that I can use any kubectl commands without any problems, but somehow dsc have problems with an access to cluster.

Mention the platform you are using
VsCode

To Reproduce
Steps to reproduce the behavior:

  1. Run dsc connect --service my-service-name --namespace=my-namespace --local-port 33001 --use-kubernetes-service-environment-variables --yes -- my command to execute in terminal
  2. See error that looks like this:
An unexpected error occurred: 'Failed to perform action on the cluster using the current kubeconfig. You may need to log in by running a kubectl command.'
To see our active issues or file a bug report, please visit https://aka.ms/bridge-to-k8s-report.
For diagnostic information, see logs at '/var/folders/_n/ngnd9b_x67b8ft57ywnw8lfh0000gn/T/Bridge To Kubernetes'.

Expected behavior
I expect cli tool to connect to cluster and start to forward traffic from specified service to my local machine

Logs:

2024-02-27T17:40:16.7978450Z | Library | TRACE | Pulling kubeconfig...\nOperation context: <json>{"clientRequestId":null,"correlationId":"6343b174-9a1e-40b4-ae9b-159b737696001709055602886:053ec064a810:5d474cfe1591","requestId":null,"userSubscriptionId":null,"startTime":"2024-02-27T17:40:16.786372+00:00","userAgent":"VSCode/2.0.120240111","requestHttpMethod":null,"requestUri":null,"version":"1.0.20240109.1","requestHeaders":{},"loggingProperties":{"ApplicationName":"Library","DeviceOperatingSystem":"Darwin 22.5.0 Darwin Kernel Version 22.5.0: Thu Jun  8 22:22:20 PDT 2023; root:xnu-8796.121.3~7/RELEASE_ARM64_T6000","Framework":".NET 7.0.7","MacAddressHash":"b46053ae578eca7980be5dbbab45a52a12b60404dcc2e1f998974fed32d5368e","ProcessId":33783,"TargetEnvironment":"Production"}}</json>
2024-02-27T17:40:16.8593000Z | Library | TRACE | Event: CloudProvider <json>{"properties":{"ClusterFQDNDomain":"Amazon"},"metrics":null}</json>
2024-02-27T17:40:16.9456400Z | Library | WARNG | Logging handled exception: k8s.Exceptions.KubeConfigException: {"Message":"external exec failed due to failed deserialization process: System.Text.Json.JsonException: The input does not contain any JSON tokens. Expected the input to start with a valid JSON token, when isFinalBlock is true. Path: $ | LineNumber: 0 | BytePositionInLine: 0.\n ---\u003E System.Text.Json.JsonReaderException: The input does not contain any JSON tokens. Expected the input to start with a valid JSON token, when isFinalBlock is true. LineNumber: 0 | BytePositionInLine: 0.\n   at System.Text.Json.ThrowHelper.ThrowJsonReaderException(Utf8JsonReader\u0026 json, ExceptionResource resource, Byte nextByte, ReadOnlySpan\u00601 bytes)\n   at System.Text.Json.Utf8JsonReader.Read()\n   at System.Text.Json.Serialization.JsonConverter\u00601.ReadCore(Utf8JsonReader\u0026 reader, JsonSerializerOptions options, ReadStack\u0026 state)\n   --- End of inner exception stack trace ---\n   at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack\u0026 state, JsonReaderException ex)\n   at System.Text.Json.Serialization.JsonConverter\u00601.ReadCore(Utf8JsonReader\u0026 reader, JsonSerializerOptions options, ReadStack\u0026 state)\n   at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan\u00601 utf8Json, JsonTypeInfo jsonTypeInfo, Nullable\u00601 actualByteCount)\n   at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan\u00601 json, JsonTypeInfo jsonTypeInfo)\n   at k8s.KubernetesJson.Deserialize[TValue](String json, JsonSerializerOptions jsonSerializerOptions)\n   at k8s.KubernetesClientConfiguration.ExecuteExternalCommand(ExternalExecution config)","Data":{},"InnerException":null,"HelpLink":null,"Source":"KubernetesClient","HResult":-2146233088,"StackTrace":"   at k8s.KubernetesClientConfiguration.ExecuteExternalCommand(ExternalExecution config)\n   at k8s.KubernetesClientConfiguration.SetUserDetails(K8SConfiguration k8SConfig, Context activeContext)\n   at k8s.KubernetesClientConfiguration.InitializeContext(K8SConfiguration k8SConfig, String currentContext)\n   at k8s.KubernetesClientConfiguration.GetKubernetesClientConfiguration(String currentContext, String masterUrl, K8SConfiguration k8SConfig)\n   at k8s.KubernetesClientConfiguration.BuildConfigFromConfigObject(K8SConfiguration k8SConfig, String currentContext, String masterUrl)\n   at Microsoft.BridgeToKubernetes.Common.Kubernetes.K8sClientFactory.CreateFromKubeConfig(K8SConfiguration kubeConfig)\n   at Microsoft.BridgeToKubernetes.Common.Kubernetes.KubernetesClient.\u003C\u003Ec__DisplayClass12_0.\u003C.ctor\u003Eb__0()\n   at System.Lazy\u00601.ViaFactory(LazyThreadSafetyMode mode)\n   at System.Lazy\u00601.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)\n   at System.Lazy\u00601.CreateValue()\n   at Microsoft.BridgeToKubernetes.Common.Kubernetes.KubernetesClient.get_RestClient()\n   at Microsoft.BridgeToKubernetes.Common.Kubernetes.KubernetesClient.\u003C\u003Ec__DisplayClass29_0.\u003C\u003CListPodsInNamespaceAsync\u003Eb__0\u003Ed.MoveNext()\n--- End of stack trace from previous location ---\n   at Microsoft.BridgeToKubernetes.Common.Kubernetes.KubernetesClient.\u003C\u003Ec__DisplayClass75_0\u00601.\u003C\u003CClientInvokeWrapperAsync\u003Eb__0\u003Ed.MoveNext()\n--- End of stack trace from previous location ---\n   at Microsoft.BridgeToKubernetes.Common.Utilities.WebUtilities.RetryUntilTimeAsync(Func\u00602 action, TimeSpan maxWaitTime, CancellationToken cancellationToken)\n   at Microsoft.BridgeToKubernetes.Common.Kubernetes.KubernetesClient.ClientInvokeWrapperAsync[T](Func\u00601 handler, String operation, CancellationToken cancellationToken)\n   at Microsoft.BridgeToKubernetes.Common.Kubernetes.KubernetesClient.ListPodsInNamespaceAsync(String namespaceName, IEnumerable\u00601 labels, CancellationToken cancellationToken)\n   at Microsoft.BridgeToKubernetes.Library.Client.ManagementClients.KubernetesManagementClient.\u003C\u003Ec__DisplayClass7_0.\u003C\u003CRefreshCredentialsAsync\u003Eb__0\u003Ed.MoveNext()"}\nOperation context: <json>{"clientRequestId":"ca570d6f-9348-42fe-bf7f-106ebf40ab88","correlationId":"6343b174-9a1e-40b4-ae9b-159b737696001709055602886:053ec064a810:2dd82ecc627a","requestId":null,"userSubscriptionId":null,"startTime":"2024-02-27T17:40:16.786372+00:00","userAgent":"VSCode/2.0.120240111","requestHttpMethod":null,"requestUri":null,"version":"1.0.20240109.1","requestHeaders":{},"loggingProperties":{"ApplicationName":"Library","DeviceOperatingSystem":"Darwin 22.5.0 Darwin Kernel Version 22.5.0: Thu Jun  8 22:22:20 PDT 2023; root:xnu-8796.121.3~7/RELEASE_ARM64_T6000","Framework":".NET 7.0.7","MacAddressHash":"b46053ae578eca7980be5dbbab45a52a12b60404dcc2e1f998974fed32d5368e","ProcessId":33783,"TargetEnvironment":"Production"}}</json>
2024-02-27T17:40:16.9580800Z | Library | TRACE | Invoking kubectl ListPods command: --kubeconfig="/var/folders/_n/ngnd9b_x67b8ft57ywnw8lfh0000gn/T/tmpLL48xR.tmp" get po --namespace petr-buchyn
2024-02-27T17:40:16.9585040Z | Library | TRACE | Using kubectl found at: '/Users/petrbuchin/Library/Application Support/Code/User/globalStorage/mindaro.mindaro/file-downloader-downloads/bridge/kubectl/osx/kubectl'
2024-02-27T17:40:16.9767450Z | Library | TRACE | Invoked long running kubectl ListPods command: '--kubeconfig="/var/folders/_n/ngnd9b_x67b8ft57ywnw8lfh0000gn/T/tmpLL48xR.tmp" get po --namespace petr-buchyn'
2024-02-27T17:40:17.4567090Z | Library | TRACE | Dependency: Kubernetes <json>{"target":"ListPods","success":true,"duration":null,"properties":{"ExitCode":"0"}}</json>
2024-02-27T17:40:17.4613550Z | Library | TRACE | Event: KubernetesManagementClient-RefreshCredentialsAsync <json>{"properties":{"Result":"Succeeded"},"metrics":{"DurationInMs":594}}</json>

Desktop (please complete the following information):

  • OS: MacOs Ventura 13.4.1