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

Deprecate Kubernetes client API version v1alpha1 #6476

Merged

Conversation

micahhausler
Copy link
Member

@micahhausler micahhausler commented Oct 13, 2021

Kubernetes has deprecated v1alpha1, v1beta1 has been available since Kubernetes
v1.11 (kubernetes/kubernetes#64482), and EKS currently supports Kubernetes
versions v1.16 through v1.21. This is a breaking change for clients running
versions v1.10 and older, which haven't been supported by EKS since September
2019.

"aws eks get-token" now respects the KUBERNETES_EXEC_INFO environment
variable and conservatively falls back to v1alpha1, which is supported
by Kubernetes versions 1.10 through 1.22 (released upstream August 2021, to be
released by EKS in Q4 2021). It also now supports clients requesting credentials
using the "v1beta1" and "v1" versions.

"aws eks update-kubeconfig" now writes "v1beta1" in the kubeconfig which
will be supported by Kubernetes until 1.29 (aproximately December 2023).
At or around that date, we can change the default version written to
kubeconfigs to "v1"

Signed-off-by: Micah Hausler mhausler@amazon.com

Issue #, if available:

Description of changes:

See above

cc: @nckturner @sgundapu

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@codecov-commenter
Copy link

codecov-commenter commented Oct 13, 2021

Codecov Report

Merging #6476 (320f898) into develop (e564532) will increase coverage by 0.01%.
The diff coverage is 100.00%.

@@             Coverage Diff             @@
##           develop    #6476      +/-   ##
===========================================
+ Coverage    92.85%   92.87%   +0.01%     
===========================================
  Files          204      204              
  Lines        16310    16344      +34     
===========================================
+ Hits         15145    15179      +34     
  Misses        1165     1165              
Impacted Files Coverage Δ
awscli/customizations/eks/get_token.py 100.00% <100.00%> (ø)
awscli/customizations/eks/update_kubeconfig.py 97.93% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e564532...320f898. Read the comment docs.

awscli/customizations/eks/get_token.py Outdated Show resolved Hide resolved
@@ -143,3 +144,105 @@ def test_url_different_partition(self):
expected_endpoint='sts.cn-north-1.amazonaws.com.cn',
expected_signing_region='cn-north-1'
)

def test_api_version_discovery_deprecated(self):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When do these tests get run?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They're run by pytest. See scripts/ci/run-tests

def test_api_version_discovery_deprecated(self):
os.environ["KUBERNETES_EXEC_INFO"] = '{"kind":"ExecCredential","apiVersion":"client.authentication.k8s.io/v1alpha1","spec":{"interactive":true}}'
cmd = 'eks get-token --cluster-name %s' % self.cluster_name
stdout, stderr, _ = self.run_cmd(cmd)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this testing with an external kubectl binary? If so, what version?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this is called just by the test runner.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be cool if we had an integration test that used client-go in some capacity, even if it was only a manual test initially. Not a blocker.

Copy link
Contributor

@sgundapu sgundapu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kdaily kdaily added the needs-review This issue or pull request needs review from a core team member. label Nov 6, 2021
@kdaily kdaily added customization Issues related to CLI customizations (located in /awscli/customizations) eks-kubeconfig labels Dec 14, 2021
@stealthycoin
Copy link
Contributor

fixes #6308

@kdaily kdaily linked an issue May 4, 2022 that may be closed by this pull request
2 tasks
@kdaily kdaily added ready-for-review and removed needs-review This issue or pull request needs review from a core team member. labels May 4, 2022
@kdaily kdaily added review bug This issue is a bug. and removed ready-for-review labels May 5, 2022
del os.environ["KUBERNETES_EXEC_INFO"]

def test_api_version_discovery_malformed(self):
os.environ["KUBERNETES_EXEC_INFO"] = '{{"kind":"ExecCredential","apiVersion":"client.authentication.k8s.io/v1alpha1","spec":{"interactive":true}}'
Copy link
Contributor

@justindho justindho May 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should be using a copy of the environment variables here (and the other tests) instead (i.e., os.environ.copy()). The tests are run in parallel, and directly modifying envvars (os.environ["KUBERNETES_EXEC_INFO"] = ..., del os.environ["KUBERNETES_EXEC_INFO"]) may interfere with other tests running in parallel.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've used this in the past for setting env vars: #6476 (comment)

Copy link
Contributor

@kyleknap kyleknap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine. All of my feedback was related to Python-specifics and codebase usage/organization.

awscli/customizations/eks/get_token.py Outdated Show resolved Hide resolved
awscli/customizations/eks/get_token.py Outdated Show resolved Hide resolved
awscli/customizations/eks/get_token.py Outdated Show resolved Hide resolved
awscli/customizations/eks/get_token.py Outdated Show resolved Hide resolved
awscli/customizations/eks/get_token.py Outdated Show resolved Hide resolved
tests/functional/eks/test_get_token.py Outdated Show resolved Hide resolved
tests/functional/eks/test_get_token.py Outdated Show resolved Hide resolved
@@ -13,6 +13,8 @@
import base64
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would also be great if we can get a changelog for this feature? You can use the scripts/new-change script to generate a changelog entry. For the type field, I'd recommend setting the type to enhancement and the category to eks get-token

awscli/customizations/eks/get_token.py Outdated Show resolved Hide resolved
tests/functional/eks/test_get_token.py Outdated Show resolved Hide resolved
awscli/customizations/eks/get_token.py Outdated Show resolved Hide resolved
awscli/customizations/eks/get_token.py Outdated Show resolved Hide resolved
micahhausler and others added 2 commits May 5, 2022 16:36
Kubernetes has deprecated v1alpha1, v1beta1 has been available since Kubernetes
v1.11 (kubernetes/kubernetes#64482), and EKS currently supports Kubernetes
versions v1.16 through v1.21. This is a breaking change for clients running
versions v1.10 and older, which haven't been supported by EKS since September
2019.

"aws eks get-token" now respects the KUBERNETES_EXEC_INFO environment
variable and conservatively falls back to v1alpha1, which is supported
by Kubernetes versions 1.10 through 1.22 (released upstream August 2021, to be
released by EKS in Q4 2021). It also now supports "v1beta1" and "v1".

"aws eks update-kubeconfig" now writes "v1beta1" in the kubeconfig which
will be supported by Kubernetes until 1.29 (aproximately December 2023).
At or around that date, we can change the default version written to
kubeconfigs to "v1"

Signed-off-by: Micah Hausler <mhausler@amazon.com>
@justindho justindho force-pushed the eks-token-api-version-deprecation branch from 5ea108a to 18fdfa3 Compare May 5, 2022 23:39
Copy link
Contributor

@kyleknap kyleknap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Just had some more suggestions.

.changes/next-release/enhancement-eksgettoken-91863.json Outdated Show resolved Hide resolved
tests/functional/eks/test_get_token.py Outdated Show resolved Hide resolved
tests/functional/eks/test_get_token.py Outdated Show resolved Hide resolved
awscli/customizations/eks/get_token.py Outdated Show resolved Hide resolved
@justindho justindho force-pushed the eks-token-api-version-deprecation branch from 3a2c6d6 to 3124795 Compare May 6, 2022 00:26
Copy link
Contributor

@kyleknap kyleknap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! 🚢

@nckturner
Copy link

LGTM

]

ERROR_MSG_TPL = (
"{0} KUBERNETES_EXEC_INFO, defaulting to {1}. This is likely a "

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it say "Error reading KUBERNETES_EXEC_INFO" instead of just "KUBERNETES_EXEC_INFO"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will say Error parsing to start the sentence as the variable is being used as a template. Tests also confirm that too: https://github.com/aws/aws-cli/pull/6476/files#diff-ee0c03e30582b485e61dba3f70f956a6024118bdffe8657c476fee7f9ac655afR194.

@zawachte-c
Copy link

@micahhausler I am hitting an issue using kubectl 1.19 where it doesn't set KUBERNETES_EXEC_INFO. So the following flow is broken...

# update to latest aws-cli
 aws eks update-kubeconfig
 kubectl get pods <= with kubectl 1.19

This returns the following error:

Empty KUBERNETES_EXEC_INFO, defaulting to client.authentication.k8s.io/v1alpha1. This is likely a bug in your Kubernetes client. Please update your Kubernetes client.
Unable to connect to the server: getting credentials: exec plugin is configured to use API version client.authentication.k8s.io/v1beta1, plugin returned version client.authentication.k8s.io/v1alpha1

kubectl >- 1.20 works as expected. I still have some 1.19 clusters running so i kept kubectl at 1.19, but I can update kubectl, but since eks still supports kubernetes 1.19 I figured it was worth a post.

@micahhausler
Copy link
Member Author

@zawachte-c thank you! Take a look at #6940, as this should resolve the <= 1.19 problems

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. customization Issues related to CLI customizations (located in /awscli/customizations) eks-kubeconfig review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CLI versions 1.20.9 and 2.2.24 shipped a breaking change in a dot release
10 participants