Skip to content

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

@dn-ark

Description

@dn-ark

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    lifecycle/rottenDenotes an issue or PR that has aged beyond stale and will be auto-closed.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions