-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
new flag --listen-apiserver-port for docker/podman: allow user to specify host port for api-server #11070
Conversation
Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA. It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.
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. |
Hi @zhan9san. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: zhan9san The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Can one of the admins verify this patch? |
Hi, |
a25c47a
to
da0cdb9
Compare
@zhan9san how would this work with multiple clusters ? wouldn't they conflict if they have two clusters on same machine? |
publish := fmt.Sprintf("--publish=%s::%d", pm.ListenAddress, pm.ContainerPort) | ||
// example --publish=127.0.0.17:8443:8443 will get a fixed host port for 8443 | ||
publish := "" | ||
if pm.HostPort != 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about add a Check here to verify this port is Free and Usable and if it is not Free and usable return an error to the user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's OK.
I'll add this validation based on what docker does.
@zhan9san are you still working on this ? |
cmd/minikube/cmd/start.go
Outdated
if err != nil { | ||
exit.Message(reason.Usage, "Sorry, the port provided with the --listen-apiserver-port flag is already allocated: {{.listenAPIServerPort}}.", out.V{"listenAPIServerPort": listenAPIServerPort}) | ||
} | ||
err = ln.Close() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn’t this need to be defer ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pointing it out.
The code snippet above is replaced by defer
.
By introducing defer statements we can ensure that the socket is always closed.
/ok-to-test |
kvm2 driver with docker runtime
Times for minikube start: 48.1s 49.2s 47.3s 46.5s 51.7s Times for minikube ingress: 34.3s 34.3s 35.2s 38.2s 34.2s docker driver with docker runtime
Times for minikube start: 22.9s 21.1s 21.6s 21.3s 21.7s Times for minikube ingress: 28.5s 28.5s 33.5s 28.5s 37.0s docker driver with containerd runtime |
kvm2 driver with docker runtime
Times for minikube start: 48.0s 46.8s 48.7s 50.3s 51.0s Times for minikube ingress: 35.2s 35.3s 34.8s 34.4s 35.2s docker driver with docker runtime
Times for minikube ingress: 30.0s 29.5s 36.5s 28.0s 29.5s Times for minikube start: 22.7s 21.5s 21.0s 22.7s 21.7s docker driver with containerd runtime |
Hi @medyagh I'd like to create another PR about FAQ document instead of adding redundant logic in source code. #11193 and #9404 bring me back to considering whether #11070 is necessary. Please let me know what you think. Here is the test of
test.yml
|
if err != nil { | ||
exit.Message(reason.Usage, "Sorry, the port provided with the --listen-apiserver-port flag is already allocated: {{.listenAPIServerPort}}.", out.V{"listenAPIServerPort": listenAPIServerPort}) | ||
} | ||
defer ln.Close() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this defer needs to happen before Exit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @medyagh
Thanks so much for your time.
If it goes into exit.Message
, that means the socket wouldn't be created. Do we still need to modify this snippet?
You're far more familiar to Golang that me. I referred the logic in this file, example_test.go, at line 23.
Besides, I noticed #9404 has achieved this feature. The only drawback is that #9404 exposes one more random port.
Should we still work on this feature, --listen-apiserver-port
?
Please let me know what you think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zhan9san You are correct about defer
, if an error is returned no action is required on the socket.
@zhan9san: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. 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. |
It seems there are some issues in CI workflow. |
@zhan9san: PR needs rebase. 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. |
Is anyone still working on this? If not I can try to drive it forward. We configure our developer machines via ansible and the dynamic k8s port means we have to do a lookup instead of using a fixed value. Not the end of the world, but would be much easier to use a fixed port. |
Hi @marwatk Could you please verify does this workaround satisfy your requirement? |
@zhan9san, thanks for the suggestion. I tried that first and while it works for communication it still puts the random port in |
Hi @marwatk Could you please provide the minikube version and kubeconfig? I tried again(v1.22.0), it does show the fixed port, but internal IP address in apiserver. As |
@zhan9san, I'm on 1.22: $ minikube start \
> --driver=docker \
> --embed-certs \
> --ports=80:80 \
> --ports=443:443 \
> --ports=42376:2376 \
> --ports=48443:8443
😄 minikube v1.22.0 on Ubuntu 18.04
✨ Using the docker driver based on user configuration
👍 Starting control plane node minikube in cluster minikube
🚜 Pulling base image ...
🔥 Creating docker container (CPUs=2, Memory=12800MB) ...
❗ This container is having trouble accessing https://k8s.gcr.io
💡 To pull new external images, you may need to configure a proxy: https://minikube.sigs.k8s.io/docs/reference/networking/proxy/
🐳 Preparing Kubernetes v1.21.2 on Docker 20.10.7 ...
▪ Generating certificates and keys ...
▪ Booting up control plane ...
▪ Configuring RBAC rules ...
🔎 Verifying Kubernetes components...
▪ Using image gcr.io/k8s-minikube/storage-provisioner:v5
🌟 Enabled addons: storage-provisioner, default-storageclass
🏄 Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default
$ cat ~/.kube/config
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: <SNIP>
extensions:
- extension:
last-update: Thu, 09 Sep 2021 12:34:39 MDT
provider: minikube.sigs.k8s.io
version: v1.22.0
name: cluster_info
server: https://127.0.0.1:49154 <---note the 49154 instead of 48443 here
name: minikube
<SNIP> |
Hi @marwatk I run the exactly the same command with you, but still cannot reproduce your issue. Could you please rename/move current kubeconfig and re-run Once it is done, run $ docker port minikube
8443/tcp -> 0.0.0.0:48443
8443/tcp -> :::48443
8443/tcp -> 127.0.0.1:49313
22/tcp -> 127.0.0.1:49317
2376/tcp -> 127.0.0.1:49316
2376/tcp -> 0.0.0.0:42376
2376/tcp -> :::42376
32443/tcp -> 127.0.0.1:49314
443/tcp -> 0.0.0.0:443
443/tcp -> :::443
5000/tcp -> 127.0.0.1:49315
80/tcp -> 0.0.0.0:80
80/tcp -> :::80 |
Sure enough, deleting my At any rate, we're moving to Thanks for your followup! |
Hi,
This change will have apiserver exposed on a fixed port, even though minikube is restarted.
Would it be possible to review and approve this change?
Fixes #11041
Thanks