<p>Let's say we have a Kubernetes service which serves both a RESTful HTTP API and a gRPC API:</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  namespace: mynamespace
  name: myservice
spec:
  type: ClusterIP
  selector:
    app: my-app
  ports:
  - port: 80
    targetPort: 80
    protocol: TCP
    name: http
  - port: 8080
    targetPort: 8080
    protocol: TCP
    name: grpc
</code></pre>
<p>We want to be able to reach those service endpoints externally, for example from another Kubernetes cluster.</p>
<p>This could be achieved by changing the service type from <code>ClusterIP</code> to <code>LoadBalancer</code>. However, let's assume that this is not desirable, for example because it requires additional public IP addresses.</p>
<p>An alternative approach would be to use the <a href="https://kubernetes.io/docs/concepts/cluster-administration/proxies" rel="nofollow noreferrer">apiserver proxy</a> which</p>
<blockquote>
<p>connects a user outside of the cluster to cluster IPs which otherwise might not be reachable</p>
</blockquote>
<p>This works with the http endpoint. For example, if the http API exposes an endpoint <code>/api/foo</code>, it can be reached like this:</p>
<pre><code>http://myapiserver/api/v1/namespaces/mynamespace/services/myservice:http/proxy/api/foo
</code></pre>
<p>Is it somehow possible to also reach the gRPC service via the apiserver proxy? It would seem that since gRPC uses HTTP/2, the apiserver proxy won't support it out of the box. e.g. doing something like this on the client side...</p>
<pre><code>grpc.Dial(&quot;myapiserver/api/v1/namespaces/mynamespace/services/myservice:grpc/proxy&quot;)
</code></pre>
<p>... won't work.</p>
<p>Is there a way to connect to a gRPC service via the apiserver proxy?</p>
<p>If not, is there a different way to connect to the gRPC service from external, without using a <code>LoadBalancer</code> service?</p>

Max
<p><code>...not to require an additional public IP</code></p>
<p>NodePort is not bound to public IP. That is, your worker node can sits in the private network and reachable at the node private IP:nodePort#. The meantime, you can use <code>kubectl port-forward --namespace mynamespace service myservice 8080:8080</code> and connect thru localhost.</p>
