Kubernetes proxy with multiple ports

12/3/2015

is it possible to use the kubernetes api server's proxy feature to go to a specific port I have open on a service when I have many ports open?

I have looked at the swagger api spec, and there doesnt seem to be any parameter for choosing one of the potentially many ports of a service.

I have this influxdb service:

apiVersion: v1
kind: Service
metadata:
  labels:
    base_name: influx
  name: influx
  namespace: test
spec:
  clusterIP: 10.3.0.12
  ports:
  - name: admin-panel
    nodePort: 32646
    port: 8083
    protocol: TCP
    targetPort: 8083
  - name: api
    nodePort: 32613
    port: 8086
    protocol: TCP
    targetPort: 8086
  - name: snapshots
    nodePort: 30586
    port: 8087
    protocol: TCP
    targetPort: 8087
  selector:
    base_name: influx
  sessionAffinity: None
  type: NodePort
status:
  loadBalancer: {}

and I am trying to access the admin-pannel through the kubernetes api proxy like so:

https://kube-master/api/v1/proxy/namespaces/test/services/influx

which results in a 503 error

{
kind: "Status",
apiVersion: "v1",
metadata: { },
status: "Failure",
message: "no endpoints available for service "influx"",
reason: "ServiceUnavailable",
code: 503
}
-- esecules
kubernetes

1 Answer

12/3/2015

You should be able to append either an actual port or a portname at the end.

As an aside, it looks like your master is not firewalled, if this is true I recommend not making it accessible outside the cluster and running kubectl proxy on your localhost, this will create a proxy to the master, then you can hit: http://localhost:8001/api/v1/proxy/namespaces/test/services/influx:8083/

-- Prashanth B
Source: StackOverflow