Skip to content
This repository has been archived by the owner on Aug 20, 2022. It is now read-only.

"Cannot find the requested object" error when trying to connect to kubernetes cluster from Visual Studio 2019 #337

Open
bab5470 opened this issue Jul 14, 2022 · 1 comment

Comments

@bab5470
Copy link

bab5470 commented Jul 14, 2022

When trying to connect to our (Rancher) kubernetes cluster from Bridge for Kubernetes Visual Studio extension we are seeing the following error "Cannot find the requested object.":

image

Furthermore it seems the extension isn't enumerating the namespaces, services or application URL dropdowns.

I confirmed using kubectl that I can communicate with my cluster from the same workstation that I am running Bridge to Kubernetes on and I am using a connection where all ports are completely open. So I don't think this is a ports issue.

I am also using an account that I believe has the equivalent of cluster admin permissions so there shouldn't be a permissions problem either. I am attaching logs from the bridge for kubernetes:

Bridge To Kubernetes.zip

There are multiple logs and multiple errors in the logs which makes it difficult to pinpoint which are relevant but from what I can see a lot of them seem to be related to cryptography and perhaps the SSL certificate being used on the cluster.

2022-07-14T11:29:49.0651632Z | Library | ERROR | Logging handled exception: Internal.Cryptography.CryptoThrowHelper+WindowsCryptographicException: {"StackTrace":"   at Internal.Cryptography.Pal.CertificatePal.FromBlobOrFile(Byte[] rawData, String fileName, SafePasswordHandle password, X509KeyStorageFlags keyStorageFlags)
   at System.Security.Cryptography.X509Certificates.X509Certificate..ctor(Byte[] data)
   at System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(Byte[] rawData)
   at k8s.KubernetesClientConfiguration.SetClusterDetails(K8SConfiguration k8SConfig, Context activeContext)
   at k8s.KubernetesClientConfiguration.InitializeContext(K8SConfiguration k8SConfig, String currentContext)
   at k8s.KubernetesClientConfiguration.GetKubernetesClientConfiguration(String currentContext, String masterUrl, K8SConfiguration k8SConfig)
   at k8s.KubernetesClientConfiguration.BuildConfigFromConfigObject(K8SConfiguration k8SConfig, String currentContext, String masterUrl)
   at Microsoft.BridgeToKubernetes.Common.Kubernetes.K8sClientFactory.CreateFromKubeConfig(K8SConfiguration kubeConfig)
   at Microsoft.BridgeToKubernetes.Common.Kubernetes.KubernetesClient.<>c__DisplayClass12_0.<.ctor>b__0()
   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
   at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.get_Value()
   at Microsoft.BridgeToKubernetes.Common.Kubernetes.KubernetesClient.get_RestClient()
   at Microsoft.BridgeToKubernetes.Common.Kubernetes.KubernetesClient.<>c__DisplayClass38_0.<<ListServicesInNamespaceAsync>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.BridgeToKubernetes.Common.Kubernetes.KubernetesClient.<>c__DisplayClass75_0`1.<<ClientInvokeWrapperAsync>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.BridgeToKubernetes.Common.Utilities.WebUtilities.RetryUntilTimeAsync(Func`2 action, TimeSpan maxWaitTime, CancellationToken cancellationToken)
   at Microsoft.BridgeToKubernetes.Common.Kubernetes.KubernetesClient.ClientInvokeWrapperAsync[T](Func`1 handler, String operation, CancellationToken cancellationToken)
   at Microsoft.BridgeToKubernetes.Common.Kubernetes.KubernetesClient.ListServicesInNamespaceAsync(String namespaceName, IEnumerable`1 labels, CancellationToken cancellationToken)
   at Microsoft.BridgeToKubernetes.Library.Client.ManagementClients.KubernetesManagementClient.<>c__DisplayClass9_0.<<ListServicesInNamespacesAsync>b__3>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.BridgeToKubernetes.Library.ServiceClients.KubernetesRestClientExceptionStrategy.RunWithHandlingAsync[T](Func`1 func, FailureConfig failureConfig)","Message":"Cannot find the requested object.","Data":{},"InnerException":null,"HelpLink":null,"Source":"System.Security.Cryptography.X509Certificates","HResult":-2146885623}

The cluster is using an SSL certificate from our centralized certificate authority which my workstation trusts (the CA cert is in the local certificate store). Now I'm not sure if I have to do anything to make Visual Studio or Bridge to Kubernetes to trust it.

Perhaps that's not the root cause of the problem but can anyone offer me any suggestions on how to get this working or what to look at?

Thanks!
Brad

@bab5470
Copy link
Author

bab5470 commented Jul 19, 2022

Anyone have any ideas or suggestions?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant