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

AoT version with AKS kubelogin throws exception on creating configuration #1602

Open
dn-ark opened this issue Dec 19, 2024 · 3 comments
Open

Comments

@dn-ark
Copy link

dn-ark commented Dec 19, 2024

Describe the bug
Using KubernetesClient.Aot throws an exception when trying to create a configuration via KubernetesClientConfiguration.BuildConfigFromConfigFile() that utilizes AKS kubelogin.

Exception is

k8s.Exceptions.KubeConfigException: 'external exec failed due to uncaught exception: System.ArgumentNullException: Value cannot be null. (Parameter 'jsonTypeInfo')
   at System.Text.Json.ThrowHelper.ThrowArgumentNullException(String parameterName)
   at System.Text.Json.JsonSerializer.Deserialize(String json, JsonTypeInfo jsonTypeInfo)
   at k8s.KubernetesJson.Deserialize[TValue](String json, JsonSerializerOptions jsonSerializerOptions)
   at k8s.KubernetesClientConfiguration.ExecuteExternalCommand(ExternalExecution config)'

Kubernetes C# SDK Client Version
15.0.1

Server Kubernetes Version
1.30.6

Dotnet Runtime Version
.NET 9

To Reproduce

  1. Use kubelogin example as a reference
  2. First, confirm that regular KubernetesClient version 15.0.1 works correct when calling KubernetesClientConfiguration.BuildConfigFromConfigFile()
  3. Now change the package to KubernetesClient.Aot version 15.0.1 and try again - get an exception

Expected behavior
Configuration should be created successfully.

KubeConfig
Please refer to the linked sample but here's relevant users section from my config specifically:

users:
- name: clusterUser_<name>
  user:
    exec:
      apiVersion: client.authentication.k8s.io/v1beta1
      args:
      - get-token
      - --environment
      - AzurePublicCloud
      - --server-id
      - <server_id>
      - --client-id
      - <client_id>
      - --tenant-id
      - <tenant_id>
      - --login
      - devicecode
      command: kubelogin
      env: null
      installHint: |2

        kubelogin is not installed which is required to connect to AAD enabled cluster.

        To learn more, please go to https://aka.ms/aks/kubelogin
      interactiveMode: IfAvailable
      provideClusterInfo: false

Where do you run your app with Kubernetes SDK:

  • OS: Windows 11 Pro
  • Environment: Launching project with debug in Visual Studio

Additional context

@dn-ark
Copy link
Author

dn-ark commented Dec 19, 2024

I guess it could be related to this one as well: #1598

@tg123
Copy link
Member

tg123 commented Dec 19, 2024

yup this is something dynamic, so not fully supported in aot

@IvanJosipovic
Copy link
Contributor

This should be fixable with a PR by setting the jsonTypeInfo on

var responseObject = KubernetesJson.Deserialize<ExecCredentialResponse>(process.StandardOutput.ReadToEnd());

[JsonSerializable(typeof(ExecCredentialResponse))]
internal partial class ExecCredentialResponseContext : JsonSerializerContext
{
}

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

3 participants