<p>I want to deploy a gRPC service to Azure Kubernetes Service. I have already depoyed RESTful services using Helm charts but gRPC service is throwing "connection timed out" error.</p>

<p>I have already tried everything said in the NGINX and HELM documentation but nothing worked. The certificate is self signed. I have tried all permutation and combination of annotations :p</p>

<p><b>Service.yaml</b></p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: {{ template "fullname" . }}
  labels:
    app: {{ template "fullname" . }}
    chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
    release: "{{ .Release.Name }}"
    heritage: "{{ .Release.Service }}"
spec:
  ports:
  - port: 50051
    protocol: TCP
    targetPort: 50051
    name: grpc
  selector:
    app: {{ template "fullname" . }}
  type: NodePort
</code></pre>

<p><b>ingress.yaml</b></p>

<pre><code>{{ if .Values.ingress.enabled }}
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: {{ template "fullname" . }} 
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/grpc-backend: "true"
    nginx.org/grpc-services: {{ template "fullname" . }}
    nginx.ingress.kubernetes.io/ssl-redirect: "true"
    nginx.ingress.kubernetes.io/rewrite-target: /$2
spec:
  tls:
    secretName: aks-ingress-tls
  rules:
  - http:
      proto: h2
      paths:
      - backend:
          serviceName: {{ template "fullname" . }}
          servicePort: grpc
          proto: h2
        path: /{servicename}-grpc(/|$)(.*)
{{ end }}
</code></pre>

<p>Tried this also- still not working-</p>

<pre><code>{{ if .Values.ingress.enabled }}
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: {{ template "fullname" . }} 
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/ssl-redirect: "true"
    nginx.ingress.kubernetes.io/backend-protocol: "GRPC"
    nginx.ingress.kubernetes.io/rewrite-target: /$2
spec:
  tls:
  - secretName: aks-ingress-tls
  rules:
  - http:
      paths:
      - backend:
          serviceName: {{ template "fullname" . }}
          servicePort: 50051
        path: /servicename-grpc(/|$)(.*)
{{ end }}
</code></pre>

Aniket Prashar
<p>It looks like you are missing an annotation on your ingress.</p>

<h3>ingress.yaml - snippet</h3>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    # This annotation matters!
    nginx.ingress.kubernetes.io/backend-protocol: "GRPC"
</code></pre>

<blockquote>
  <p>According to this snippet from the <a href="https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#backend-protocol" rel="nofollow noreferrer">official Kubernetes nginx ingress documentation</a>:</p>
  
  <h3>Backend Protocol</h3>
  
  <p>Using backend-protocol annotations is possible to indicate how NGINX should communicate with the backend service. (Replaces secure-backends in older versions) Valid Values: HTTP, HTTPS, GRPC, GRPCS and AJP</p>
  
  <p>By default NGINX uses HTTP.</p>
  
  <p>Example:</p>
  
  <p><code>nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"</code></p>
</blockquote>

<p>As an aside, there's a chance you might need to specify <code>GRPCS</code> instead of <code>GRPC</code> since it appears you are using SSL.</p>

<p>Another thing to call out is that the docs mention that this annotation replaces 'secure-backends' in older versions, which could be where you found the <code>grpc-backend</code> annotation you are currently using.</p>
