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

feat: support exposing clusterIP services via minikube service #17877

Merged
merged 1 commit into from
Apr 3, 2024

Conversation

ComradeProgrammer
Copy link
Member

@ComradeProgrammer ComradeProgrammer commented Jan 1, 2024

support exposing clusterIP services via minikube service

ClusterIP cannot be visited outside the cluster, because cluster IP is a virtual private IP. However, we can visit clusterIP on one of the node of the cluster, because kube-proxy generate IPtables on these nodes for clusterIPs. This is how minikube implement port forwarding for "minikube service" on those drivers which requires port forwarding.

This time the same method is used to expose clusterIP service.

Happy New year. I am back

FIX #17283

Before:

./minikube service nginx-service
|-----------|---------------|-------------|--------------|
| NAMESPACE |     NAME      | TARGET PORT |     URL      |
|-----------|---------------|-------------|--------------|
| default   | nginx-service |             | No node port |
|-----------|---------------|-------------|--------------|
😿  service default/nginx-service has no node port

After:

./minikube service nginx-service
|-----------|---------------|-------------|--------------|
| NAMESPACE |     NAME      | TARGET PORT |     URL      |
|-----------|---------------|-------------|--------------|
| default   | nginx-service |             | No node port |
|-----------|---------------|-------------|--------------|
😿  service default/nginx-service has no node port
❗  The following services are clusterIP services: [default/nginx-service], which are supposed to be accessable inside the cluster only. Minikube allows you to access them by opening an SSH tunnel, which is only for test purpose and must not be used in production environment
🏃  Starting tunnel for service nginx-service.
|-----------|---------------|-------------|------------------------|
| NAMESPACE |     NAME      | TARGET PORT |          URL           |
|-----------|---------------|-------------|------------------------|
| default   | nginx-service |             | http://127.0.0.1:53234 |
|-----------|---------------|-------------|------------------------|
🎉  Opening service default/nginx-service in default browser...
❗  Because you are using a Docker driver on darwin, the terminal needs to be open to run it.

It has been tested on both Ubuntu which does not need port forward if it is a clusterIP service, and MacOS which needs it even it is not a clusterIP service.

The example yaml configuration used for this test:

apiVersion: v1
kind: Pod
metadata:
  name: nginx
  labels:
    app.kubernetes.io/name: proxy
spec:
  containers:
  - name: nginx
    image: nginx:stable
    ports:
      - containerPort: 80
        name: http-web-svc

---
apiVersion: v1
kind: Service
metadata:
  name: nginx-service
spec:
  selector:
    app.kubernetes.io/name: proxy
  ports:
  - name: name-of-service-port
    protocol: TCP
    port: 80
    targetPort: http-web-svc

P.S. Chinese translation for this part is also added

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jan 1, 2024
@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jan 1, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @ComradeProgrammer. 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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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.

@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jan 1, 2024
@minikube-bot
Copy link
Collaborator

Can one of the admins verify this patch?

cmd/minikube/cmd/service.go Outdated Show resolved Hide resolved
@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 12, 2024
cmd/minikube/cmd/service.go Outdated Show resolved Hide resolved
@k8s-ci-robot k8s-ci-robot removed the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 12, 2024
@medyagh
Copy link
Member

medyagh commented Mar 28, 2024

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Mar 28, 2024
@minikube-pr-bot
Copy link

kvm2 driver with docker runtime

+----------------+----------+---------------------+
|    COMMAND     | MINIKUBE | MINIKUBE (PR 17877) |
+----------------+----------+---------------------+
| minikube start | 52.6s    | 52.6s               |
| enable ingress | 27.4s    | 27.0s               |
+----------------+----------+---------------------+

Times for minikube start: 52.3s 51.5s 53.6s 51.0s 54.8s
Times for minikube (PR 17877) start: 51.0s 52.0s 52.7s 57.6s 49.8s

Times for minikube ingress: 27.5s 27.5s 27.2s 27.5s 27.1s
Times for minikube (PR 17877) ingress: 27.6s 28.0s 28.6s 24.1s 26.5s

docker driver with docker runtime

+----------------+----------+---------------------+
|    COMMAND     | MINIKUBE | MINIKUBE (PR 17877) |
+----------------+----------+---------------------+
| minikube start | 24.5s    | 23.2s               |
| enable ingress | 21.3s    | 21.4s               |
+----------------+----------+---------------------+

Times for minikube start: 24.8s 24.0s 25.6s 24.4s 23.7s
Times for minikube (PR 17877) start: 23.7s 24.6s 24.4s 21.9s 21.4s

Times for minikube ingress: 20.7s 21.3s 21.8s 21.3s 21.3s
Times for minikube (PR 17877) ingress: 21.2s 20.8s 20.7s 22.8s 21.3s

docker driver with containerd runtime

+----------------+----------+---------------------+
|    COMMAND     | MINIKUBE | MINIKUBE (PR 17877) |
+----------------+----------+---------------------+
| minikube start | 21.9s    | 21.5s               |
| enable ingress | 32.7s    | 32.0s               |
+----------------+----------+---------------------+

Times for minikube start: 20.6s 22.5s 23.0s 20.5s 23.0s
Times for minikube (PR 17877) start: 23.8s 22.2s 19.9s 19.9s 21.7s

Times for minikube ingress: 31.2s 47.8s 19.8s 31.8s 32.8s
Times for minikube (PR 17877) ingress: 31.7s 31.8s 31.8s 31.8s 32.8s

@minikube-pr-bot
Copy link

These are the flake rates of all failed tests.

Environment Failed Tests Flake Rate (%)
Docker_Linux_crio_arm64 TestStartStop/group/old-k8s-version/serial/SecondStart (gopogh) 3.43 (chart)
QEMU_macOS TestAddons/Setup (gopogh) 9.46 (chart)
QEMU_macOS TestFunctional/parallel/CpCmd (gopogh) 9.46 (chart)
QEMU_macOS TestFunctional/parallel/FileSync (gopogh) 9.46 (chart)
QEMU_macOS TestFunctional/parallel/NonActiveRuntimeDisabled (gopogh) 9.46 (chart)
QEMU_macOS TestFunctional/parallel/SSHCmd (gopogh) 9.46 (chart)
QEMU_macOS TestFunctional/parallel/UpdateContextCmd/no_clusters (gopogh) 9.46 (chart)
QEMU_macOS TestFunctional/parallel/UpdateContextCmd/no_minikube_cluster (gopogh) 9.46 (chart)
QEMU_macOS TestFunctional/parallel/Version/components (gopogh) 9.46 (chart)
QEMU_macOS TestFunctional/serial/LogsCmd (gopogh) 9.46 (chart)
QEMU_macOS TestFunctional/serial/LogsFileCmd (gopogh) 9.46 (chart)
QEMU_macOS TestFunctional/parallel/CertSync (gopogh) 10.81 (chart)
QEMU_macOS TestFunctional/parallel/DashboardCmd (gopogh) 10.81 (chart)
QEMU_macOS TestFunctional/parallel/DockerEnv/bash (gopogh) 10.81 (chart)
QEMU_macOS TestFunctional/parallel/ImageCommands/ImageBuild (gopogh) 10.81 (chart)
QEMU_macOS TestFunctional/parallel/ImageCommands/ImageListJson (gopogh) 10.81 (chart)
QEMU_macOS TestFunctional/parallel/ImageCommands/ImageListShort (gopogh) 10.81 (chart)
QEMU_macOS TestFunctional/parallel/ImageCommands/ImageListTable (gopogh) 10.81 (chart)
QEMU_macOS TestFunctional/parallel/ImageCommands/ImageListYaml (gopogh) 10.81 (chart)
QEMU_macOS TestFunctional/parallel/ImageCommands/ImageLoadDaemon (gopogh) 10.81 (chart)
QEMU_macOS TestFunctional/parallel/ImageCommands/ImageLoadFromFile (gopogh) 10.81 (chart)
QEMU_macOS TestFunctional/parallel/ImageCommands/ImageReloadDaemon (gopogh) 10.81 (chart)
QEMU_macOS TestFunctional/parallel/ImageCommands/ImageSaveToFile (gopogh) 10.81 (chart)
QEMU_macOS TestFunctional/parallel/NodeLabels (gopogh) 10.81 (chart)
QEMU_macOS TestFunctional/parallel/PersistentVolumeClaim (gopogh) 10.81 (chart)
QEMU_macOS TestFunctional/parallel/ServiceCmd/DeployApp (gopogh) 10.81 (chart)
QEMU_macOS TestFunctional/parallel/ServiceCmd/Format (gopogh) 10.81 (chart)
QEMU_macOS TestFunctional/parallel/ServiceCmd/HTTPS (gopogh) 10.81 (chart)
QEMU_macOS TestFunctional/parallel/ServiceCmd/JSONOutput (gopogh) 10.81 (chart)
QEMU_macOS TestFunctional/parallel/ServiceCmd/List (gopogh) 10.81 (chart)
More tests... Continued...

Too many tests failed - See test logs for more details.

To see the flake rates of all tests by environment, click here.

@medyagh
Copy link
Member

medyagh commented Apr 3, 2024

/lgtm

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ComradeProgrammer, medyagh

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 Apr 3, 2024
@medyagh medyagh merged commit 666d444 into kubernetes:master Apr 3, 2024
15 of 27 checks passed
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. 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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

minikube service should support ClusterIP services
5 participants