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

Use kubectl for kube-proxy upgrader calls #5609

Merged
merged 1 commit into from
Apr 12, 2023

Conversation

g-gaston
Copy link
Member

@g-gaston g-gaston commented Apr 12, 2023

Description of changes

Before the kube-proxy upgrader (#5345) all API calls to the management cluster came either from kubectl or clusterctl, which both happened to be run in a docker container in the admin machine. This was the first piece of code that introduced the use of Kubernetes Go client directly from the CLI binary. This means that if a user was relying on this internal implementation (explicit interface vs implicit interface), their system could break if it wasn't setup to give the CLI network connectivity to the kind cluster.

This PR "reverts" the addition of that new paradigm by changing the underlying client implementation to use kubectl commands.

Testing

Ran TestCloudStackKubernetes123ManagementClusterUpgradeFromLatest manually upgrading from v0.14.6 to make sure the kube-proxy upgrader still works as expected. (in progress)

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

@eks-distro-bot eks-distro-bot added do-not-merge/work-in-progress size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Apr 12, 2023
@codecov
Copy link

codecov bot commented Apr 12, 2023

Codecov Report

Merging #5609 (9ba81c7) into main (dc16138) will increase coverage by 0.08%.
The diff coverage is 87.72%.

❗ Current head 9ba81c7 differs from pull request most recent head ffc3ec0. Consider uploading reports for the commit ffc3ec0 to get more accurate results

@@            Coverage Diff             @@
##             main    #5609      +/-   ##
==========================================
+ Coverage   73.22%   73.30%   +0.08%     
==========================================
  Files         447      449       +2     
  Lines       37029    37244     +215     
==========================================
+ Hits        27113    27301     +188     
- Misses       8291     8311      +20     
- Partials     1625     1632       +7     
Impacted Files Coverage Δ
pkg/clients/kubernetes/scheme.go 50.00% <ø> (ø)
pkg/providers/snow/snow.go 71.36% <75.00%> (+0.27%) ⬆️
pkg/executables/kubectl.go 57.20% <80.57%> (+1.48%) ⬆️
pkg/clients/kubernetes/unauth.go 91.17% <86.04%> (-8.83%) ⬇️
pkg/clients/kubernetes/client.go 100.00% <100.00%> (ø)
pkg/clients/kubernetes/kubeconfig.go 100.00% <100.00%> (ø)
pkg/clients/kubernetes/kubectl.go 100.00% <100.00%> (ø)
pkg/clustermanager/kube_proxy.go 79.93% <100.00%> (+0.59%) ⬆️
pkg/controller/clientutil/kubernetes.go 100.00% <100.00%> (ø)
pkg/controller/clusterapi.go 100.00% <100.00%> (ø)
... and 1 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@g-gaston g-gaston force-pushed the kube-proxy-to-kubectl branch from 2713785 to ef77f76 Compare April 12, 2023 17:01
@eks-distro-bot
Copy link
Collaborator

eks-distro-bot commented Apr 12, 2023

@g-gaston: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
eks-anywhere-docs-presubmit ef77f76 link true /test eks-anywhere-docs-presubmit
eks-anywhere-cluster-controller-tooling-presubmit ef77f76 link true /test eks-anywhere-cluster-controller-tooling-presubmit

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@g-gaston g-gaston force-pushed the kube-proxy-to-kubectl branch from ef77f76 to a8681e0 Compare April 12, 2023 17:06
@g-gaston g-gaston changed the title [WIP] Use kubectl for kube-proxy upgrader calls Use kubectl for kube-proxy upgrader calls Apr 12, 2023
@g-gaston
Copy link
Member Author

/hold while we run some manual tests

return c.kubectl.Get(ctx, resourceType, kubeconfig, list)
}

// Create saves the object obj in the Kubernetes cluster.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// Create saves the object obj in the Kubernetes cluster.
// Create creates the object obj in the Kubernetes cluster.

Copy link
Member Author

Choose a reason for hiding this comment

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

I would prefer to keep save since it avoids using the same word contained in the method name. If not, the description becomes a bit redundant.

Also:
https://github.com/kubernetes-sigs/controller-runtime/blob/main/pkg/client/interfaces.go#L64

return nil, err
}
return kubeadmControlPlane, nil
}

// CAPIKubeadmControlPlaneKey generates an ObjectKey for the CAPI Kubeadm control plane owned by
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't this method belong to clusterapi package?

Copy link
Member Author

Choose a reason for hiding this comment

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

That's not a bad idea
fine if I take a follow up?

return apiObj.GetName()
}

func newNotFoundErrorForTypeAndName(resourceType, name string) error {
Copy link
Member

Choose a reason for hiding this comment

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

does this work for x.y.apiversion?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah. In fact that's the case where it works best

Before the kube-proxy upgrader
(aws#5345) all API calls to the
management cluster came either from kubectl or clusterctl, which both
happened to be run in a docker container in the admin machine. This was
the first piece of code that introduced the use of Kubernetes Go client
directly from the CLI binary. This means that if a user was relying on
this internal implementation (explicit interface vs implicit interface),
their system could break if it wasn't setup to give the CLI network
connectivity to the kind cluster.

This PR "reverts" the addition of that new paradigm byt changing the
underlying client implementation to use kubectl commands.
@g-gaston g-gaston force-pushed the kube-proxy-to-kubectl branch from e4900c6 to ffc3ec0 Compare April 12, 2023 22:32
@g-gaston
Copy link
Member Author

/unhold

@jiayiwang7
Copy link
Member

/lgtm

@g-gaston
Copy link
Member Author

/approve

@eks-distro-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: g-gaston

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@eks-distro-bot eks-distro-bot merged commit 334b084 into aws:main Apr 12, 2023
@g-gaston
Copy link
Member Author

/cherry-pick release-0.15

@eks-distro-pr-bot
Copy link
Contributor

@g-gaston: new pull request created: #5631

In response to this:

/cherry-pick release-0.15

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@eks-distro-pr-bot
Copy link
Contributor

@g-gaston: new pull request could not be created: failed to create pull request against aws/eks-anywhere#release-0.15 from head eks-distro-pr-bot:cherry-pick-5609-to-release-0.15: status code 422 not one of [201], body: {"message":"Validation Failed","errors":[{"resource":"PullRequest","code":"custom","message":"A pull request already exists for eks-distro-pr-bot:cherry-pick-5609-to-release-0.15."}],"documentation_url":"https://docs.github.com/rest/reference/pulls#create-a-pull-request"}

In response to this:

/cherry-pick release-0.15

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

1 similar comment
@eks-distro-pr-bot
Copy link
Contributor

@g-gaston: new pull request could not be created: failed to create pull request against aws/eks-anywhere#release-0.15 from head eks-distro-pr-bot:cherry-pick-5609-to-release-0.15: status code 422 not one of [201], body: {"message":"Validation Failed","errors":[{"resource":"PullRequest","code":"custom","message":"A pull request already exists for eks-distro-pr-bot:cherry-pick-5609-to-release-0.15."}],"documentation_url":"https://docs.github.com/rest/reference/pulls#create-a-pull-request"}

In response to this:

/cherry-pick release-0.15

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

ddjjia pushed a commit to ddjjia/eks-anywhere that referenced this pull request Jun 8, 2023
Before the kube-proxy upgrader
(aws#5345) all API calls to the
management cluster came either from kubectl or clusterctl, which both
happened to be run in a docker container in the admin machine. This was
the first piece of code that introduced the use of Kubernetes Go client
directly from the CLI binary. This means that if a user was relying on
this internal implementation (explicit interface vs implicit interface),
their system could break if it wasn't setup to give the CLI network
connectivity to the kind cluster.

This PR "reverts" the addition of that new paradigm byt changing the
underlying client implementation to use kubectl commands.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants