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

quarkus-kubernetes-client fails to use ExecCredential when running in native mode #30151

Closed
Obirah opened this issue Jan 3, 2023 · 5 comments · Fixed by #30153
Closed

quarkus-kubernetes-client fails to use ExecCredential when running in native mode #30151

Obirah opened this issue Jan 3, 2023 · 5 comments · Fixed by #30153
Assignees
Labels
area/kubernetes kind/bug Something isn't working
Milestone

Comments

@Obirah
Copy link

Obirah commented Jan 3, 2023

Describe the bug

I'm developing a Quarkus application which creates resources on a Kubernetes cluster. The cluster is an EKS cluster and hence the kubeconfig on my development machine contains an exec section which calls aws eks get-token ....

When building the application in native mode and running it on my development machine, the Kubernetes client fails because it cannot deserialize the ExecConfig.

Expected behavior

The Kubernetes client provided by the quarkus-kubernetes-client extension should be able to authenticate with clusters using ExecCredential in native mode just as it is able to do so in quarkus dev mode.

Actual behavior

The Kubernetes client fails with the following error when running in native mode: Cannot construct instance of io.fabric8.kubernetes.client.Config$ExecCredential: cannot deserialize from Object value (no delegate- or property-based Creator): this appears to be a native image, in which case you may need to configure reflection for the class that is to be deserialized

How to Reproduce?

  1. Create an EKS cluster
  2. Issue aws eks update-kubeconfig --name <cluster-name> so that you have a kubeconfig containing the exec section on your machine.
  3. Start a Quarkus app that is built in native mode and uses the kubernetes client.

Output of uname -a or ver

No response

Output of java -version

openjdk 17.0.5 2022-10-18

GraalVM version (if different from Java)

22.3.0

Quarkus version or git rev

2.15.1.Final

Build tool (ie. output of mvnw --version or gradlew --version)

Gradle 7.6

Additional information

No response

@Obirah Obirah added the kind/bug Something isn't working label Jan 3, 2023
@quarkus-bot
Copy link

quarkus-bot bot commented Jan 3, 2023

/cc @Sgitario(kubernetes), @geoand(kubernetes), @iocanel(kubernetes)

@geoand
Copy link
Contributor

geoand commented Jan 3, 2023

Any chance you can provide the entire stacktrace?

@Obirah
Copy link
Author

Obirah commented Jan 3, 2023

Sure, here you go:

2023-01-03 16:52:38,903 ERROR [io.fab.kub.cli.Config] (main) Failed to parse the kubeconfig.: io.fabric8.kubernetes.client.KubernetesClientException: An error has occurred.
        at io.fabric8.kubernetes.client.utils.Serialization.unmarshal(Serialization.java:244)
        at io.fabric8.kubernetes.client.utils.Serialization.unmarshal(Serialization.java:351)
        at io.fabric8.kubernetes.client.utils.Serialization.unmarshal(Serialization.java:287)
        at io.fabric8.kubernetes.client.utils.Serialization.unmarshal(Serialization.java:272)
        at io.fabric8.kubernetes.client.Config.getExecCredentialFromExecConfig(Config.java:746)
        at io.fabric8.kubernetes.client.Config.loadFromKubeconfig(Config.java:702)
        at io.fabric8.kubernetes.client.Config.tryKubeConfig(Config.java:616)
        at io.fabric8.kubernetes.client.Config.autoConfigure(Config.java:286)
        at io.fabric8.kubernetes.client.Config.<init>(Config.java:251)
        at io.fabric8.kubernetes.client.Config.<init>(Config.java:245)
        at io.fabric8.kubernetes.client.ConfigBuilder.<init>(ConfigBuilder.java:10)
        at io.fabric8.kubernetes.client.ConfigBuilder.<init>(ConfigBuilder.java:7)
        at io.quarkus.kubernetes.client.runtime.KubernetesClientUtils.createConfig(KubernetesClientUtils.java:20)
        at io.quarkus.kubernetes.client.runtime.KubernetesConfigProducer.config(KubernetesConfigProducer.java:17)
        at io.quarkus.kubernetes.client.runtime.KubernetesConfigProducer_ProducerMethod_config_473f364c0137b02548d58c16344312a6c0709354_Bean.create(Unknown Source)
        at io.quarkus.kubernetes.client.runtime.KubernetesConfigProducer_ProducerMethod_config_473f364c0137b02548d58c16344312a6c0709354_Bean.create(Unknown Source)
        at io.quarkus.arc.impl.AbstractSharedContext.createInstanceHandle(AbstractSharedContext.java:113)
        at io.quarkus.arc.impl.AbstractSharedContext$1.get(AbstractSharedContext.java:37)
        at io.quarkus.arc.impl.AbstractSharedContext$1.get(AbstractSharedContext.java:34)
        at io.quarkus.arc.impl.LazyValue.get(LazyValue.java:26)
        at io.quarkus.arc.impl.ComputingCache.computeIfAbsent(ComputingCache.java:69)
        at io.quarkus.arc.impl.AbstractSharedContext.get(AbstractSharedContext.java:34)
        at io.quarkus.kubernetes.client.runtime.KubernetesConfigProducer_ProducerMethod_config_473f364c0137b02548d58c16344312a6c0709354_Bean.get(Unknown Source)
        at io.quarkus.kubernetes.client.runtime.KubernetesConfigProducer_ProducerMethod_config_473f364c0137b02548d58c16344312a6c0709354_Bean.get(Unknown Source)
        at io.quarkus.kubernetes.client.runtime.KubernetesClientProducer_ProducerMethod_kubernetesClient_a22f7caa17bd98380e4f38d941de1bca98b44f84_Bean.create(Unknown Source)
        at io.quarkus.kubernetes.client.runtime.KubernetesClientProducer_ProducerMethod_kubernetesClient_a22f7caa17bd98380e4f38d941de1bca98b44f84_Bean.create(Unknown Source)
        at io.quarkus.arc.impl.AbstractSharedContext.createInstanceHandle(AbstractSharedContext.java:113)
        at io.quarkus.arc.impl.AbstractSharedContext$1.get(AbstractSharedContext.java:37)
        at io.quarkus.arc.impl.AbstractSharedContext$1.get(AbstractSharedContext.java:34)
        at io.quarkus.arc.impl.LazyValue.get(LazyValue.java:26)
        at io.quarkus.arc.impl.ComputingCache.computeIfAbsent(ComputingCache.java:69)
        at io.quarkus.arc.impl.AbstractSharedContext.get(AbstractSharedContext.java:34)
        at io.quarkus.kubernetes.client.runtime.KubernetesClientProducer_ProducerMethod_kubernetesClient_a22f7caa17bd98380e4f38d941de1bca98b44f84_Bean.get(Unknown Source)
        at io.quarkus.kubernetes.client.runtime.KubernetesClientProducer_ProducerMethod_kubernetesClient_a22f7caa17bd98380e4f38d941de1bca98b44f84_Bean.get(Unknown Source)
        at de.db.mdp.awsEndpointSync.producer.KubernetesClientProducer_Bean.create(Unknown Source)
        at de.db.mdp.awsEndpointSync.producer.KubernetesClientProducer_Bean.create(Unknown Source)
        at io.quarkus.arc.impl.AbstractSharedContext.createInstanceHandle(AbstractSharedContext.java:113)
        at io.quarkus.arc.impl.AbstractSharedContext$1.get(AbstractSharedContext.java:37)
        at io.quarkus.arc.impl.AbstractSharedContext$1.get(AbstractSharedContext.java:34)
        at io.quarkus.arc.impl.LazyValue.get(LazyValue.java:26)
        at io.quarkus.arc.impl.ComputingCache.computeIfAbsent(ComputingCache.java:69)
        at io.quarkus.arc.impl.AbstractSharedContext.get(AbstractSharedContext.java:34)
        at de.db.mdp.awsEndpointSync.producer.KubernetesClientProducer_Bean.get(Unknown Source)
        at de.db.mdp.awsEndpointSync.producer.KubernetesClientProducer_Bean.get(Unknown Source)
        at de.db.mdp.awsEndpointSync.producer.KubernetesClientProducer_ProducerMethod_account_e4d40e179da98fc1e751aa0dc4e30910120a8a56_Bean.create(Unknown Source)
        at de.db.mdp.awsEndpointSync.producer.KubernetesClientProducer_ProducerMethod_account_e4d40e179da98fc1e751aa0dc4e30910120a8a56_Bean.get(Unknown Source)
        at de.db.mdp.awsEndpointSync.producer.KubernetesClientProducer_ProducerMethod_account_e4d40e179da98fc1e751aa0dc4e30910120a8a56_Bean.get(Unknown Source)
        at de.db.mdp.awsEndpointSync.sync.AwsEndpointSync_Bean.create(Unknown Source)
        at de.db.mdp.awsEndpointSync.sync.AwsEndpointSync_Bean.create(Unknown Source)
        at io.quarkus.arc.impl.AbstractSharedContext.createInstanceHandle(AbstractSharedContext.java:113)
        at io.quarkus.arc.impl.AbstractSharedContext$1.get(AbstractSharedContext.java:37)
        at io.quarkus.arc.impl.AbstractSharedContext$1.get(AbstractSharedContext.java:34)
        at io.quarkus.arc.impl.LazyValue.get(LazyValue.java:26)
        at io.quarkus.arc.impl.ComputingCache.computeIfAbsent(ComputingCache.java:69)
        at io.quarkus.arc.impl.AbstractSharedContext.get(AbstractSharedContext.java:34)
        at de.db.mdp.awsEndpointSync.sync.AwsEndpointSync_Bean.get(Unknown Source)
        at de.db.mdp.awsEndpointSync.sync.AwsEndpointSync_Bean.get(Unknown Source)
        at de.db.mdp.awsEndpointSync.AwsEndpointSyncApp_Bean.create(Unknown Source)
        at de.db.mdp.awsEndpointSync.AwsEndpointSyncApp_Bean.create(Unknown Source)
        at io.quarkus.arc.impl.AbstractSharedContext.createInstanceHandle(AbstractSharedContext.java:113)
        at io.quarkus.arc.impl.AbstractSharedContext$1.get(AbstractSharedContext.java:37)
        at io.quarkus.arc.impl.AbstractSharedContext$1.get(AbstractSharedContext.java:34)
        at io.quarkus.arc.impl.LazyValue.get(LazyValue.java:26)
        at io.quarkus.arc.impl.ComputingCache.computeIfAbsent(ComputingCache.java:69)
        at io.quarkus.arc.impl.AbstractSharedContext.get(AbstractSharedContext.java:34)
        at io.quarkus.arc.impl.ClientProxies.getApplicationScopedDelegate(ClientProxies.java:21)
        at de.db.mdp.awsEndpointSync.AwsEndpointSyncApp_ClientProxy.arc$delegate(Unknown Source)
        at de.db.mdp.awsEndpointSync.AwsEndpointSyncApp_ClientProxy.run(Unknown Source)
        at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:130)
        at io.quarkus.runtime.Quarkus.run(Quarkus.java:71)
        at io.quarkus.runtime.Quarkus.run(Quarkus.java:44)
        at de.db.mdp.awsEndpointSync.AwsEndpointSyncApp$Companion.main(AwsEndpointSyncApp.kt:25)
        at de.db.mdp.awsEndpointSync.AwsEndpointSyncApp.main(AwsEndpointSyncApp.kt)
Caused by: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `io.fabric8.kubernetes.client.Config$ExecCredential`: cannot deserialize from Object value (no delegate- or property-based Creator): this appears to be a native image, in which case you may need to configure reflection for the class that is to be deserialized
 at [Source: (BufferedInputStream); line: 1, column: 2]
        at com.fasterxml.jackson.databind.DeserializationContext.reportBadDefinition(DeserializationContext.java:1909)
        at com.fasterxml.jackson.databind.DatabindContext.reportBadDefinition(DatabindContext.java:408)
        at com.fasterxml.jackson.databind.DeserializationContext.handleMissingInstantiator(DeserializationContext.java:1349)
        at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromObjectUsingNonDefault(BeanDeserializerBase.java:1417)
        at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:352)
        at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:185)
        at com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:323)
        at com.fasterxml.jackson.databind.ObjectReader._bindAndClose(ObjectReader.java:2105)
        at com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:1481)
        at io.fabric8.kubernetes.client.utils.Serialization.unmarshal(Serialization.java:240)
        ... 72 more

@geoand
Copy link
Contributor

geoand commented Jan 3, 2023

Great, thanks!

@geoand
Copy link
Contributor

geoand commented Jan 3, 2023

#30153 should fix the issue

gsmet added a commit that referenced this issue Jan 3, 2023
Ensure that k8s client's ExecConfig works properly in native mode
@quarkus-bot quarkus-bot bot added this to the 2.16 - main milestone Jan 3, 2023
@gsmet gsmet modified the milestones: 2.16 - main, 2.15.2.Final Jan 3, 2023
gsmet pushed a commit to gsmet/quarkus that referenced this issue Jan 3, 2023
gsmet pushed a commit to gsmet/quarkus that referenced this issue Jan 4, 2023
ebullient pushed a commit to maxandersen/quarkus that referenced this issue Jan 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/kubernetes kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants