go gRPC routing without specifying port

Answer #1 0

If it is working internally in the pod, then you only need to expose it. You can do it by adding a yaml definition for a service. Like the following.

apiVersion: v1
kind: Service
metadata:
  namespace: $YOUR_NAMESPCAE
  labels:
    app: $YOUR_SERVICE_NAME
  name: $YOUR_SERVICE_NAME
spec:
  ports:
  - name: $YOUR_GRCP_PORT
    port: $YOUR_GRCP_PORT
    targetPort: $YOUR_GRCP_PORT
  selector:
    app: $YOUR_SERVICE_NAME
status:
  loadBalancer: {}

Note that where it says $YOUR_GRCP_PORTyou define the grcp port you will expose.

Now you only need to edit the ingress you mentioned. It should be something like the following.

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: vizix-ingress
  namespace: preprod-vizix-io
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/rewrite-target: "/"
spec:
  rules:
  - http:
      paths:
      - path: /
        backend:
          serviceName: $YOUR_SERVICE_NAME
          servicePort: $YOUR_GRCP_PORT

You’ll also like:


© 2023 CodeForDev.com -