question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Building operator fails because of an invalid ~/.kube/config

See original GitHub issue

I’m using version 3.0.0 of the dotnet-operator-sdk. I have a small project that I cannot compile due to an error in my ~/.kube/config.

When running dotnet build, it fails because the generated crds command fails. When I manually run that command, I get the stack trace below.

I understand it fails, because it is unable to parse my ~/.kube/config file because it doesn’t understand the provideClusterInfoProperty property in one of my contexts (I don’t know why it is there). Removing this property makes it work. What I don’t understand: why is the code generation step loading my ~/.kube/config? That shouldn’t be necessary to generate CRD’s, right?

>>> dotnet bin/Debug/netcoreapp5.0/Operator.dll generator crds --out /src/Operator/config/crds --format Yaml

Microsoft (R) Build Engine version 16.8.3+39993bd9d for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
  All projects are up-to-date for restore.
  Operator -> /src/Operator/bin/Debug/netcoreapp5.0/Operator.dll
  Generating Dockerfile
  Dockerfile already exists. Don't overwrite.
  Generating CRDs
  Unhandled exception. System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
   ---> YamlDotNet.Core.YamlException: (Line: 19, Col: 7, Idx: 1985) - (Line: 19, Col: 7, Idx: 1985): Exception during deserialization
   ---> System.Runtime.Serialization.SerializationException: Property 'provideClusterInfoProperty' not found on type 'k8s.KubeConfigModels.ExternalExecution'.
     at YamlDotNet.Serialization.TypeInspectors.TypeInspectorSkeleton.GetProperty(Type type, Object container, String name, Boolean ignoreUnmatched)
     at k8s.Yaml.AutoRestTypeInspector.GetProperty(Type type, Object container, String name, Boolean ignoreUnmatched)
     at YamlDotNet.Serialization.NodeDeserializers.ObjectNodeDeserializer.YamlDotNet.Serialization.INodeDeserializer.Deserialize(IParser parser, Type expectedType, Func`3 nestedObjectDeserializer, Object& value)
     at YamlDotNet.Serialization.ValueDeserializers.NodeValueDeserializer.DeserializeValue(IParser parser, Type expectedType, SerializerState state, IValueDeserializer nestedObjectDeserializer)
     --- End of inner exception stack trace ---
     at YamlDotNet.Serialization.ValueDeserializers.NodeValueDeserializer.DeserializeValue(IParser parser, Type expectedType, SerializerState state, IValueDeserializer nestedObjectDeserializer)
     at YamlDotNet.Serialization.ValueDeserializers.AliasValueDeserializer.DeserializeValue(IParser parser, Type expectedType, SerializerState state, IValueDeserializer nestedObjectDeserializer)
     at YamlDotNet.Serialization.ValueDeserializers.NodeValueDeserializer.<>c__DisplayClass3_0.<DeserializeValue>b__0(IParser r, Type t)
     at YamlDotNet.Serialization.NodeDeserializers.ObjectNodeDeserializer.YamlDotNet.Serialization.INodeDeserializer.Deserialize(IParser parser, Type expectedType, Func`3 nestedObjectDeserializer, Object& value)
     at YamlDotNet.Serialization.ValueDeserializers.NodeValueDeserializer.DeserializeValue(IParser parser, Type expectedType, SerializerState state, IValueDeserializer nestedObjectDeserializer)
     at YamlDotNet.Serialization.ValueDeserializers.AliasValueDeserializer.DeserializeValue(IParser parser, Type expectedType, SerializerState state, IValueDeserializer nestedObjectDeserializer)
     at YamlDotNet.Serialization.ValueDeserializers.NodeValueDeserializer.<>c__DisplayClass3_0.<DeserializeValue>b__0(IParser r, Type t)
     at YamlDotNet.Serialization.NodeDeserializers.ObjectNodeDeserializer.YamlDotNet.Serialization.INodeDeserializer.Deserialize(IParser parser, Type expectedType, Func`3 nestedObjectDeserializer, Object& value)
     at YamlDotNet.Serialization.ValueDeserializers.NodeValueDeserializer.DeserializeValue(IParser parser, Type expectedType, SerializerState state, IValueDeserializer nestedObjectDeserializer)
     at YamlDotNet.Serialization.ValueDeserializers.AliasValueDeserializer.DeserializeValue(IParser parser, Type expectedType, SerializerState state, IValueDeserializer nestedObjectDeserializer)
     at YamlDotNet.Serialization.ValueDeserializers.NodeValueDeserializer.<>c__DisplayClass3_0.<DeserializeValue>b__0(IParser r, Type t)
     at YamlDotNet.Serialization.NodeDeserializers.CollectionNodeDeserializer.DeserializeHelper(Type tItem, IParser parser, Func`3 nestedObjectDeserializer, IList result, Boolean canUpdate)
     at YamlDotNet.Serialization.NodeDeserializers.CollectionNodeDeserializer.YamlDotNet.Serialization.INodeDeserializer.Deserialize(IParser parser, Type expectedType, Func`3 nestedObjectDeserializer, Object& value)
     at YamlDotNet.Serialization.ValueDeserializers.NodeValueDeserializer.DeserializeValue(IParser parser, Type expectedType, SerializerState state, IValueDeserializer nestedObjectDeserializer)
     at YamlDotNet.Serialization.ValueDeserializers.AliasValueDeserializer.DeserializeValue(IParser parser, Type expectedType, SerializerState state, IValueDeserializer nestedObjectDeserializer)
     at YamlDotNet.Serialization.ValueDeserializers.NodeValueDeserializer.<>c__DisplayClass3_0.<DeserializeValue>b__0(IParser r, Type t)
     at YamlDotNet.Serialization.NodeDeserializers.EnumerableNodeDeserializer.YamlDotNet.Serialization.INodeDeserializer.Deserialize(IParser parser, Type expectedType, Func`3 nestedObjectDeserializer, Object& value)
     at YamlDotNet.Serialization.ValueDeserializers.NodeValueDeserializer.DeserializeValue(IParser parser, Type expectedType, SerializerState state, IValueDeserializer nestedObjectDeserializer)
     at YamlDotNet.Serialization.ValueDeserializers.AliasValueDeserializer.DeserializeValue(IParser parser, Type expectedType, SerializerState state, IValueDeserializer nestedObjectDeserializer)
     at YamlDotNet.Serialization.ValueDeserializers.NodeValueDeserializer.<>c__DisplayClass3_0.<DeserializeValue>b__0(IParser r, Type t)
     at YamlDotNet.Serialization.NodeDeserializers.ObjectNodeDeserializer.YamlDotNet.Serialization.INodeDeserializer.Deserialize(IParser parser, Type expectedType, Func`3 nestedObjectDeserializer, Object& value)
     at YamlDotNet.Serialization.ValueDeserializers.NodeValueDeserializer.DeserializeValue(IParser parser, Type expectedType, SerializerState state, IValueDeserializer nestedObjectDeserializer)
     at YamlDotNet.Serialization.ValueDeserializers.AliasValueDeserializer.DeserializeValue(IParser parser, Type expectedType, SerializerState state, IValueDeserializer nestedObjectDeserializer)
     at YamlDotNet.Serialization.Deserializer.Deserialize(IParser parser, Type type)
     at YamlDotNet.Serialization.Deserializer.Deserialize[T](IParser parser)
     at YamlDotNet.Serialization.Deserializer.Deserialize[T](TextReader input)
     at YamlDotNet.Serialization.Deserializer.Deserialize[T](String input)
     at k8s.Yaml.LoadFromString[T](String content)
     at k8s.Yaml.LoadFromStreamAsync[T](Stream stream)
     at k8s.KubernetesClientConfiguration.LoadKubeConfigAsync(FileInfo kubeconfig, Boolean useRelativePaths)
     at k8s.KubernetesClientConfiguration.BuildConfigFromConfigFileAsync(FileInfo kubeconfig, String currentContext, String masterUrl, Boolean useRelativePaths)
     at k8s.KubernetesClientConfiguration.BuildConfigFromConfigFile(FileInfo kubeconfig, String currentContext, String masterUrl, Boolean useRelativePaths)
     at k8s.KubernetesClientConfiguration.BuildConfigFromConfigFile(String kubeconfigPath, String currentContext, String masterUrl, Boolean useRelativePaths)
     at k8s.KubernetesClientConfiguration.BuildDefaultConfig()
     at DotnetKubernetesClient.KubernetesClient..ctor()
     at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
     at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitDisposeCache(ServiceCallSite transientCallSite, RuntimeResolverContext context)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine.<>c__DisplayClass1_0.<RealizeService>b__0(ServiceProviderEngineScope scope)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)
     at McMaster.Extensions.CommandLineUtils.CommandLineApplication.ServiceProvider.GetService(Type serviceType)
     at McMaster.Extensions.CommandLineUtils.CommandLineApplication.System.IServiceProvider.GetService(Type serviceType)
     at McMaster.Extensions.CommandLineUtils.Conventions.ConstructorInjectionConvention.FindMatchedConstructor[TModel](ConstructorInfo[] constructors, IServiceProvider services, Boolean throwIfNoParameterTypeRegistered)
     at McMaster.Extensions.CommandLineUtils.Conventions.ConstructorInjectionConvention.ApplyImpl[TModel](ConventionContext context)
     --- End of inner exception stack trace ---
     at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
     at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
     at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
     at McMaster.Extensions.CommandLineUtils.Conventions.ConstructorInjectionConvention.Apply(ConventionContext context)
     at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Builder.McMaster.Extensions.CommandLineUtils.Conventions.IConventionBuilder.AddConvention(IConvention convention)
     at McMaster.Extensions.CommandLineUtils.ConventionBuilderExtensions.UseConstructorInjection(IConventionBuilder builder, IServiceProvider additionalServices)
     at KubeOps.Operator.HostExtensions.RunOperatorAsync(IHost host, String[] args)
     at Operator.Program.Main(String[] args) in /src/Operator/Program.cs:line 20
     at Operator.Program.<Main>(String[] args)
  Aborted (core dumped)
/home/basilfx/.nuget/packages/kubeops/3.0.0/build/KubeOps.targets(59,9): error MSB3073: The command "dotnet bin/Debug/netcoreapp5.0/Operator.dll generator crds --out /src/Operator/config/crds --format Yaml" exited with code 134. [/src/Operator/Operator.csproj]

Build FAILED.

/home/basilfx/.nuget/packages/kubeops/3.0.0/build/KubeOps.targets(59,9): error MSB3073: The command "dotnet bin/Debug/netcoreapp5.0/Operator.dll generator crds --out /src/Operator/config/crds --format Yaml" exited with code 134. [/src/Operator/Operator.csproj]
    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:02.88

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
buehlercommented, Feb 20, 2021

Just found out, that the kubernetes client project could fix this error (see mention above).

0reactions
buehlercommented, Mar 5, 2021

This should be fixed by #169

Read more comments on GitHub >

github_iconTop Results From Across the Web

Failed to load kubeconfig due to Invalid kube-config file #56
This is all very strange, as this causes the playbook to fail, and I am able to cat the file, and it's perfectly...
Read more >
Invalid kube-config file. No configuration found when i use ...
But i am getting this error: kubernetes.config.config_exception.ConfigException: Invalid kube-config file. No configuration found.
Read more >
Invalid Kube-Config File, No Configuration Found
When working with Kubernetes, you may encounter an error message that reads: 'Invalid kube-config file. No configuration found.
Read more >
Error launching POD in EKS from MWAA
We are trying to launch a POD in EKS from MWAA. Our EKS is authenticated using aws-iam-authenticator in kube_config.yaml.
Read more >
AWS EKS update-kubeconfig does not respect --role-arn flag
The error you are hitting is because the AWS credentials you're using to run the update-kubeconfig command don't have permissions to ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found