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

🐛 Delegate CAPD port selection to the container runtime #8642

Conversation

killianmuldoon
Copy link
Contributor

Delegate port selection to the container runtime by passing 0 directly into the runtime on container creation.

Related to #8641

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels May 11, 2023
@killianmuldoon

This comment was marked as outdated.

@k8s-ci-robot

This comment was marked as duplicate.

@killianmuldoon
Copy link
Contributor Author

/test pull-cluster-api-e2e-full-main

@killianmuldoon killianmuldoon changed the title [WIP] 🐛 Delegate CAPD port selection to the container runtime 🐛 Delegate CAPD port selection to the container runtime May 11, 2023
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 11, 2023
@killianmuldoon
Copy link
Contributor Author

Passing e2e full.

@sbueringer @chrischdi - WDYT about merging this to see if docker is better at picking an open port for the nodes in the Cluster?

@killianmuldoon
Copy link
Contributor Author

Should be cherry picked to help with flakes on older supported branches.

/cherry-pick release-1.3

@k8s-infra-cherrypick-robot

@killianmuldoon: once the present PR merges, I will cherry-pick it on top of release-1.3 in a new PR and assign it to you.

In response to this:

Should be cherry picked to help with flakes on older supported branches.

/cherry-pick release-1.3

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.

@killianmuldoon
Copy link
Contributor Author

/cherry-pick release-1.4

@k8s-infra-cherrypick-robot

@killianmuldoon: once the present PR merges, I will cherry-pick it on top of release-1.4 in a new PR and assign it to you.

In response to this:

/cherry-pick release-1.4

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.

@chrischdi
Copy link
Member

That should be way more stable 👍

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 11, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 74da53540a462de29945e5ec26f3bf8dd4306917

@@ -56,15 +54,6 @@ type nodeCreateOpts struct {

// CreateControlPlaneNode will create a new control plane container.
func (m *Manager) CreateControlPlaneNode(ctx context.Context, name, image, clusterName, listenAddress string, port int32, mounts []v1alpha4.Mount, portMappings []v1alpha4.PortMapping, labels map[string]string, ipFamily clusterv1.ClusterIPFamily) (*types.Node, error) {
Copy link
Member

@sbueringer sbueringer May 12, 2023

Choose a reason for hiding this comment

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

I found this comment for HostPort in the kind API:

	// NOTE: if you set the special value of `-1` then the node backend
	// (docker, podman...) will be left to pick the port instead.
	// This is potentially useful for remote hosts, BUT it means when the container
	// is restarted it will be randomized. Leave this unset to allow kind to pick it.

This got me thinking about what happens in our case when Docker picks a random port. So I tried what happens with the variant on this PR vs main.

This PR: After restart containers get a new random port
main: Ports are stable across restarts

As far as I can see we only have host ports for the haproxy and the control plane containers.

Restarting a control plane node breaks connectivity to the apiserver for a few seconds but it recovers. So that's fine.

Restarting haproxy does not break connectivity from mgmt to workload cluster (i.e. the kubeconfig we store still works (endpoint: https://172.18.0.4:6443)). It only breaks the kubeconfig from kind get kubeconfig (endpoint: https://0.0.0.0:32776)

So overall this only breaks kubeconfigs from kind after haproxy restarts.

For me this tradeoff is fine.

It would be just really good to document this behavior that we now have in combination with the impact it has (as I described here). Maybe godoc comments for the CreateControlPlaneNode and CreateExternalLoadBalancerNode funcs. "If the port is set to 0, the host port will be picked by the container runtime and is not stable across container restarts. This has the following consequences ..."

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for finding that - it seems like a reasonable tradeoff, given these clusters aren't production ready and users will be able to fix the kubeconfig if they really need to.

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good!

Signed-off-by: killianmuldoon <kmuldoon@vmware.com>
@killianmuldoon killianmuldoon force-pushed the pr-change-docker-port-selection branch from b6e99a4 to f726a2e Compare May 12, 2023 11:15
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 12, 2023
Copy link
Member

@chrischdi chrischdi left a comment

Choose a reason for hiding this comment

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

/lgtm

Just thought about if we should also add a similar note somewhere around here in quickstart:

<aside class="note warning">

But OK for me without having it.

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 12, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 4612b3dd8c8d2a72deb89262be3e71685b05736c

@sbueringer
Copy link
Member

/lgtm

Just thought about if we should also add a similar note somewhere around here in quickstart:

<aside class="note warning">

But OK for me without having it.

I think it's fine. restarting the container is an edge case

@sbueringer
Copy link
Member

/lgtm
/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sbueringer

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 12, 2023
@k8s-ci-robot k8s-ci-robot merged commit 783bf61 into kubernetes-sigs:main May 12, 2023
@k8s-ci-robot k8s-ci-robot added this to the v1.5 milestone May 12, 2023
@k8s-infra-cherrypick-robot

@killianmuldoon: new pull request created: #8654

In response to this:

Should be cherry picked to help with flakes on older supported branches.

/cherry-pick release-1.3

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.

@k8s-infra-cherrypick-robot

@killianmuldoon: new pull request created: #8655

In response to this:

/cherry-pick release-1.4

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.

@johannesfrey
Copy link
Contributor

/area provider/infrastructure-docker

@k8s-ci-robot k8s-ci-robot added the area/provider/infrastructure-docker Issues or PRs related to the docker infrastructure provider label Jun 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/provider/infrastructure-docker Issues or PRs related to the docker infrastructure provider cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants