kubernetes: Services without selectors cannot forward to other services as documented

Kubernetes version (use kubectl version):

Client Version: version.Info{Major:"1", Minor:"5", GitVersion:"v1.5.1", GitCommit:"82450d03cb057bab0950214ef122b67c83fb11df", GitTreeState:"clean", BuildDate:"2016-12-14T00:57:05Z", GoVersion:"go1.7.4", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"5", GitVersion:"v1.5.2", GitCommit:"08e099554f3c31f6e6f07b448ab3ed78d0520507", GitTreeState:"clean", BuildDate:"2017-01-12T04:52:34Z", GoVersion:"go1.7.4", Compiler:"gc", Platform:"linux/amd64"}

Environment:

Google Container Engine, 1.5.2

What happened:

I created a selectorless service and configured the endpoint to point at the ClusterIP of another service in a different namespace, as described in the documentation: https://kubernetes.io/docs/user-guide/services/#services-without-selectors

This is supported behaviour (“You want to point your service to a service in another Namespace or on another cluster”).

Any requests on the External IP of the selectorless service hang.

What you expected to happen:

Requests to be sent to the target service.

How to reproduce it (as minimally and precisely as possible):

Start this stack:

---
kind: Namespace
apiVersion: v1
metadata:
  name: reproducer-alpha
---
kind: Pod
apiVersion: v1
metadata:
  name: alpha
  namespace: reproducer-alpha
  labels:
    service: alpha
spec:
  containers:
    - name: alpha
      image: robhaswell/hello-env
      env:
        - name: HELLO_MSG
          value: I am ALPHA
      ports:
        - containerPort: 8080
---
kind: Service
apiVersion: v1
metadata:
  name: alpha
  namespace: reproducer-alpha
spec:
  ports:
    - protocol: TCP
      port: 8080
      targetPort: 8080
  selector:
    service: alpha
  clusterIP: 10.3.250.250
---
kind: Service
apiVersion: v1
metadata:
  name: frontend
  namespace: default
spec:
  ports:
    - protocol: TCP
      port: 8080
      targetPort: 8080
  type: LoadBalancer
---
kind: Endpoints
apiVersion: v1
metadata:
  name: frontend
  namespace: default
subsets:
  - addresses:
    - ip: 10.3.250.250
    ports:
    - port: 8080

Wait for the frontend service to be allocated an IP, then try to hit it with curl on port 8080: curl http://EXTERNAL-IP:8080. There is no output. I would expect the output to be ‘I am ALPHA’.

Anything else we need to know:

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 16 (7 by maintainers)

Commits related to this issue

Most upvoted comments

@yelled3 no, I never managed to get this working as documented. I gave up on this issue as soon as @thockin said “I don’t think this particular usage pattern was tested or even considered really” when my exact use-case was listed as an example in the documentation (“You want to point your service to a service in another Namespace or on another cluster”).

I’ve encountered enough wontfix attitudes on open source projects to know that pursuing this would exceed the amount of time I have available to finish this work.

In the end I used haxproxy in TCP mode and configured it with environment variables.