-
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
Minikube docker driver: customize exposed ports #8398
Comments
I don't think there is a (user-accessible) way to add ports to a running container in Docker:
You can work around it with // control plane specific options
params.PortMappings = append(params.PortMappings, oci.PortMapping{
ListenAddress: oci.DefaultBindIPV4,
ContainerPort: int32(params.APIServerPort),
},
oci.PortMapping{
ListenAddress: oci.DefaultBindIPV4,
ContainerPort: constants.SSHPort,
},
oci.PortMapping{
ListenAddress: oci.DefaultBindIPV4,
ContainerPort: constants.DockerDaemonPort,
},
oci.PortMapping{
ListenAddress: oci.DefaultBindIPV4,
ContainerPort: constants.RegistryAddonPort,
},
) There was no such flag before either, but VirtualBox looks more flexible than Docker ? The situation is even worse on Docker Desktop, because there you have VM network too. |
Indeed, ports have to be exposed when containers are created (afaik). With Virtualbox it works fine since it is possible to create port forwarding rules, which is a great match in my use case. I have multiple ingresses, but also need to expose additional ports |
You could of course just continue to use the VirtualBox driver |
@afbjorklund yes of course, that what I'm doing for now. I was actually not aware of the switch of the default to the docker driver; I've probably missed it in the release notes. The thing is that I'd hope to waste less resources if I could make use of the docker driver instead of the virtualbox one. But indeed, for now at least I can keep on working ;-)) |
@afbjorklund I'd like to access the k8s API that is running on the minikube container in more interfaces than just loopback. Inspecting the minikube container I saw that the API port is only exposed on the loopback interface:
Can an option to configure the "HostIp" field be provided so I can set it to match the IP of the desired interface? EDIT: It can be done on docker when starting the container (https://docs.docker.com/config/containers/container-networking/#published-ports) |
@bolipereira : We should provide some better ingress options of exposing apps, but I'm not sure sure about the apiserver itself Maybe you could describe your use case - in a new issue ? Is it something similar to the generic driver #4733 (for none) |
@afbjorklund I'll open a new issue if you think it makes sense to support my use case:
Currently, I need to SSH into the machine running the cluster to interact with the k8s API. What I'd like to do is issue kubectl commands to the cluster without having to access it remotely with SSH. That would be possible by exposing the apiserver port on the host. I don't think enabling it by default would be sensible, but I feel that I should have the option to expose the container ports on a network interface other than loopback. |
So if I understand you correctly, it works OK on the workstation but you also want to access it externally (from the laptop). This scenario is slightly different from the one that I described, where kubernetes is running on a dedicated Linux server. |
@afbjorklund Yes, that's basically it. Do you think adding this feature makes sense? Should I open another issue if that's the case? |
That seems like a good feature to add |
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
Stale issues rot after 30d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
/remove-lifecycle rotten @toonvanstrijp how does #9404 help this situation? |
@AskAlice re-reading this issue I’m not definitely sure my PR fixes this. my PR let’s you enable extra ports to be exposed when using the docker driver. So if you’re using the docker driver and add the apiserverport to the ports arg when creating the cluster it should be exposed and ready to use for you. or am I missing something here? |
Not sure if this is exactly what you're asking, but if you only need to forward some exposed container ports out of Minikube so they are accessible on your host machine, you can run an SSH tunnel. This is useful if you are using Minikube as a Docker Desktop replacement and aren't running K8s services. For example, forward traffic on exposed container port 8000 to the host machine on port 8000:
|
This was implemented with #9404, closing |
I'd like to know if there's currently a way to customize the ports that are exposed by the minikube container when running on Linux with the Docker driver?
Previously, I was using the virtualbox driver and used the following to expose ports I needed to access:
The text was updated successfully, but these errors were encountered: