thesandlord / Istio101

⚡ Lightning-Talk Style Demo of Istio and OpenCensus⚡

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

gRPC ingress routing

mavvverick opened this issue · comments

commented

Hey,

can you provide me an example of Istio ingress.yaml for grpc routing with Kubernetes ? I have tried but unable to make it work with Istio.

Thanks in advance.

@noisyox this is on the backburner, but I do want to get to it eventually.

commented

@thesandlord I have finally made it work after numerous attempts. I hope it will help others as there is no complete solution provided in doc or else where.

Also, Istio101 has provided me a head start in configuring istio. Thanks a ton.

apiVersion: v1
kind: Service
metadata:
  name: frontend
  labels:
    app: frontend
spec:
  ports:
  - port: 50051
    targetPort: 50051      
    name: grpc-port
  selector:
    app: frontend

---

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: frontend-grpc
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: frontend
        version: prod
    spec:
      containers:
      - name: frontend
        image: image
        imagePullPolicy: Always
        ports:
        - containerPort: 50051
          name: grpc-port
        env:
        - name: SERVICE_NAME
          value: "frontend-prod"
        - name: UPSTREAM_URI
          value: "https://jsonplaceholder.typicode.com/todos/1"
---

apiVersion: networking.istio.io/v1alpha3
kind: ServiceEntry
metadata:
  name: jsonplaceholder
spec:
  hosts:
  - jsonplaceholder.typicode.com
  ports:
  - number: 80
    name: http
    protocol: HTTP
  - number: 443
    name: https
    protocol: HTTPS

---

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: istio-gateway
spec:
  selector:
    istio: ingressgateway # use Istio default gateway implementation
  servers:
  - port:
      number: 9090
      name: http
      protocol: HTTP
    hosts:
    - "*"

---

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: frontend
spec:
  gateways:
  - istio-gateway
  hosts:
  - "*"
  http:
  - match:
    - uri:
        prefix: /
    route:
    - destination:
        port:
          number: 50051
        host: frontend

I have converted frontend, middleware and backend to support grcp protocol. It works absolutely fine.

Do you want to send a pull request?

commented

yes, I will send by next week.