kubernetes: Using LoadBalancer Service without Selector not working

What happened?

I was trying to use Service without selector using Endpoints resource as described here, but wasn’t able to get it working.

What did you expect to happen?

Sending a GET request to the LoadBalancer external IP should redirect the request to the IP specified under Endpoints resource but it didn’t.

How can we reproduce it (as minimally and precisely as possible)?

To make debugging easier, I created the following minimal example. I set the service’s type to LoadBalancer so that an external IP can be created and exposed for debugging.

apiVersion: v1
kind: Service
metadata:
  name: toy
spec:
  type: LoadBalancer
  ports:
    - port: 80
      targetPort: 80
---
apiVersion: v1
kind: Endpoints
metadata:
  name: toy
subsets:
  - addresses:
      - ip: "192.0.43.10"
    ports:
      - port: 80

Sending GET request directly to the IP specified above under addresses (i.e. 192.0.43.10:80) (curl -X GET 192.0.43.10:80) works and return some responses. However, Sending the same GET request to the LoadBalancer external IP does not work (connection refused).

Anything else we need to know?

No response

Kubernetes version

$ kubectl version
Client Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.2", GitCommit:"092fbfbf53427de67cac1e9fa54aaa09a28371d7", GitTreeState:"clean", BuildDate:"2021-06-16T12:59:11Z", GoVersion:"go1.16.5", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"20+", GitVersion:"v1.20.9-gke.1001", GitCommit:"1fe18c314ed577f6047d2712a9d1c8e498e22381", GitTreeState:"clean", BuildDate:"2021-08-23T23:06:28Z", GoVersion:"go1.15.13b5", Compiler:"gc", Platform:"linux/amd64"}

Cloud provider

GCP

OS version

No response

Install tools

No response

Container runtime (CRI) and and version (if applicable)

No response

Related plugins (CNI, CSI, …) and versions (if applicable)

No response

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 21 (12 by maintainers)

Most upvoted comments

/remove-kind bug