Skip to content

Malformed response when requesting EKS token from gov-cloud (affects >=2.10.4) #7719

@timfallmk

Description

@timfallmk

Describe the bug

After updating to cli v 2.10.4 (and continuing in 2.11.0) we get the following response from our clusters running in Gov-Cloud

kubectl get pods
Unable to connect to the server: getting credentials: decoding stdout: couldn't get version/kind; json parse error: json: cannot unmarshal array into Go value of type struct { APIVersion string "json:\"apiVersion,omitempty\""; Kind string "json:\"kind,omitempty\"" }

We get the same response from every kubectl request.

Narrowed the problem down to the authentication step callout to aws eks get-token. With debug logs on, error occurs after the following lines:

host:sts.us-gov-west-1.amazonaws.com
x-k8s-aws-id:farpoint

host;x-k8s-aws-id
<earlier call stack>
<snip>
2023-03-03 13:43:15,726 - MainThread - botocore.auth - DEBUG - StringToSign:
AWS4-HMAC-SHA256
20230303T214315Z
20230303/us-gov-west-1/sts/aws4_request
<snip>
2023-03-03 13:43:15,726 - MainThread - botocore.auth - DEBUG - Signature:
<snip>

A few key details:

  • Region: us-gov-west-1
  • kubectl version:
Client Version: v1.25.6
Kustomize Version: v4.5.7
Server Version: v1.25.6-eks-48e63af
  • Clusters are EKS running 1.25 and provisioned with eksctl
  • We use aws sso for account auth and token generation

Confirmed a few things:

  • Does not happen when using fixed IAM credentials, either via aws or aws-iam-authenticator
  • Does not happen for cli <=2.10.3

I can't seem to get any more debug logs so I can't dig further, but feels like a malformed response somewhere? Naked aws eks get-token seems to return expected results.

Expected Behavior

kubectl command returns data

Current Behavior

kubectl get pods
Unable to connect to the server: getting credentials: decoding stdout: couldn't get version/kind; json parse error: json: cannot unmarshal array into Go value of type struct { APIVersion string "json:\"apiVersion,omitempty\""; Kind string "json:\"kind,omitempty\"" }

Happens for all subcommands checked (that interact with the server)

Reproduction Steps

Needs:

  • EKS cluster 1.25 in Gov-Cloud region
  • AWS SSO setup and used as login method

Doesn't work:

asdf shell awscli 2.10.4/2.11.0/latest
kubectl X
Unable to connect to the server: getting credentials: decoding stdout: couldn't get version/kind; json parse error: json: cannot unmarshal array into Go value of type struct { APIVersion string "json:\"apiVersion,omitempty\""; Kind string "json:\"kind,omitempty\"" }

Does work:

asdf shell awscli 2.10.3 (or before)
kubectl X
<expected output>

Possible Solution

Smells like a malformed HTML response is trying to get unmarshalled (just to my 👃 )
Downgrading to 2.10.3 or earlier is a viable workaround for now

Additional Information/Context

AWS SSO connected to Azure AD IdP

CLI version used

2.10.4+

Environment details (OS name and version, etc.)

macOS 13.2.1, kubectl and awscli via homebrew

Metadata

Metadata

Assignees

Labels

bugThis issue is a bug.eks-get-tokenp1This is a high priority issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions